Capture front-facing camera - Phonegap? - ios

How to capture video from front-facing camera, using Phonegap?
I found this navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2}); in Phonegaps API docs online. But I dont see anything about using the front camera instead of rear. Is it possible?

I think after the camera opens up, u can choose the front camera. Currently i dont think so there is an option to open the front camera by default

If your smartphone have front and back camera, when you use
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2});
capture camera will be opened with switch button automatically.

I was playing around with PhoneGap today since I had an idea for an app. For this idea I needed the front facing camera aswell to be selected as default. After trying different things I found a work around which selected the front facing camera by default [NOTE: this is a dirty fix, I've got no clue what happens on devices without a front facing camera!]
In Xcode (or whatever editor you use) open [ProjectName]/plugins/CDVCapture.m and locate both captureImage and captureVideo. Both functions/commands have a line saying
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
Add this line below:
pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
And both Video and Image capturing will select the front facing camera by default when opening up the camera app. However, the user still has the possibility to switch cameras.
Here's a pastebin with my full CVDCapture.m file: http://pastebin.com/kkkyiPdn

Related

Launch photo library without using uiimagepicker

I am working on a camera app. I need to adapt the same behavior of the default camera app which opens camera roll when you tap the image on the left corner.
How I can launch camera roll as the default app does? I do not want to get an image, so I don't need to use the UIImagePickerController
Thanks in advance
You can use Photos Framework Available from iOS 8.Using this framework,you will get direct access to photos.You can build your own image editing apps using this Framework.
Please download the sample code from this link :
Photos framework sample code

Video Preview Layer Running While in Split-View?

I currently have an app that displays the front facing camera atop a video preview layer. By default in iOS 9, the preview layer is interrupted/paused and will not resume until split-view is dismissed. Based on the nature of the app, maintaining the running camera preview layer while multitasking is essential.
Is there any way to force the capture session to continue previewing while in split view?
Update: Seems as if Apple does not allow any sort of camera use while the device has more than one application open. You can, however, invoke UIImagePickerController in order to take a photo while in split-view. Of course this solution only allows you to snap a single photo, and nothing more. Hope this helps someone!

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

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?

iOS App: AVFoundation Video camera recording delegates

I am trying to develop an app that records the video using the rear camera.
I want the video to be tweaked (adding overlay image, green screen) before saving it to a file.
I am using AVFoundation, and have researched anywhere, but I still cant make the correct codes to preview and record (without the tweaking)
Some codes that Iget from the internet use BufferDelegate, the rest are using RecordingDelegate.
Do I need to use both to achieve what I want? or is it just one ofthem?
Could you please pinpoint me how I can achieve this?

Change to secondary camera using Phonegap

I'm using phonegap 1.2 in a ipad2 app. I need to use the camera facing front, not the main camera. When the API activates the camera it starts ok, but it uses then main camera on the back, and the user has to switch to the secondary camera in the front. I can't find any parameters in the Phonegap API that can select which camera to use.
I'm afraid this is not one of the PhoneGap's features for the moment. I suggest you take this up to the github issue tracker for iOS of it's something you are interested.

Resources