I am implementing a face recognition and eye blinking to authenticate a user.But I was wondering if you can capture the image with an android function and pass it on to the shared object and during this process the blinking function should capture the eye and monitor the frame for blinking in real time.My question is can I capture the image and use opencv-2.3.1 capture function to capture the frame for template matching at the same time.
You can offload the processing (with openCV) to a worker thread, then camera preview callbacks will continue normally. If you are using the faster setPreviewCallbackWithBuffer() method, then you should be careful to release your buffer for camera reuse as soon as possible - probably before the image recognition is complete.
Related
I have made an AR application which play video when the target is detected. But problem is that even when I place camera not in-front of the target image (No Target) its still keep playing until I go again an pause the video by clicking on the target.
If using Vuforia, there is a callback function, OnTrackingLost(), indicating that the tracker has been lost. You can stop the video in the body of this function.
If using another technology and you have to implement such a function by yourself, the obvious solution would be to use a timer. If the target image (previously recognized and tracked) is not detected for a given period of time, the tracker is lost. Again, you stop the video when you realize that the tracked image is lost.
I am making a pretty simple/standard camera app that uses a AVCaptureVideoPreviewLayer. When the user presses a button, I call captureStillImageAsynchronouslyFromConnection on the AVCaptureStillImageOutput to capture an image. At the time that I capture the image, I animate a simple white UIView over the preview layer as an indication to the user that a photo is being captured, and hide it again after the image capture is complete.
My problem is that when the camera flash is on, I don't want to display the white view immediately because the photo capture doesn't actually happen until after the flash has gone off. Is there a way to determine that the flash has finished or that the image capture has actually begun? Perhaps via KVO, NSNotificationCenter, or something?
Try using KVO on the capturingStillImage property of AVCaptureStillImageOutput.
The documentation reads like that may be what you need.
I'm working with the raw camera image, but need to restart the preview following the capture of an image. When i call startPreview() following takePicture, the android hangs because the camera is till in use. I've waited till after the raw image has been written to disk, but the camera is still in use, so the start preview still hangs the system.
camera.takePicture(null, null, null);
(test needed here){
camera.startPreview();
}
Putting the start preview in the rawcallback hangs the android.
When calling takePicture, the jpegCallback occurs after the camera is finished, so it is safe to start the preview, but this also creates a .jpg.
The question is following the takePicture, is there any way to determine when the camera is idle? (other than the jpegCallback?).
I've found ways around the problem, such as starting the preview on a timer, but still wonder if there is any way to determine the actual status of the camera and a way to test when it is save to restart the preview.
After calling the takePicture() function, you must wait until the JPEG callback has returned for the camera to be ready to use again. There is no way to monitor its status. The documentation explicitly states the following:
After calling this method, you must not call startPreview() or take
another picture until the JPEG callback has returned.
If you need some fast way of grabbing frames (i.e. images) without stopping and restarting the camera preview, you can implement the PreviewCallback interface which will simply allow you to grab preview frames without stopping the preview at all. Just remember that you will need to convert these from YUV format (which is not difficult using Android's YUVImage class.
So I have an application that can currently capture video with the front facing iphone camera and then do some processing on the video feed real-time. What I'm trying to do, however, is make this process run in the background and put other controls onscreen. So for example, say I'd like to run the camera and process the image feed, but I want the user to see a black screen with some buttons on it. Any ideas on how to do this?
Just so we get terminology right, by "in the background", you mean running the camera capture while your application is in the foreground, but not displaying the actual video feed. This is possible, but I wanted to make clear that if you move your whole application into the background you will not have access to the camera then.
There are a few ways to do this, but the one that I've spent the most time with is grabbing frames of video (or photos) via AV Foundation. Using an AVCaptureDevice and AVCaptureSession, you can grab the frames of video and route them to an encoder for saving to disk or for processing using your own custom code. None of this requires the camera feed to be displayed onscreen, so you can put up whatever interface you like and do this video recording or photo capture without any onscreen indication.
I would caution that you should make it explicit to your users what you are doing, so that you do not run the risk of violating someone's privacy. Apple does not react kindly to those who do this (for good reason).
I encapsulate a lot of this within my open source GPUImage video and photo processing framework, so you could look at the code for the GPUImageVideoCamera class there to see how I configure the capture inputs. I hand the video frames off to OpenGL ES for the application of filters and other processing operations, but you could ignore that portion of it if you just wanted to do your own encoding or processing.
Heres an exemple code from Apple's doc:
http://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html
there is also the way to customize the camera interface.
I'm doing research into AR on the iPhone and am trying to figure out how people are getting each frame of video? I'm wanting to figure out AR using computer vision( OpenCV ). So basically I will have a pattern on a piece of paper that I will find using OpenCV and place a graphic on top of the pattern.
I know about the movie class UIImagePickerController, but am unsure how you would go about getting to each frame.
Can someone point me in the right direction?
UIImagePickerController is the means for displaying a camera view and taking single pictures with a camera-like front end. It's not what you're looking for.
Instead you need to look into AVFoundation, particularly the classes surrounding AVCaptureSession. You'll want to acquire a meaningful AVCaptureDevice (which can be the front or back camera on the iPhone 4 and current iPod Touch), create an AVCaptureDeviceInput that references it and add that as an input to an AVCaptureSession. Then just create an AVCaptureVideoDataOutput and set it up with a meaningful delegate and a Grand Central Dispatch dispatch queue.
When you start the session going, you'll receive delegate callbacks on the queue you created providing CMSampleBufferRefs, from which you can pull a CVImageBufferRef and hence the pixel data.