2016-03-21 86 views
0

我是matlab新手。我想要測量RGB或灰度圖像中邊界框的x和y座標以及質心。我不知道我該怎麼做來解決這個問題。任何人都可以幫我解決這個問題嗎?matlab中邊界框座標測量

這是我至今

frame=step(obj); 
bbox=step(faceDetector,frame); 
boxInserter = insertObjectAnnotation(frame,'rectangle',bbox, 'Face Detected'); 
imshow(boxInserter,'border','tight'); 

回答

0

根據臉部的數量相框具有的step方法返回一個bbox矩陣具有不同尺寸,其中包含邊界框本身的座標代碼。在這裏看到的bbox描述:

https://www.mathworks.com/help/vision/ref/vision.cascadeobjectdetector.step.html

因此,例如,

% Create a cascade detector object. 
faceDetector = vision.CascadeObjectDetector(); 

% Read a video frame and run the detector. 
videoFileReader = vision.VideoFileReader('visionface.avi'); 
videoFrame  = step(videoFileReader); 
bbox   = step(faceDetector, videoFrame); 

回報這bbox

264 122 93 93 

這些數字的格式:[XY寬度高度]

a因此臉部的x,y位置是[264,122]。那麼從這些數字計算質心應該是相當簡單的。