Reputation: 865
I am trying to develop a driving recorder app for android 6.0 platform. This app can record video capturing from camera and save to mp4 files. During the saving process, I hope the app to also capture the image one by one with the image I can do some image analysis with opencv such as finding the lane edges or testing if something in front of my car, so on and so for.
I have researched the sample app Camera2Video and now I can have my app to save the video mp4 file capturing from the camera.
My next step is to let my app know when each image capturing from camera is ready, or when the MediaRecorder get single image, so that I can take that image for the subsequent process.
My problem is, how do I config the listener or whatever can let my app know when each single image capturing from camera is ready ?
Upvotes: 1
Views: 798
Reputation: 18107
Add an additional output Surface from an ImageReader (or from a SurfaceTexture if you want GPU-based processing, or from an Allocation for RenderScript-based processing) in your capture session creation. Then for your recording request, include the ImageReader surface as a target as well.
The maximum resolution you can make this stream depends on the capabilities of the camera device; a LEGACY-level device can't really do this, but anything else is fine with 3 outputs at RECORD, RECORD, and PREVIEW resolutions.
Then create a listener for the ImageReader and use the onImageAvailable callbacks to process frames as they come in.
Upvotes: 1