How to make android camera to capture particular area inside the screen?

android, camera, opencv

Solution

If you are using opencv then I presume you will have a callback called onCameraFrame that gives you a Mat that represents the camera frames using:

mRgba = inputFrame.rgba();

To generate the border you can simply write to mRgba before returning mRgba in the call to onCameraFrame. I do something similar here - in this case I draw a rectangle:

Core.rectangle(mRgba, new Point(w * 1 / 3, h * 1 / 3), new Point(
                w * 2 / 3, h * 2 / 3), Colours.RED);

Now if you only want the content of the rectangle then you can use submat:

 Rect roi = new Rect(new Point(w * 1 / 3 + 1, h * 1 / 3 + 1),
                new Point(w * 2 / 3, h * 2 / 3));
 Mat viewFinder = mRgba.submat(roi);

In this case viewFinder will now contain the image contained in the rectangle.

I hope that answers the question but come back to me if you need any more info.

Problem

I want to make a android custom camera to capture particular area like card io. I want to capture the image inside the boundaries. want to show the border in the screen also.I am using opencv for this Attached the image for reference

Original source