Android scale CvCameraViewListener2 prior to drawing

asked 2015-04-25 12:36:38 -0600

I would like to move a opencv application I built to Android, I would like it to be landscape with the one half to be a horizontally cropped video feed and the the other half to be text display.

Unfortunately I can't seem to crop the video, as all that is displayed is a blank screen.

public class MainActivity extends Activity implements CvCameraViewListener2 {

   ...

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
   int offset = winWidth / 4; // winWidth is the width of the screen
   Mat frame = inputFrame.rgba();
   Mat roi = frame.submat(offset, frame.rows() - offset, 0, frame.cols());
   frame.release();
   return roi;
}
edit retag flag offensive close merge delete

Comments

the submat is referencing the original frame's pixels, so

either clone it:

Mat roi = frame.submat(offset, frame.rows() - offset, 0, frame.cols()).clone();

or don't release the frame.

berak gravatar imageberak ( 2015-04-25 13:37:42 -0600 )edit

Ok thanks, but that still hasn't produced the results I expect.

Fortnight gravatar imageFortnight ( 2015-04-26 00:02:05 -0600 )edit