如何识别确定图片中人头数量
各位大侠,我在网上找到一点行者的关于识别照片中人头数量的部分代码,但因我功力不够,现请各位大侠帮忙,补全行者代码中缺少的部分,以便确定照片中人头个数,谢谢!
libfacedetect.rar
(256.07 KB)
行者 的部分代码:
img = cvimread('faa.jpg',1)
gray = mat_CJian()
cvtColor(img,gray,0)
ImgData = Mat_data(gray)
Imgheight = Mat_rows(gray)
Imgwidth = Mat_cols(gray)
imgWidthStep = imgwidth
t1 = seconds()
Faceret = facedetect_multiview(ImgData,Imgwidth,Imgheight,Imgwidth,ImgWidthStep)
FaceMum = CTOBIN(SYS(2600,faceRet,4),'4rs')
? '人脸数量:' + STR(faceMum)
t2 = SECONDS()
? '检测耗时:' + STR(t2-t1,6,4)
IF faceMum > 0
FOR i = 0 TO faceMum-1
faceX = CTOBIN(SYS(2600,faceRet+4+12*i,2),'2rs')
faceY = CTOBIN(SYS(2600,faceRet+6+12*i,2),'2rs')
faceV = CTOBIN(SYS(2600,faceRet+8+12*i,2),'2rs')
faceH = CTOBIN(SYS(2600,faceRet+10+12*i,2),'2rs')
neighbors = CTOBIN(SYS(2600,faceRet+12+12*i,2),'2rs')
angle = CTOBIN(SYS(2600,faceRet+14+12*i,2),'2rs')
cvRectangle(img,cvRect(faceX,faceY,faceV,faceH),cvScalar(0,0xff,0,0),1,8)
ENDFOR
ENDIF
cvimghow('123',img)