C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 用于眼动追踪的屏幕计算大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用眼动追踪我已经使用OpenCV成功建立了虹膜跟踪算法,并使用了轮廓和Hough变换.但下一步对我来说还不清楚.我想知道我正在做的计算是否正确将中心转换为屏幕.用户的头部具有固定的位置.

c – 用于眼动追踪的屏幕计算

我想要的是一种适用于所有目光的算法.有角度计算吗?那么当用户向右看时,线性?

我现在做的是:
 首先,我让用户查看特定点,并使用RANSAC检测最接近屏幕位置的光圈位置.我用屏幕上的四个2D点和虹膜来做到这一点.我正在使用Homography来获得正确的计算.

void gaussian_elimination(float *input,int n){
// ported to c from pseudocode in
// http://en.wikipedia.org/wiki/Gaussian_elimination

float * A = input;
int i = 0;
int j = 0;
int m = n-1;
while (i < m && j < n){
    // Find pivot in column j,starTing in row i:
    int maxi = i;
    for(int k = i+1; k<m; k++){
        if(fabs(A[k*n+j]) > fabs(A[maxi*n+j])){
            maxi = k;
        }
    }
    if (A[maxi*n+j] != 0){
        //swap rows i and maxi,but do not change the value of i
        if(i!=maxi)
            for(int k=0;k<n;k++){
                float aux = A[i*n+k];
                A[i*n+k]=A[maxi*n+k];
                A[maxi*n+k]=aux;
            }
        //Now A[i,j] will contain the old value of A[maxi,j].
        //divide each entry in row i by A[i,j]
        float A_ij=A[i*n+j];
        for(int k=0;k<n;k++){
            A[i*n+k]/=A_ij;
        }
        //Now A[i,j] will have the value 1.
        for(int u = i+1; u< m; u++){
            //subtract A[u,j] * row i from row u
            float A_uj = A[u*n+j];
            for(int k=0;k<n;k++){
                A[u*n+k]-=A_uj*A[i*n+k];
            }
            //Now A[u,j] will be 0,since A[u,j] - A[i,j] * A[u,j] = A[u,j] - 1 * A[u,j] = 0.
        }

        i++;
    }
    j++;
}

//BACk substitution
for(int i=m-2;i>=0;i--){
    for(int j=i+1;j<n-1;j++){
        A[i*n+m]-=A[i*n+j]*A[j*n+m];
        //A[i*n+j]=0;
    }
}
}



ofMatrix4x4 findHomography(ofPoint src[4],ofPoint dst[4]){
ofMatrix4x4 matrix;

// create the equation sy@L_607_7@ to be solved
//
// from: Multiple View Geometry in Computer Vision 2ed
//       Hartley R. and ZisseRMAN A.
//
// x' = xH
// where H is the homography: a 3 by 3 matrix
// that transformed to inhomogeneous coordinates for each point
// gives the following equations for each point:
//
// x' * (h31*x + h32*y + h33) = h11*x + h12*y + h13
// y' * (h31*x + h32*y + h33) = h21*x + h22*y + h23
//
// as the homography is scale independent we can let h33 be 1 (indeed any of the terms)
// so for 4 points we have 8 equations for 8 terms to solve: h11 - h32
// after ordering the terms it gives the following matrix
// that can be solved with gaussian elimination:

float P[8][9]={
    {-src[0].x,-src[0].y,-1,src[0].x*dst[0].x,src[0].y*dst[0].x,-dst[0].x },// h11
    {  0,-src[0].x,src[0].x*dst[0].y,src[0].y*dst[0].y,-dst[0].y },// h12

    {-src[1].x,-src[1].y,src[1].x*dst[1].x,src[1].y*dst[1].x,-dst[1].x },// h13
    {  0,-src[1].x,src[1].x*dst[1].y,src[1].y*dst[1].y,-dst[1].y },// h21

    {-src[2].x,-src[2].y,src[2].x*dst[2].x,src[2].y*dst[2].x,-dst[2].x },// h22
    {  0,-src[2].x,src[2].x*dst[2].y,src[2].y*dst[2].y,-dst[2].y },// h23

    {-src[3].x,-src[3].y,src[3].x*dst[3].x,src[3].y*dst[3].x,-dst[3].x },// h31
    {  0,-src[3].x,src[3].x*dst[3].y,src[3].y*dst[3].y,-dst[3].y },// h32
};

gaussian_elimination(&P[0][0],9);

matrix(0,0)=P[0][8];
matrix(0,1)=P[1][8];
matrix(0,2)=0;
matrix(0,3)=P[2][8];

matrix(1,0)=P[3][8];
matrix(1,1)=P[4][8];
matrix(1,2)=0;
matrix(1,3)=P[5][8];

matrix(2,0)=0;
matrix(2,1)=0;
matrix(2,2)=0;
matrix(2,3)=0;

matrix(3,0)=P[6][8];
matrix(3,1)=P[7][8];
matrix(3,2)=0;
matrix(3,3)=1;

return matrix;

}

解决方法

您应该看看现有的解决方案:

>用眼睛绘画的眼睛作家(我测试过它只能控制鼠标)

Eyewriter.org

Eyewriter walkthrough

Eyewriter on Github

> EyeLike瞳孔追踪

EyeLike info page(此处讨论类似于想要的算法)

EyeLike on Github

祝好运!

大佬总结

以上是大佬教程为你收集整理的c – 用于眼动追踪的屏幕计算全部内容,希望文章能够帮你解决c – 用于眼动追踪的屏幕计算所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。