C++ Simpleblobdetector找到了许多关键点
当使用OpenCV时,我想找到一个指向地面的激光指向器,上面有实时图像。现在,出于测试目的,我正在使用静态图像来测试OpenCV算法。当时我在多个测试图像中成功地找到了激光。这是我的问题。当试图找到x和y坐标时,我得到了一些非常奇怪的结果。simpleblobdetector可以找到大约18*e^个关键点。奇怪,因为图像的分辨率只有640X480像素。下面是我的代码和一些输出。有人知道我为什么会得到这么多关键点,以及如何修复它,以便提取坐标吗C++ Simpleblobdetector找到了许多关键点,c++,visual-studio,opencv,blob,detection,C++,Visual Studio,Opencv,Blob,Detection,当使用OpenCV时,我想找到一个指向地面的激光指向器,上面有实时图像。现在,出于测试目的,我正在使用静态图像来测试OpenCV算法。当时我在多个测试图像中成功地找到了激光。这是我的问题。当试图找到x和y坐标时,我得到了一些非常奇怪的结果。simpleblobdetector可以找到大约18*e^个关键点。奇怪,因为图像的分辨率只有640X480像素。下面是我的代码和一些输出。有人知道我为什么会得到这么多关键点,以及如何修复它,以便提取坐标吗 // Read image Mat im = imr
// Read image
Mat im = imread(argv[1], IMREAD_COLOR);
cout << im.cols << " " << im.rows << endl;
Mat filtered;
inRange(im, Scalar(0, 0, 0), Scalar(255, 255, 216), filtered);
imshow("Filtered image", filtered);
// Simpleblobdetector parameters.
SimpleBlobDetector::Params params;
params.filterByArea = true;
params.filterByCircularity = false;
params.filterByColor = false;
params.filterByConvexity = false;
params.filterByInertia = false;
params.minArea = 50;
params.maxArea = 100;
// Set up the detector with default parameters.
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// Detect blobs.
std::vector<KeyPoint> keypoints;
detector->detect(filtered, keypoints);
cout << "There are " << keypoints.size() << " BLOBs found." << 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);
// De locatie van de keypoints weergeven in de console.
for (int i = 0; i < keypoints.size(); i++)
{
cout << "The X-cooridnate is: " << keypoints.at(i).pt.x << endl;
cout << "The Y-coordinate is: " << keypoints.at(i).pt.y << endl;
}
// Show blobs
imshow("keypoints", im_with_keypoints);
waitKey(0);
return 0;
//读取图像
Mat im=imread(argv[1],imread\u颜色);
难道我也有类似的问题吗。我的问题是,我将错误的库链接到调试构建,因此向量中充满了垃圾:确保您链接到了正确的库(调试库到调试构建),我遇到了类似的问题。我的问题是,我将错误的库链接到调试构建,因此向量中充满了垃圾:确保链接到了正确的库(调试库到调试构建)