【发布时间】:2017-03-22 07:55:44
【问题描述】:
我对 opencv 和 C++ 比较陌生,我希望对我的代码有所帮助。对于我的项目,我目前正在开发一个简单的 blob 检测器,但是当我运行它时,我得到 "OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file C:\ builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\array.cpp,第 2494 行 按任意键继续 。 . ."。我很确定错误来自 Mat im_with_keypoints;,或者链接器中的问题。下面是我的代码。如果你能帮助我,那就太好了。
- 更新:我通过调试器运行了这个程序并出现了这个错误
- 我也在使用 Visual Studio 2015
这是我试图检测斑点的图像:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat im = imread("Eagle_coins.jpg", IMREAD_GRAYSCALE);
SimpleBlobDetector::Params params;
params.minThreshold = 10;
params.maxThreshold = 200;
params.filterByColor = true;
params.filterByCircularity = true;
params.minCircularity = 0.1;
params.maxCircularity = 0.28;
params.filterByConvexity = true;
params.minConvexity = 0.87;
params.maxConvexity = 2.8;
params.filterByInertia = true;
params.minInertiaRatio = 0.01;
params.maxInertiaRatio = 2;
vector<KeyPoint> keypoints;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
detector->detect(im, keypoints);
Mat im_with_keypoints;
drawKeypoints(im, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imshow("white", im_with_keypoints);
waitKey(0);
}
【问题讨论】:
-
您是否尝试在调试器中运行它?那告诉了你什么?无需猜测。
-
@Dan Mašek 我通过调试器运行程序并出现运行时错误
-
您应该能够在错误发生时中断调试器,并检查堆栈跟踪以查看代码中发生这种情况的确切位置。然后,您可以使用调试器进一步检查您调用失败的参数,以便更深入地了解问题。 |如果您附加输入图像的副本以允许其他人复制它,这将很有用。 |您可以提及的另一件事是您在哪种模式下编译程序(调试或发布?)以及您将其链接到哪些库(名称)。
-
@Dan Mašek 抱歉,回复晚了,我按照您的建议在整个代码中放置断点,但是,无论我在哪里放置断点,程序都不会运行(我从结束并努力乞讨)。我的代码处于调试模式。我链接的库是 vc12,以及用于附加依赖项的 opencv_world300d.lib。
-
没问题。我是否正确假设您使用的是 Visual Studio 2013?请编辑您的问题并添加您用于测试的图片,以便我们尝试重现问题。
标签: c++ opencv visual-c++