Previewing and saving photos in CameraActivity
Our main activity, CameraActivity
, needs to do the following:
On startup, use OpenCV Manager to ensure that the appropriate OpenCV shared libraries are available. (For more information about OpenCV Manager, refer back to the Building the OpenCV samples with Eclipse section in Chapter 1, Setting Up OpenCV.)
Display a live camera feed.
Provide the following menu actions:
Switch the active camera (for a device that has multiple cameras).
Save a photo and insert it into
MediaStore
so that it is accessible to apps such asGallery
. Immediately open the photo inLabActivity
.
We will use OpenCV functionality wherever feasible, even though we could just use the standard Android libraries to display a live camera feed, save a photo, and so on.
OpenCV provides an abstract class called CameraBridgeViewBase
, which represents a live camera feed. This class extends Android's SurfaceView
class, so that its instances can be part of the view hierarchy. Moreover, a...