Ask Your Question
1

MultiTracker Rois

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

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);
  }

  imshow("tracker",frame);
  waitKey(30);

} `

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

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

berak gravatar image

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

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);
  }

  waitKey(30);

edit:

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();
     else
         hconcat(rois, patch, rois);
  }

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

Comments

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

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

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

cherault gravatar image

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

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

Regards,

edit flag offensive delete link more

Comments

1

try

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

  waitKey(30);
sturkmen gravatar imagesturkmen ( 2018-12-09 14:11:39 -0600 )edit

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

cherault gravatar imagecherault ( 2018-12-10 01:52:49 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,023 times

Last updated: Dec 11 '18