Calculate Centroid of ractangle
10 views (last 30 days)
Show older comments
How can i modify this code to calculate the centroid of ractangular box as shown in the figure below.
peopleDetector = vision.PeopleDetector;
I = imread('detectman.jpg');
bboxes = step(peopleDetector, I);
people = insertObjectAnnotation(I, 'rectangle', bboxes, 'people');
figure, imshow(people)
I appreciate your feedaback and suggestion.
Thank you,
Regards,
Biswas
0 Comments
Answers (1)
Image Analyst
on 5 Jun 2016
bboxes is probably in the form [left, top, width, height] like rectangles usually are in MATLAB code. So the centroid is
xCentroid = bboxes(1) + bboxes(3)/2;
yCentroid = bboxes(2) + bboxes(4)/2;
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!