Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 跟踪视频中的瞳孔_Opencv_Computer Vision_Eye Tracking - Fatal编程技术网

Opencv 跟踪视频中的瞳孔

Opencv 跟踪视频中的瞳孔,opencv,computer-vision,eye-tracking,Opencv,Computer Vision,Eye Tracking,我正在做一个项目,目标是跟踪瞳孔。为此,我制作了一个头戴式系统,可以捕捉眼睛的图像。完成了硬件部分,我被软件部分击中了。我正在使用opencv。请让我知道追踪学生最有效的方法是什么Houghcircles表现不佳 在此之后,我还尝试了HSV过滤器,下面是代码和代码 链接到原始图像和已处理图像的屏幕截图。请帮我解决这个问题。该链接还包含我在此代码中使用的瞳孔视频 代码: include "cv.h" include"highgui.h" IplImage* GetThresholdedIma

我正在做一个项目,目标是跟踪瞳孔。为此,我制作了一个头戴式系统,可以捕捉眼睛的图像。完成了硬件部分,我被软件部分击中了。我正在使用opencv。请让我知道追踪学生最有效的方法是什么Houghcircles表现不佳

在此之后,我还尝试了HSV过滤器,下面是代码和代码 链接到原始图像和已处理图像的屏幕截图。请帮我解决这个问题。该链接还包含我在此代码中使用的瞳孔视频

代码:

include "cv.h"

include"highgui.h"

IplImage* GetThresholdedImage(IplImage* img)
{

    IplImage *imgHSV=cvCreateImage(cvGetSize(img),8,3);
    cvCvtColor(img,imgHSV,CV_BGR2HSV);
    IplImage *imgThresh=cvCreateImage(cvGetSize(img),8,1);
    cvInRangeS(imgHSV,cvScalar(0, 84, 0, 0),cvScalar(179, 256, 11, 0),imgThresh);
    cvReleaseImage(&imgHSV);
    return imgThresh;
}

void main(int *argv,char **argc)
{

    IplImage *imgScribble= NULL;
    char c=0;
    CvCapture *capture;
    capture=cvCreateFileCapture("main.avi");

    if(!capture)
    {
        printf("Camera could not be initialized");
        exit(0);
    }
    cvNamedWindow("Simple");
    cvNamedWindow("Thresholded");

    while(c!=32)
    {
        IplImage *img=0;
        img=cvQueryFrame(capture);
        if(!img)
            break;
        if(imgScribble==NULL)
            imgScribble=cvCreateImage(cvGetSize(img),8,3);

        IplImage *timg=GetThresholdedImage(img);
        CvMoments *moments=(CvMoments*)malloc(sizeof(CvMoments));
        cvMoments(timg,moments,1);

        double moment10 = cvGetSpatialMoment(moments, 1, 0);
        double moment01 = cvGetSpatialMoment(moments, 0, 1);
        double area = cvGetCentralMoment(moments, 0, 0);

        static int posX = 0;
        static int posY = 0;

        int lastX = posX;
        int lastY = posY;

        posX = moment10/area;
        posY = moment01/area;
         // Print it out for debugging purposes
        printf("position (%d,%d)\n", posX, posY);
        // We want to draw a line only if its a valid position
        if(lastX>0 && lastY>0 && posX>0 && posY>0)
        {
            // Draw a yellow line from the previous point to the current point
            cvLine(imgScribble, cvPoint(posX, posY), cvPoint(lastX, lastY), cvScalar(0,255,255), 5);
        }
        // Add the scribbling image and the frame...

        cvAdd(img, imgScribble, img);

        cvShowImage("Simple",img);
        cvShowImage("Thresholded",timg);
        c=cvWaitKey(3);
        cvReleaseImage(&timg);
        delete moments;

    }
    //cvReleaseImage(&img);
    cvDestroyWindow("Simple");
    cvDestroyWindow("Thresholded");

}

我能够跟踪眼睛,精确地找到瞳孔的中心坐标

首先,我对头戴式相机拍摄的图像进行阈值分割。之后,我使用了轮廓查找算法,然后我找到了所有轮廓的质心。这给了我瞳孔的中心坐标,这种方法实时性很好,而且检测眨眼的精度也很高

现在,我的目标是将此功能嵌入到游戏(赛车游戏)中。如果我向左/向右看,汽车就会向左/向右移动,如果我眨眼,汽车就会减速。我现在该怎么办???我需要一个游戏引擎来完成吗


我听说过一些与VisualStudio2010(unity等)兼容的开源游戏引擎。可行吗???如果是,我应该如何进行

我是SimpleCV的开发者之一。我们为计算机视觉维护一个开源python库。你可以在下载。SimpleCV非常适合通过在命令行上进行黑客攻击来解决这些类型的问题。我只用几行代码就能提取出这个学生。给你:

img = Image("eye4.jpg") # load the image
bm = BlobMaker() # create the blob extractor
# invert the image so the pupil is white, threshold the image, and invert again
# and then extract the information from the image
blobs = bm.extractFromBinary(img.invert().binarize(thresh=240).invert(),img)

if(len(blobs)>0): # if we got a blob
    blobs[0].draw() # the zeroth blob is the largest blob - draw it
    locationStr = "("+str(blobs[0].x)+","+str(blobs[0].y)+")"
    # write the blob's centroid to the image
    img.dl().text(locationStr,(0,0),color=Color.RED)
    # save the image
    img.save("eye4pupil.png")
    # and show us the result.
    img.show()


因此,接下来的步骤是使用某种跟踪器,比如Kalmann滤波器,来可靠地跟踪瞳孔。您可能希望将眼睛建模为球体,并在球体坐标(即θ和φ)中跟踪瞳孔的质心。您还需要编写一些代码来检测眨眼事件,这样当用户眨眼时,系统不会完全不稳定。我建议使用canny边缘检测器来找到图像中最大的水平线,并假设这些是眼睑。我希望这有帮助,请让我们知道你的工作进展如何

这一切都取决于你的系统必须有多好。如果这是一个2个月的大学项目,按照Kscottz的建议,找到并跟踪一些斑点或使用现成的解决方案是可以的

但如果你的目标是建立一个更严肃的体系,你必须更深入

我建议您使用的一种方法是检测人脸兴趣点。一个很好的例子是活动外观模型,它似乎最擅长跟踪人脸

它需要你对计算机视觉算法有扎实的理解,良好的编程技能,以及一些工作。但结果是值得付出努力的

而且不要被演示显示全脸跟踪的事实所愚弄。你可以训练它跟踪任何东西:手、眼睛、花或叶子等等


(在开始使用AAM之前,您可能想了解更多有关其他人脸跟踪算法的信息。它们可能更适合您)

这是我的解决方案,我能够精确跟踪眼睛并找到瞳孔的中心坐标


首先,我对头戴式相机拍摄的图像进行阈值分割。之后,我使用了轮廓查找算法,然后我找到了所有轮廓的质心。这给了我瞳孔的中心坐标,这种方法实时性很好,而且检测眨眼的精度也很高

这真的应该是一个新问题。好的,给你