List
Does changing camera type work on iPhone?
Posted Date: 2018-09-05 8:05     Edited Date: 2018-09-10 2:26     Writer: inactive

So, what i'm basicly doing, changing camera type when user presses the button:

AbstractConfigurationScriptableObject conf = ConfigurationScriptableObject.GetInstance();
conf.CameraType = (imgSwchr.State == 0) ? CameraDevice.CameraType.Rear : CameraDevice.CameraType.Face;

And then i flip the image verticaly if it's phone on portrait mode, and horizontaly, if its tablet and it's landscape mode:

if (imgSwchr.State == 1)
        {
            if(phone)
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, true);
            else
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.HORIZONTAL, true);
        }
        else
        {
            if (phone)
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, false);
            else
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.HORIZONTAL, false);
        }

Everything works find on android devices and iPad, but iPhone 5 crashes when i press change camera type button. Can you assist me in what i'm doing wrong?

Posted Date: 2018-09-06 4:50     Edited Date: 2018-09-06 4:50     Writer: slkim

It is probably because you did not stop the camera when you changed the camera position.

Try the code below.

AbstractConfigurationScriptableObject conf = ConfigurationScriptableObject.GetInstance();
if(conf.CameraType == CameraDevice.CameraType.Face) {
conf.CameraType = CameraDevice.CameraType.Rear;
CameraDevice.GetInstance().Stop();
CameraDevice.GetInstance().Start();
} else {
conf.CameraType = CameraDevice.CameraType.Face;
CameraDevice.GetInstance().Stop();
CameraDevice.GetInstance().Start();
}

 

Posted Date: 2018-09-06 7:43     Edited Date: 2018-09-06 7:43     Writer: inactive

But i do stop() and start() camera when doing it. In order:

1. Stop()

2. Change configuration

3. Start().

Is it wrong order? Here is full method code:

void CameraBtnClick()
    {
        bool phone = ApplicationSettings.AppType == ApplicationSettings.AppicationType.Phone;

        ImageSwitcher imgSwchr = cameraBtn.GetComponent<ImageSwitcher>();
        imgSwchr.SwitchNext(false);

        CameraDevice cameraDevice = CameraDevice.GetInstance();
        cameraDevice.Stop();

        AbstractConfigurationScriptableObject conf = ConfigurationScriptableObject.GetInstance();
        conf.CameraType = (imgSwchr.State == 0) ? CameraDevice.CameraType.Rear : CameraDevice.CameraType.Face;

        if (imgSwchr.State == 1)
        {
            if(phone)
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, true);
            else
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.HORIZONTAL, true);
        }
        else
        {
            if (phone)
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, false);
            else
                cameraDevice.FlipVideo(CameraDevice.FlipDirection.HORIZONTAL, false);
        }

        cameraDevice.Start();

    }

P.S. it's no way problem occurs on ImageSwitcher.

 

Posted Date: 2018-09-07 8:46     Edited Date: 2018-09-07 8:46     Writer: inactive

Here what logs on Xcode say:

"AVCaptureFocusModeContinuousAutoFocus And AVCaptureFocusModeAutoFocus not support"

Any idea?

Posted Date: 2018-09-10 2:26     Edited Date: 2018-09-10 2:26     Writer: slkim

Does iPad and iPhone5 is die with the above code?

"AVCaptureFocusModeContinuousAutoFocus And AVCaptureFocusModeAutoFocus not support" code is show because front camera is not support AutoFocus.