与opencv有关C++程序解释问题
cvCvtColor(img,gray,CV_BGR2GRAY);cvResize(gray,small_img,CV_INTER_LINEAR);cvEqualizeH...
cvCvtColor( img, gray, CV_BGR2GRAY );
cvResize( gray, small_img, CV_INTER_LINEAR );
cvEqualizeHist( small_img, small_img );
cvClearMemStorage( storage );
if( cascade )
{
CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage, 1.1, 2,
cvSize(30, 30) );
for( int i = 0; i < (faces ? faces->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
}
}
cvShowImage( "result", img ); 展开
cvResize( gray, small_img, CV_INTER_LINEAR );
cvEqualizeHist( small_img, small_img );
cvClearMemStorage( storage );
if( cascade )
{
CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage, 1.1, 2,
cvSize(30, 30) );
for( int i = 0; i < (faces ? faces->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
}
}
cvShowImage( "result", img ); 展开
1个回答
展开全部
cvCvtColor( img, gray, CV_BGR2GRAY ); //把彩色图像img转化为灰度图像gray
cvResize( gray, small_img, CV_INTER_LINEAR ); //采用线性插值的方法调整gray图像和small_img相匹配
cvEqualizeHist( small_img, small_img ); //对small_img进行直方图均衡化,结果放在small_img
cvClearMemStorage( storage ); //清空storage内存储的内容(但不释放内存)
if( cascade )
{ CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage, 1.1, 2,cvSize(30, 30) ); //对small_img进行检索,返回的矩形框序列存放在faces
for( int i = 0; i < (faces ? faces->total : 0); i++ )
{ CvRect* r = (CvRect*)cvGetSeqElem( faces, i ); //获取每一个寻找到的物体的矩形框,一共找到faces->total个
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 ); //在img图像内绘制一个圆心为center半径为radius线条颜色为colors[i%8]的圆
} //3 是线的粗细,负数时表示填充,8线类型,0表示小数点位数
}
cvShowImage( "result", img ); //显示图像img
cvResize( gray, small_img, CV_INTER_LINEAR ); //采用线性插值的方法调整gray图像和small_img相匹配
cvEqualizeHist( small_img, small_img ); //对small_img进行直方图均衡化,结果放在small_img
cvClearMemStorage( storage ); //清空storage内存储的内容(但不释放内存)
if( cascade )
{ CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage, 1.1, 2,cvSize(30, 30) ); //对small_img进行检索,返回的矩形框序列存放在faces
for( int i = 0; i < (faces ? faces->total : 0); i++ )
{ CvRect* r = (CvRect*)cvGetSeqElem( faces, i ); //获取每一个寻找到的物体的矩形框,一共找到faces->total个
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 ); //在img图像内绘制一个圆心为center半径为radius线条颜色为colors[i%8]的圆
} //3 是线的粗细,负数时表示填充,8线类型,0表示小数点位数
}
cvShowImage( "result", img ); //显示图像img
来自:求助得到的回答
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询