Display changing lines using Computer Vision Toolbox. PLEASE HELP!

1 次查看(过去 30 天)
I am writing a program using the Computer Vision Toolbox. My program detects two objects by thresholding and then using Blob analysis to place bounding boxes around the objects. I would like to insert a line between the bounding boxes and eventually find the distances between the objects. However, the bounding boxes are only present when the objects are in the video and therefore the lines will not always be present. I have tried this:
if not(isempty(BBox))
if (size(BBox,1)> 2)
pts = [BBox(1,1) BBox(1,2) BBox(2,1) BBox(2,2)];
Imr = step(hshapeins, Imr, pts);
step(hAllObjects, Imr);
end
end
If anyone has any idea how to do this please comment!!! Thanks.

采纳的回答

Witek Jachimczyk
Witek Jachimczyk 2012-7-31
Hi,
This would connect upper left corners of the bounding boxes. What you are doing makes sense. What is the exact problem that you are running into?
I see some issues in the code above:
  • you are assuming two objects, yet, this line: if (size(BBox,1)> 2) requires more than two objects; I think that you meant to write: if (size(BBox,1) >= 2)
  • I assume that you have hshapeins configured to draw lines; if that's correct then your code should work
HTH,
Witek
  1 个评论
Samuel Thomas
Samuel Thomas 2012-8-3
Thank you very much!! I can't believe I missed that.
I have another question. I am now trying to display the distance of my changing line. I've gotten a number to display but it isn't changing. I computed the value myself and it doesn't match up. This is what my code looks like:
if not(isempty(BBox))
if (size(BBox,1) >= 2)
d = sqrt(double(((BBox(2,1)+BBox(2,3)+20)- (BBox(1,1)+BBox(1,3)+130))^2+((BBox(2,2)+BBox(2,4)-100)-(BBox(1,2)+BBox(1,4)+110))^2));
d = int8(d);
Imr = step(DistanceDisplay, Imr, d);
step(hAllObjects, Imr);
end
end
If you could help me that would be great!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tracking and Motion Estimation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by