gpt4 book ai didi

opencv - opencv 2.4.9和vs 2012中运行源人脸检测时出错

转载 作者:行者123 更新时间:2023-12-02 11:02:48 24 4
gpt4 key购买 nike

我使用预构建的opencv 2.4.9我测试了在opencv 2.4.9中显示的图像是否有效,但是对于此源,它有错误吗?如果此错误是我使用预构建的opencv?该做什么而不该做什么
我将xml文件复制到当前文件夹和我的硬件corei5,Radeon ATI图形中

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/ml.h>

void doMosaic(IplImage* in, int x, int y,
int width, int height, int size);

int main (int argc, char **argv)
{
int i, c;
IplImage *src_img = 0, *src_gray = 0;
const char *cascade_name = "haarcascade_frontalface_alt.xml";
CvHaarClassifierCascade *cascade = 0;
CvMemStorage *storage = 0;
CvSeq *faces;

cascade = (CvHaarClassifierCascade *) cvLoad (cascade_name, 0, 0, 0);
cvNamedWindow ("Capture", CV_WINDOW_AUTOSIZE);
CvCapture *capture = cvCreateCameraCapture(0);
assert(capture != NULL);

while (1) {
src_img = cvQueryFrame (capture);
src_gray = cvCreateImage (cvGetSize(src_img), IPL_DEPTH_8U, 1);

storage = cvCreateMemStorage (0);
cvClearMemStorage (storage);
cvCvtColor (src_img, src_gray, CV_BGR2GRAY);
cvEqualizeHist (src_gray, src_gray);

faces = cvHaarDetectObjects (src_gray, cascade, storage,
1.11, 4, 0, cvSize (40, 40));
for (i = 0; i < (faces ? faces->total : 0); i++) {
CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
doMosaic(src_img, r->x, r->y, r->width, r->height, 20);
}

cvShowImage("Capture", src_img);
cvReleaseImage(&src_gray);

c = cvWaitKey (2);
if (c == '\x1b')
break;
}

cvReleaseCapture (&capture);
cvDestroyWindow ("Capture");

return 0;
}

void doMosaic(IplImage* in, int x0, int y0,
int width, int height, int size)
{
int b, g, r, col, row;

int xMin = size*(int)floor((double)x0/size);
int yMin = size*(int)floor((double)y0/size);
int xMax = size*(int)ceil((double)(x0+width)/size);
int yMax = size*(int)ceil((double)(y0+height)/size);

for(int y=yMin; y<yMax; y+=size){
for(int x=xMin; x<xMax; x+=size){
b = g = r = 0;
for(int i=0; i<size; i++){
if( y+i > in->height ){
break;
}
row = i;
for(int j=0; j<size; j++){
if( x+j > in->width ){
break;
}
b += (unsigned char)in->imageData[in->widthStep*(y+i)+(x+j)*3];
g += (unsigned char)in->imageData[in->widthStep*(y+i)+(x+j)*3+1];
r += (unsigned char)in->imageData[in->widthStep*(y+i)+(x+j)*3+2];
col = j;
}
}
row++;
col++;
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
in->imageData[in->widthStep*(y+i)+(x+j)*3] = cvRound((double)b/(row*col));
in->imageData[in->widthStep*(y+i)+(x+j)*3+1] = cvRound((double)g/(row*col));
in->imageData[in->widthStep*(y+i)+(x+j)*3+2] = cvRound((double)r/(row*col));
}
}
}
}
}

错误是微软的一个中断,请帮助我。非常感谢
First-chance exception at 0x75C4B727 in opencv.exe: Microsoft C++ exception: cv::Exception at memory location 0x003CF678.

If there is a handler for this exception, the program may be safely continued.

最佳答案

最终我成功了,我首先针对PDB错误工具>选项>调试>输出窗口> moduleloadmessage>关闭,然后我未选择工具>选项>调试>符号> Microsoft符号服务器,然后更改capture.open(-1);捕获.open(0);现在通过设置opencv itworks,非常感谢

关于opencv - opencv 2.4.9和vs 2012中运行源人脸检测时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31648878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com