Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "opencv2/imgproc/imgproc.hpp"
- #include "opencv2/highgui/highgui.hpp"
- #include <stdlib.h>
- #include <stdio.h>
- #include <opencv2/imgproc/imgproc.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/opencv.hpp>
- #include <opencv2/videoio.hpp>
- #include <opencv2/video.hpp>
- using namespace cv;
- // Read image
- int main() {
- Mat im = imread("/home/paul/Downloads/dust/DustRemoval/processedImage-00025.png", IMREAD_GRAYSCALE );
- SimpleBlobDetector::Params params;
- params.minThreshold = 10;
- params.maxThreshold = 150;
- params.thresholdStep = 10;
- params.filterByInertia = false;
- params.filterByConvexity = false;
- params.filterByColor = false;
- params.filterByCircularity = false;
- params.minArea = 0;
- params.maxArea = 30;
- params.filterByArea = true;
- // Set up the detector with default parameters.
- auto detector = cv::SimpleBlobDetector::create(params);
- // Detect blobs.
- std::vector<KeyPoint> keypoints;
- detector->detect(im, keypoints);
- std::cout << keypoints.size() << std::endl;
- // Draw detected blobs as red circles.
- // DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
- Mat im_with_keypoints;
- drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
- // Show blobs
- imshow("keypoints", im_with_keypoints );
- waitKey(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement