goodbytes
goodbytes

Reputation: 438

Capture video frames with opencv in android

I am trying to process android video in real time with opencv-android. So far I am able to access the video with opencv, and display it on a org.opencv.android.JavaCameraView.(I referred to this link) I haven't been able to access the video feed of the camera by frame-wise. I need to get each and every frame in order to apply some opencv algorithms on them for object tracking. Please suggest a method to access and process the frames with opencv. (Redirect this if it's already been asked)

Upvotes: 2

Views: 4671

Answers (1)

Derek K
Derek K

Reputation: 3157

Here is how to do it:

 public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    //Do your processing here, for example:
    Mat image = inputFrame.rgba();
    Mat ret_mat=new Mat();
    Core.add(image, new Scalar(40, 40, 40, 0), ret_mat); //change brightness of video frame

    return ret_mat;
}

OpenCv functions operate with Mat object, which represents matrix of pixels of your image/frame. The code above makes each frame brighter by 40 units.

Upvotes: 1

Related Questions