Topic locked

Best way to switch from back to front camera, and back again?

August 24, 2014 - 2:27pm #1

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?

September 12, 2014 - 7:49am #4

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. Everything appears to work prefectly without reinitializing the trackers.

Best way to switch from back to front camera, and back again?

September 3, 2014 - 6:26am #3

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())

- deinit the camera (QCAR::CameraDevice::deinit())

- re-init the camera with the desired camera direction (front or back)

- re-start the camera (QCAR::Camera::start())

- re-start the Tracker

 

You may also want to have a quick look at:

https://developer.vuforia.com/forum/faq/ios-sample-code-tips

 

Best way to switch from back to front camera, and back again?

August 30, 2014 - 12:14pm #2

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. I think that's the only way to switch from using the back camera for AR, then the front camera for a simple image capture, and then the back camera again for AR (unless there's another solution that I'm missing). Thanks for any suggestions!

Topic locked