Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to only display an ROI in a video frame OpenCV java?

0 down vote favorite I am new to OpenCV and so I am still learning some of the functionalities. So, here is what I would like to achieve. I want to load my camera and in the camera frame I just want to keep the area inside the rectangular box to be seen in the camera frame. Anything outside the box should be completely black. How should I go about it. This is what I tried so far.

int centerx = (int) (mrgba.width()*0.5);
    int  centery = (int) (mrgba.height() * 0.5);

   // Rect rect = new Rect(centerx,centery,100,100);

  //  Mat submat = mrgba.submat(rect);

     Imgproc.rectangle(mrgba,new Point(centerx-100,centery - 100),new Point(centerx+100,centery+100),new Scalar(0,0,255) );

/Currently all it does, is that it draws a rectangle at the center of the camera frame but then I dont want anything outside that rectangular frame.
    return mrgba;

How to only display an ROI in a video frame OpenCV java?

0 down vote favorite I am new to OpenCV and so I am still learning some of the functionalities. So, here is what I would like to achieve. I want to load my camera and in the camera frame I just want to keep the area inside the rectangular box to be seen in the camera frame. Anything outside the box should be completely black. How should I go about it. This is what I tried so far.

int centerx = (int) (mrgba.width()*0.5);
    int  centery = (int) (mrgba.height() * 0.5);

   // Rect rect = new Rect(centerx,centery,100,100);

  //  Mat submat = mrgba.submat(rect);

     Imgproc.rectangle(mrgba,new Point(centerx-100,centery - 100),new Point(centerx+100,centery+100),new Scalar(0,0,255) );

/Currently all it does, is that it draws a rectangle at the center of the camera frame but then I dont want anything outside that rectangular frame.
    return mrgba;