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.
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.