1

I'm a fresher to Matlab. I'm working on vision.CascadeObjectDetector on Mat-lab and is used twice to find-out two different objects(separately trained), say E and K from a video. bbox and bbox2 are respective ROIs. part of code is given below

while ~isDone(videoFileReader)
videoFrame=step(videoFileReader);
bbox=step(letterDetector_E,videoFrame);
bbox2=step(letterDetector_K,videoFrame);
C = vertcat(bbox,bbox2); 
videoOut=insertObjectAnnotation(videoFrame, 'rectangle', C, 'E&K');
step(videoPlayer, videoOut);
end

I want to take each ROI(both bbox and bbox2 considering together) one by one from left two right, top to bottom like reading a page. how can I do that.

Dima
  • 38,860
  • 14
  • 75
  • 115
SREE
  • 464
  • 3
  • 20

1 Answers1

1

I'm not sure what's the format of bbox here, but assuming it is a vector bbox = [xUpperLeft, yUpperLeft, width, height], you simply need to sort by two columns in succession. For this you can use sortrows:

sortrows(C, [1 2]);

This sorts the rows of C first by xUpperLeft (the first column), and then by yUpperLeft (the second column). See also a similar question here.

buzjwa
  • 2,632
  • 2
  • 24
  • 37
  • ya. bbox format is same as u assume... thanks... let me check whether it works for my project :-) – SREE Jan 23 '15 at 04:50