Calculate Centroid of ractangle
조회 수: 4 (최근 30일)
이전 댓글 표시
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165661/image.jpeg)
I appreciate your feedaback and suggestion.
Thank you,
Regards,
Biswas
댓글 수: 0
답변 (1개)
Image Analyst
2016년 6월 5일
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;
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!