Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include "opencv2/imgproc/imgproc.hpp"
  2. #include "opencv2/highgui/highgui.hpp"
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. #include <opencv2/imgproc/imgproc.hpp>
  7. #include <opencv2/highgui/highgui.hpp>
  8. #include <opencv2/opencv.hpp>
  9. #include <opencv2/videoio.hpp>
  10. #include <opencv2/video.hpp>
  11.  
  12. using namespace cv;
  13. // Read image
  14. int main() {
  15. Mat im = imread("/home/paul/Downloads/dust/DustRemoval/processedImage-00025.png", IMREAD_GRAYSCALE );
  16.  
  17.  
  18. SimpleBlobDetector::Params params;
  19.  
  20. params.minThreshold = 10;
  21. params.maxThreshold = 150;
  22. params.thresholdStep = 10;
  23. params.filterByInertia = false;
  24. params.filterByConvexity = false;
  25. params.filterByColor = false;
  26. params.filterByCircularity = false;
  27.  
  28.  
  29. params.minArea = 0;
  30. params.maxArea = 30;
  31. params.filterByArea = true;
  32.  
  33.  
  34. // Set up the detector with default parameters.
  35. auto detector = cv::SimpleBlobDetector::create(params);
  36.  
  37. // Detect blobs.
  38. std::vector<KeyPoint> keypoints;
  39. detector->detect(im, keypoints);
  40.  
  41. std::cout << keypoints.size() << std::endl;
  42.  
  43. // Draw detected blobs as red circles.
  44. // DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
  45. Mat im_with_keypoints;
  46. drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
  47.  
  48. // Show blobs
  49. imshow("keypoints", im_with_keypoints );
  50. waitKey(0);
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement