I have a use case where I want to use the back camera for most of the time, then switch to the front camera to capture an image, and then switch to the back camera again, creating an overlay with the captured front camera image. I'm new to iOS, but I've been able to do AR using the back camera, setup my AVCaptureSession to activate the front image, and start capturing frames from the front camera. However, when I try and tear down the front camera session and return to the back camera, my app crashes with a bad access. My thinking is that I'm not handling the starting and stopping of the QCAR session properly.
So my question is what would be the best practices in switching from one camera to another? (I'm doing this from my EAGLView, so I probably need to have access to the SampleApplicationSession that I created in my original ViewController?)
- Do I pauseAR, and then resumeAR?
- Do I stopAR, and then startAR again, going through all of my initialization steps as if I have restarted the app?
- Some other method?
Thanks for your help!
Best way to switch from back to front camera, and back again?
I hate to be that person that bumps a thread, but I'm just curious if anyone had succeeded in stopping and starting AR within an app.
Best way to switch from back to front camera, and back again?
Hi,
in gneral, these are the correct steps that you should take in order to switch camera direction:
- stop any QCAR::Tracker currently running (e.g. if you have an ImageTracker running)
- stop the camera (QCAR::CameraDevice::stop())
Best way to switch from back to front camera, and back again?
Thanks for the tips. When using the front camera I'm not trying to do any tracking, so I found that when I needed to return to the back camera, I simply had to stop() and start() the camera again to prevent the crash.