Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. int main()
  2. {
  3. VideoCapture cap(0);
  4.  
  5. Mat A, B;
  6.  
  7. int x;
  8.  
  9. for (x = 0; x < 5; x++)
  10. {
  11. cap >> A;
  12.  
  13. cvtColor(A, B, CV_BGR2GRAY);
  14. GaussianBlur(B, B, Size(9, 9), 2, 2);
  15.  
  16. vector<Vec3f> circles;
  17.  
  18. HoughCircles(B, circles, CV_HOUGH_GRADIENT, 1, B.rows / 8, 80, 80, 0, 0);
  19.  
  20. size_t i;
  21.  
  22. for (i = 0; i < circles.size(); i++)
  23. {
  24. Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
  25. int radius = cvRound(circles[i][2]);
  26. // circle center
  27. circle(A, center, 3, Scalar(0, 255, 0), -1, 8, 0);
  28. // circle outline
  29. circle(A, center, radius, Scalar(0, 0, 255), 3, 8, 0);
  30. }
  31.  
  32. cout << "The amount of dots detected is: " << i << "." << endl;
  33.  
  34. waitKey(100);
  35. }
  36.  
  37. namedWindow("Haha");
  38. imshow("Haha", A);
  39.  
  40. waitKey(10);
  41.  
  42. getchar();
  43. //VideoCapture cap = VideoCapture(dev_id + CV_CAP_V4L2);
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement