Ask Your Question

MultiTracker Rois

asked 2018-12-07 05:51:32 -0500

cherault gravatar image

Dear all,

Using the Multitracker algorithm, I would like to know how can I show the ROIs selected in various windows ? I mean show a new window for each ROI selected.

Thanks for your help and support.

Regards,` while(true) { cap >> frame;

  for(unsigned i=0;i<trackers.getObjects().size();i++)
      rectangle(frame, trackers.getObjects()[i], Scalar::all(255), 2);


} `

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-12-09 07:05:49 -0500

berak gravatar image

updated 2018-12-11 00:10:30 -0500

you need to clone() the image (so you can draw things independantly), and call imshow() with different window names, like:

  for(unsigned i=0; i<trackers.getObjects().size(); i++)
      Mat img = frame.clone();
      rectangle(img, trackers.getObjects()[i], Scalar::all(255), 2);
      imshow(format("tracker_%d", i), img);



if you're mainly interested in the content of the roi's you also could try like this:

  Size sz(100,100);
  Mat rois;
  vector<Rect2d> rects = trackers.getObjects();
  for(unsigned i=0; i<rects.size(); i++)
     Mat patch;
     resize(frame(rects[i]), patch, sz);
     if (rois.empty())
         rois = patch.clone();
         hconcat(rois, patch, rois);

  imshow("ROIS", rois);
edit flag offensive delete link more


Ok Berak, I solved my problem according to your kind answer. Thanks a lot ! Regards,

cherault gravatar imagecherault ( 2018-12-09 13:18:34 -0500 )edit

answered 2018-12-09 13:07:28 -0500

cherault gravatar image

updated 2018-12-09 13:08:59 -0500

Hello Berak,

One more time thank you. The problem is not to show various windows for each ROI, the problem is how to show window with only the selected ROI. For example, I select various "target" to track, using the MultiTracker algorithm. I need to show various windows which include only the ROIs selected by mouse. If I have three ROI with various size (Width and Height), I want to plot them on separated windows with the same ROI size.

Is it possible to achieve that ?

Thanks for your help and support


edit flag offensive delete link more




  for(unsigned i=0; i<trackers.getObjects().size(); i++)
      Mat img = frame(trackers.getObjects()[i]);
      imshow(format("tracker_%d", i), img);

sturkmen gravatar imagesturkmen ( 2018-12-09 14:11:39 -0500 )edit

Thank you a lot Sturkmen, this is the solution I did. Regards,

cherault gravatar imagecherault ( 2018-12-10 01:52:49 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-12-07 05:51:32 -0500

Seen: 297 times

Last updated: Dec 11 '18