Android OpenCV通过颜色检测进行眼动追踪

时间:2013-02-28 09:19:20

标签: android opencv eye-tracking

我有一个代码可以检测每只眼睛的脸部,双眼和瞳孔。现在我想通过使用白色检测来检测每只眼睛的角落。因为我是opencv的新手,请你指导一下,我应该怎么做并向我提供一个android示例代码?这是我所拥有的代码的一部分:

for (int i = 0; i < facesArray.length; i++){     
                Rect r = facesArray[i];     
                    Core.rectangle(mGray, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);       
                    Core.rectangle(mRgba, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);       

                    eyearea = new Rect(r.x +r.width/8,(int)(r.y + (r.height/4.5)),r.width - 2*r.width/8,(int)( r.height/3.0));         
                    Core.rectangle(mRgba,eyearea.tl(),eyearea.br() , new Scalar(255,0, 0, 255), 2);       
                    Rect eyearea_right = new Rect(r.x +r.width/16,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));       
                    Rect eyearea_left = new Rect(r.x +r.width/16 +(r.width - 2*r.width/16)/2,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));            
                    Core.rectangle(mGray,eyearea_left.tl(),eyearea_left.br() , new Scalar(255,0, 0, 255), 2);             
                    Core.rectangle(mRgba,eyearea_right.tl(),eyearea_right.br() , new Scalar(255, 0, 0, 255), 2);       
                    if(learn_frames<5){       
                     //This part detect the pupil of the eyes      
                     teplateR = get_template(mCascadeER,eyearea_right,20);     
                     teplateL = get_template(mCascadeEL,eyearea_left,20);      
                     learn_frames++;      
                   }else{      
                    match_value = match_eye(eyearea_right,teplateR,FdActivity.method);      
                    match_value = match_eye(eyearea_left,teplateL,FdActivity.method);      
                     ;    
                     }     
                       Imgproc.resize(mRgba.submat(eyearea_left), mZoomWindow2, mZoomWindow2.size());        
                        Imgproc.resize(mRgba.submat(eyearea_right), mZoomWindow, mZoomWindow.size());      
                        }      

1 个答案:

答案 0 :(得分:0)

你需要像Flandmark这样的东西来探测角落。 请参阅:http://cmp.felk.cvut.cz/~uricamic/flandmark/