C 未声明的标识符错误

C 未声明的标识符错误,c,opencv,pthreads,face-detection,C,Opencv,Pthreads,Face Detection,我在一个线程上为人脸检测编写了这段代码,然后我将为眼睛、鼻子和嘴巴编写这段代码 但是有一个错误--'threadface\u func':未声明的标识符--我找不到它是什么 #include <iostream> #include "cv.h" #include "highgui.h" #include <pthread.h> typedef struct parameter_t{ CvSeq * detectRe

我在一个线程上为人脸检测编写了这段代码,然后我将为眼睛、鼻子和嘴巴编写这段代码 但是有一个错误--
'threadface\u func':未声明的标识符--我找不到它是什么

    #include <iostream>
    #include "cv.h"
    #include "highgui.h"
    #include <pthread.h>

    typedef struct parameter_t{
        CvSeq * detectRect_face;
        IplImage* capturedImg;
        CvHaarClassifierCascade * pCascade_face;
        CvMemStorage * storage;


    }parameter_t;

    int main ( int argc, const char* argv[] )
    {
            CvCapture* capture = cvCaptureFromCAM(0);
            IplImage* capturedImg;
            int resCount = 1;
            char path[50];
            int flags = CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH;

            CvHaarClassifierCascade * pCascade_face;
            pthread_t threadface;


            pCascade_face = (CvHaarClassifierCascade *)cvLoad("C:/Users/Furkan/Desktop/Computer Vision/Programlar/opencv/data/haarcascades/haarcascade_frontalface_alt.xml");
            cvNamedWindow("FaceDetection");

            while (true)
            {
                CvMemStorage * storage;
                CvSeq * detectRect_face;
                capturedImg = cvQueryFrame(capture);
                storage = cvCreateMemStorage(0);

                parameter_t my_parameters;

                int k=pthread_create(&threadface,0,threadface_func,(void*)&my_parameters);

                if(k!=0)
                {
                    printf("Create thread failed! error");
                    return 1;
                }


                cvShowImage("FaceDetection", capturedImg);

                int ch = cvWaitKey(1);

                if(ch==27)
                    break;
                else 
                    if(ch == 115)
                    {
                        sprintf(path,"d:/resim%d.bmp",resCount++);
                        cvSaveImage(path,capturedImg,0);
                    }
            }

        cvDestroyWindow("FaceDetection");

        cvReleaseCapture(&capture);

        return 0;
    }


    void* threadface_func(void* parameter){


        parameter_t *p =(parameter_t*)parameter;

        p->detectRect_face=cvHaarDetectObjects(p->capturedImg,p->pCascade_face,p->storage,1.15, 3, 0,cvSize(25, 15));

        for(int i=0;i<(p->detectRect_face ? p->detectRect_face->total:0); i++ )
            {
                CvRect* r = (CvRect*)cvGetSeqElem(p->detectRect_face, i); 
                CvPoint pt1 = { r->x, r->y }; 
                CvPoint pt2 = { r->x + r->width, r->y + r->height }; 
                cvRectangle(p->capturedImg, pt1, pt2, CV_RGB(255,0,0), 1,8, 0); 

            }

        return 0;
    }
#包括
#包括“cv.h”
#包括“highgui.h”
#包括
typedef结构参数{
CvSeq*探测面;
IplImage*capturedImg;
CvHaarClassifierCascade*pCascade_面;
CvMemStorage*存储;
}参数t;
int main(int argc,const char*argv[]
{
CvCapture*capture=cvCaptureFromCAM(0);
IplImage*capturedImg;
整数重计数=1;
字符路径[50];
int flags=CV_HAAR_FIND_max_OBJECT|CV_HAAR_DO_ROUGH_SEARCH;
CvHaarClassifierCascade*pCascade_面;
pthread_t螺纹面;
pCascade_face=(CvHaarClassifierCascade*)cvLoad(“C:/Users/Furkan/Desktop/Computer Vision/programmar/opencv/data/haarcascade/haarcascade_frontaface_alt.xml”);
cvNamedWindow(“面部检测”);
while(true)
{
CvMemStorage*存储;
CvSeq*探测面;
capturedImg=cvQueryFrame(捕获);
存储=cvCreateMemStorage(0);
参数\u t我的\u参数;
int k=pthread_create(&threadface,0,threadface_func,(void*)和my_参数);
如果(k!=0)
{
printf(“创建线程失败!错误”);
返回1;
}
cvShowImage(“面部检测”,capturedImg);
int ch=cvWaitKey(1);
如果(ch==27)
打破
其他的
如果(ch==115)
{
sprintf(路径“d:/resim%d.bmp”,重计数++);
cvSaveImage(路径,capturedImg,0);
}
}
CVD窗口(“面部检测”);
cvReleaseCapture(&capture);
返回0;
}
void*螺纹面函数(void*参数){
参数_t*p=(参数_t*)参数;
p->detectRect_face=cvHaarDetectObjects(p->capturedImg,p->pCascade_face,p->storage,1.15,3,0,cvSize(25,15));
对于(inti=0;idetectRect\u-face?p->detectRect\u-face->总计:0);i++)
{
CvRect*r=(CvRect*)cvGetSeqElem(p->detectRect_face,i);
cvpointpt1={r->x,r->y};
CvPoint pt2={r->x+r->宽度,r->y+r->高度};
CV矩形(p->capturedImg,pt1,pt2,CV_RGB(255,0,0),1,8,0);
}
返回0;
}

请帮助…

在C中,函数必须在引用位置之前声明。在主()/<代码>的中间引用函数<代码> thRead FraseFunc < /Cuff>,因此您必须在此之前声明某个地方。

简单的解决方法是将其添加到
main()
的正上方:


或者,您可以将整个函数移动到
main()
之前。在C中,函数必须在引用位置之前声明。在主()/<代码>的中间引用函数<代码> thRead FraseFunc < /Cuff>,因此您必须在此之前声明某个地方。

简单的解决方法是将其添加到
main()
的正上方:


或者,您可以将整个函数移动到
main()

之前,发布完整的错误消息可能与此没有直接关系,但很快就会出现问题。看来你正在编译C++代码作为C代码。不要这样做,这些是不同的语言,有微妙的差异。在C语言中,IO是通过“
stdio.h
”头提供的函数完成的<代码> IoSturis/Cuff>是C++。发布完整的错误消息可能不是直接相关的,但可能很快就会出现问题。看来你正在编译C++代码作为C代码。不要这样做,这些是不同的语言,有微妙的差异。在C语言中,IO是通过“
stdio.h
”头提供的函数完成的<代码> iSoStase是C++。我已经做了你的解决方案。非常感谢。问题解决了。但是现在还有另一个错误---未解析的外部符号\uu imp\uu pthread\u创建在函数\u main中引用-???@FrknErgt-当使用pthread构建时,您需要链接到pthread库。我做了您的解决方案。非常感谢。问题解决了。但现在还有另一个错误,即--unresolved external symbol uu imp u pthread u create在函数main--?@FrknErgt中引用--当使用pthread构建时,需要链接到pthread库
void* threadface_func(void* parameter);