I have been trying for days to show an ROI in another window, taking video from a webcam

asked 2018-07-18 17:02:57 -0500

#include <opencv2 opencv.hpp="">

include <tchar.h>

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <opencv2 video="" background_segm.hpp="">

include <opencv2 video="" tracking.hpp="">

using namespace std; using namespace cv;

int main(int argc, char ** argv[]) { VideoCapture cap(1);

if (!cap.isOpened())
    return -1;
Mat gray;

for (;;)
{
    Mat frame;
    cap >> frame;
    namedWindow("VideoCam", WINDOW_AUTOSIZE);
    imshow("VideoCam", frame);
    Rect rec(50, 20, 1200, 200);
    rectangle(frame, rec, Scalar(255), 1, 5, 1);
    Rect rec1(50, 700, 1200, 200);
    rectangle(frame, rec1, Scalar(255), 1, 5, 1);
    Mat Roi = frame(rec);

    imshow("Recort1", frame);

    if (waitKey(50) >= 0)break;
}

return 0;

}

edit retag flag offensive close merge delete

Comments

imshow("Recort1", frame); <-- put Roi there, not frame

berak gravatar imageberak ( 2018-07-19 01:49:16 -0500 )edit