矩形不在检测到的眼睛对周围
Rectangle not around detected eye pair
我正在使用opencv 2.4.2和c ++。我对检测眼睛对的矩形有一个小问题。矩形不会出现在眼对周围,而是出现在检测到的面部矩形之外。我想我可能没有正确获得正确的参数。
这是一段代码
for(int i=0;i<faces.size();i++){
rectangle(frame,faces[i],Scalar(255,0,0),1,8,0);
Mat face = frame(faces[i]);
cvtColor(face,face,CV_BGR2GRAY);
imwrite("C:/Users/DELL/Documents/Visual Studio 2010/Projects/Haarcascade/Haarcascade/fot.jpg",face);
vector<Rect> eyes;
eye.detectMultiScale(face,eyes);
for( size_t j = 0; j < eyes.size(); j++ ){
rectangle(frame,eyes[i],Scalar(255,0,0),4,8,0);
}
}
谁能帮忙?谢谢
您正在寻找从0
到face->width
和从0
到face->height
范围内的眼睛,因此您可以获得相对于面部边界的眼睛坐标,然后在原始帧上绘制眼睛。您需要在框架中添加面部坐标,如下所示:
Rect r(faces[i].x + eyes[i].x, faces[i].y + eyes[i].y, eyes[i].width,eyes[i].height );
rectangle(frame,r,Scalar(255,0,0),4,8,0);
相关文章:
- 变量周围的堆栈'...'已损坏
- 运行时检查失败 #2 变量"A"周围的堆栈已损坏
- OpenCV代码不会检测人脸的数量,也不会在脸周围放一个圆圈
- 为什么我的 VS 代码调试器在我的C++代码周围弹跳?
- 运行时检查失败 #2 - 变量"e"周围的堆栈已损坏。发生
- 变量周围的堆栈'sortArray'已损坏
- 需要帮助编写 for 循环以在字符串周围创建边框
- 使函数参数默认为周围范围
- 变量周围的堆栈'folderPath'已损坏
- 线程构造函数周围的可变参数模板包装器无法编译
- 如何检查二维数组上的周围数字?
- 运行时检查失败 #2 - 变量周围的堆栈'...'已损坏
- 如何在屏幕周围生成随机像素
- 访问周围类中迭代器的私有值
- 运行时检查失败 #2 - 变量"l1"周围的堆栈已损坏
- C++:此代码可以编译,但引发运行时检查失败 #2 - 围绕变量周围的堆栈'num'已损坏。发生
- C 包装器C++库周围没有不必要的头文件
- 矩形不在检测到的眼睛对周围
- 如何检测并在眼睛的虹膜区域周围画一个圆圈
- 如何在opencvc++中绘制眼睛周围的旋转边界框