selectROI is not working.
I want to run a multi object tracking code nuder opencv 3.1 with contrib. In the code, there is a line with selectROI().
Console said to me "Select an object to track and then press SPACE or ENTER button! Finish the selection process by pressing ESC button!".
I could select roi with mouse click.
But the window can't capture my keyboard input. I can't proceed next step. What is a problem?
MultiTracker trackers(trackingAlg);
// container of the tracked objects
vector<Rect2d> objects;
// set input video
std::string video = argv[1];
VideoCapture cap(video);
Mat frame;
// get bounding box
cap >> frame;
selectROI("tracker", frame, objects);
//quit when the tracked object(s) is not provided
if (objects.size()<1)
return 0;
// initialize the tracker
trackers.add(frame, objects);
// do the tracking
printf("Start the tracking process, press ESC to quit.\n");
for (;;){
// get frame from the video
cap >> frame;
// stop the program if no more images
if (frame.rows == 0 || frame.cols == 0)
break;
//update the tracking result
trackers.update(frame);
// draw the tracked object
for (unsigned i = 0; i<trackers.objects.size(); i++)
rectangle(frame, trackers.objects[i], Scalar(255, 0, 0), 2, 1);
// show image with the tracked object
imshow("tracker", frame);
//quit on ESC button
if (waitKey(1) == 27)break;
}
windows 10 Yes, waitKey() works fine.
you actually have to perss 2 times, once(space or enter) to accept the selection, then esc, to leave the roiselector
I did that and press all of keys. but not working.
same problem here . the error is 'selectROI was not defined in this scope"