2013-02-28 100 views
0

我有一個代碼,它可以檢測臉部,雙眼和每隻眼睛的瞳孔。現在我想通過使用白色檢測來檢測每隻眼睛的角落。因爲我是opencv的新手,請指導我如何做到這一點,併爲我提供一個android示例代碼?這是我有的代碼的一部分:Android OpenCV通過顏色檢測眼動追蹤

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());  
         }  

回答