박민혀기
CELLON II(Simple Blob Detector) 본문
SimpleBlobDetector의 옵션 종류
실행 소스코드
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main() {
Mat img = imread("C:\\Users\\xlfks\\Desktop\\CELLON II\\img\\Galaxy S23 R90.jpg", IMREAD_COLOR);
//Galaxy S23, Galaxy S23 vertical, Galaxy S23 L90, Galaxy S23 R90, Galaxy S23 horizontal, Galaxy S23 180
if (img.empty()) {
cout << "Could't file open or load" << endl;
return 0;
}
//resize(img, img, Size(img.cols / 2, img.rows / 2));
Mat gray_img;
cvtColor(img, gray_img, COLOR_BGR2GRAY);
// Setup SimpleBlobDetector parameters.
SimpleBlobDetector::Params params;
//// Change thresholds
//params.minThreshold = 10;
//params.maxThreshold = 200;
//// Filter by Area.
params.filterByArea = true;
params.minArea = 1300;
//// Filter by Circularity
//params.filterByCircularity = true;
//params.minCircularity = 0.1;
//// Filter by Convexity
//params.filterByConvexity = true;
//params.minConvexity = 0.87;
//// Filter by Inertia
//params.filterByInertia = true;
//params.minInertiaRatio = 0.01;
vector<KeyPoint> keypoints;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
detector->detect(gray_img, keypoints);
Mat keypoints_img;
drawKeypoints(img, keypoints, img, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
circle(img, keypoints[0].pt, 3, Scalar(0, 255, 0), -1);
circle(img, keypoints[1].pt, 3, Scalar(255, 255, 0), -1);
circle(img, keypoints[2].pt, 3, Scalar(0, 255, 255), -1);
cout << "keypoints Size : " << keypoints.size() << endl;
for (int i = 0; i < keypoints.size(); i++) {
cout << "keypoints[" << i << "] Angle : " << keypoints[i].angle << endl;
}
//imshow("keypoints_img", keypoints_img);
imshow("img", img);
waitKey(0);
return 0;
}
참조 :
https://dsbook.tistory.com/137
[OpenCV Programming] 코너점 검출
이전 글에서 살펴본 매칭은 영상 전체를 바탕으로 비교하는 방법이기 때문에 비교할 영상이 비슷할 때만 좋은 결과가 나타난다. 즉, 물체의 변환이 있거나 회전이 있으면 좋은 결과를 얻을 수
dsbook.tistory.com
https://stackoverflow.com/questions/8076889/how-to-use-opencv-simpleblobdetector
How to use OpenCV SimpleBlobDetector
Instead of any additional blob detection library, how do I use the cv::SimpleBlobDetector class and its function detectblobs()?
stackoverflow.com
https://learnopencv.com/blob-detection-using-opencv-python-c/
Blob Detection Using OpenCV ( Python, C++ ) |
This beginner tutorial explains simple blob detection using OpenCV. C++ and Python code is available for study and practice.
learnopencv.com
'CELLON II > Ref' 카테고리의 다른 글
CELLON II(Video Reference) (0) | 2023.01.21 |
---|---|
CELLON II(Feature matching) (0) | 2023.01.13 |
CELLON II(FindContours, minRect) (0) | 2023.01.13 |