aihot  2017-04-27 20:49:14  OpenCV |   查看评论   
  •             if (area > maxArea)  
  •             {  
  •                 maxArea = area;  
  •                 index = i;  
  •             }             
  •         }  
  •   
  •         //drawContours(frame, contours, index, Scalar(0, 0, 255), 2, 8, hierarchy );  
  •           
  •         Moments moment = moments(skinArea, true);  
  •         Point center(moment.m10/moment.m00, moment.m01/moment.m00);  
  •         circle(show_img, center, 8 ,Scalar(0, 0, 255), CV_FILLED);  
  •   
  •         // 寻找指尖  
  •         vector<Point> couPoint = contours[index];  
  •         int max(0), count(0), notice(0);  
  •         vector<Point> fingerTips;  
  •         Point p, q, r;  
  •         for (int i = 5; (i < (couPoint.size() - 5)) && couPoint.size(); i++)  
  •         {  
  •             q = couPoint[i - 5];  
  •             p = couPoint[i];  
  •             r = couPoint[i + 5];  
  •             int dot = (q.x - p.x ) * (r.x - p.x) + (q.y - p.y ) * (r.y - p.y);  
  •             if (dot < 20 && dot > -20)  
  •             {  
  •                 int cross = (q.x - p.x ) * (r.y - p.y) - (r.x - p.x ) * (q.y - p.y);  
  •                 if (cross > 0)  
  •                 {  
  •                     fingerTips.push_back(p);  
  •                     circle(show_img, p, 5 ,Scalar(255, 0, 0), CV_FILLED);  
  •                     line(show_img, center, p, Scalar(255, 0, 0), 2);      
  •                 }  
  •             }  
  •         }  
  •   
  •         imshow("show_img", show_img);  
  •   
  •         if ( cvWaitKey(20) == 'q' )  
  •             break;  
  •     }  
  •   
  •     return 0;  
  • }  
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自简单粗糙的指尖检测方法(FingerTips Detection)

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]