C++ 使用simpleBlobDetector进行对象检测,但它不';行不通
我对simpleBlobDetector的代码有问题。我可以很好地构建和运行所有代码,但是程序检测到的斑点只有一个像素左右的大小。我已经尝试更改param.minArea和maxArea,但没有效果。所以我请求你们的帮助。顺便说一句,我使用的图像已经是灰度的,所以它不是因为我的阈值命令,它不工作。谢谢 马丁C++ 使用simpleBlobDetector进行对象检测,但它不';行不通,c++,opencv,computer-vision,C++,Opencv,Computer Vision,我对simpleBlobDetector的代码有问题。我可以很好地构建和运行所有代码,但是程序检测到的斑点只有一个像素左右的大小。我已经尝试更改param.minArea和maxArea,但没有效果。所以我请求你们的帮助。顺便说一句,我使用的图像已经是灰度的,所以它不是因为我的阈值命令,它不工作。谢谢 马丁 #include <opencv/cv.h> #include <opencv/highgui.h> #include <opencv2/opencv.hpp&
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(){
Mat src;
Mat dst;
src = imread("C:\\Users\\martin\\Desktop\\ThermalImage2.png", CV_LOAD_IMAGE_GRAYSCALE); //Load an image from directory path
if (! src.data){
cout << "Could not open or find the image" << endl ; // Look for invalid input
return -1;
}
else{
double thresh = 130; // Threshold
double maxValue = 255; // Value assigned to the pixel if it is over 'thresh'
threshold(src, dst, thresh, maxValue, THRESH_BINARY); // threshold the picture src and call it dst
namedWindow("thresholdedPicture", WINDOW_AUTOSIZE); // Create a window
imshow("thresholdedPicture", dst); // display thresholded picture in the window
}
SimpleBlobDetector::Params params; // Set parameters for the object detection
params.minDistBetweenBlobs = 10; //Minimum distance between blobs
params.filterByColor = true;
params.blobColor = 255;
params.filterByArea = true; // filter by area of the blob
params.minArea = 1 ;// Minimum area of the blob
params.maxArea = 100000; // Maximum area of the blob
vector<KeyPoint> keypoints;
cv::SimpleBlobDetector detector(params); // Set up the blob detector with the parameters (params)
detector.detect(dst, keypoints); // Input thresholded picture for detection of the blobs
Mat dst_blob_dect; // New array to store the picture with the blobs detected
drawKeypoints( dst, keypoints, dst_blob_dect, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS ); //Drawing a red line around the detected objects
namedWindow("keypoints", WINDOW_AUTOSIZE); // Create a window
imshow("keypoints", dst_blob_dect); // Show the picture with the blobs detected in the window "keypoints"
waitKey(0); // Press any key and the main function returns 0
return 0;}
#包括
#包括
#包括
使用名称空间std;
使用名称空间cv;
int main(){
Mat-src;
Mat-dst;
src=imread(“C:\\Users\\martin\\Desktop\\ThermalImage2.png”,CV\u LOAD\u IMAGE\u GRAYSCALE);//从目录路径加载图像
如果(!src.data){
cout尝试此操作,并为params.mindistweenblobs
使用不同的值
#include "stdafx.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>
#include <stdio.h>
using namespace std;
using namespace cv;
int main(){
Mat src;
Mat dst;
src = imread("C:\\Users\\sanche8x\\Pictures\\gather.png", CV_LOAD_IMAGE_GRAYSCALE); //Load an image from directory path
if (! src.data){
cout << "Could not open or find the image" << endl ; // Look for invalid input
return -1;
}
else{
double thresh = 130; // Threshold
double maxValue = 255; // Value assigned to the pixel if it is over 'thresh'
threshold(src, dst, thresh, maxValue, THRESH_BINARY); // threshold the picture src and call it dst
namedWindow("thresholdedPicture", WINDOW_AUTOSIZE); // Create a window
imshow("thresholdedPicture", dst); // display thresholded picture in the window
}
SimpleBlobDetector::Params params; // Set parameters for the object detection
params.minDistBetweenBlobs = 10; //Minimum distance between blobs
params.filterByColor = true;
params.blobColor = 255;
params.filterByCircularity = false;
params.filterByConvexity = false;
params.filterByInertia = false;
params.filterByArea = true; // filter by area of the blob
params.minArea = 1 ;// Minimum area of the blob
params.maxArea = 100000; // Maximum area of the blob
vector<KeyPoint> keypoints;
cv::SimpleBlobDetector detector(params); // Set up the blob detector with the parameters (params)
detector.detect(dst, keypoints); // Input thresholded picture for detection of the blobs
Mat dst_blob_dect; // New array to store the picture with the blobs detected
drawKeypoints( dst, keypoints, dst_blob_dect, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS ); //Drawing a red line around the detected objects
namedWindow("keypoints", WINDOW_AUTOSIZE); // Create a window
imshow("keypoints", dst_blob_dect); // Show the picture with the blobs detected in the window "keypoints"
waitKey(0); // Press any key and the main function returns 0
return 0;
#包括“stdafx.h”
#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间cv;
int main(){
Mat-src;
Mat-dst;
src=imread(“C:\\Users\\sanche8x\\Pictures\\gather.png”,CV\u LOAD\u IMAGE\u GRAYSCALE);//从目录路径加载图像
如果(!src.data){
你能把图片贴出来吗?