- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是在 Visual Studio 上使用 OpenCV 的新手,最近我重新安装了我的 VS2012 以使其使用 OpenCV 2.4.2 工作。
我正在尝试通过鼠标单击顶点并将它们推送到 CvSeq* 来计算指定区域的面积,以与 contourArea() 函数一起使用。
我目前正在尝试在一个空的 CvSeq* 中解析为我的自定义鼠标回调函数的最后一个参数,以便我可以添加由 x 和 y 坐标组成的 CvPoint。但是,每当我之后尝试访问 CvSeq* 轮廓时,我都会收到错误消息。所以在下面的代码片段中:
void CallBackFunc(int event, int x, int y, int flags, void* userdata)
{
CvSeq* contour = (CvSeq*)userdata;
CvPoint cur;
if ( event == EVENT_LBUTTONDOWN )
{
cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ") saved as point" << endl;
// save x,y as a contour point
cur = cvPoint(x,y);
cvSeqPush(contour, &cur);
...
我收到了正确的 cout 消息,但在尝试使用 CvSeq* 绘制轮廓时收到这样的错误:opencvtest.exe 中 0x75E3812F 处的未处理异常:Microsoft C++ 异常:内存位置 0x001FF990 处的 cv::Exception。
这里有什么问题?尝试使用 Vector> 而不是 CvSeq 会更好吗?
最佳答案
cvDrawContours() 来自旧的、已弃用的 c-api,您应该不使用它,或任何那些旧的 cv* 函数。
drawContours 来自当前的 c++ api,与 cv::Mat 一起使用,来自 cv::命名空间的函数。
另外,不要再担心 CvSeq* 或 IplImage*。如果您看到任何包含此类神秘内容的代码,请继续。
“我尝试使用 vector<vector<Point>>
而不是 CvSeq 会更好吗?” - 是的。
关于c++ - OpenCV cvDrawContours 与 drawContours,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25327724/
我有以下代码在 OpenCV 3.4.1 上运行良好,但现在不能在 OpenCV 4.1.0 上运行并给出错误。我不知道如何使代码适应新版本,你能帮我吗?非常感谢 def ImageProcessin
我从二值图像中过滤小 Blob (面积小于阈值的轮廓)。掩码是二值图像。 如果我注释行 drawContours(mask, contours, -1, Scalar(255), CV_FILLED
我正在尝试确定动脉的宽度,并制定了一个非常粗略的程序来验证 drawContours 是否合适。我的问题是轮廓仅打印黑色或白色线条,而不是我尝试使用的彩色线条。我不确定我正在绘制的 img 是否仅限于
在我的 Android 应用程序中,我从图库中获取了一张位图图像,内容如下 Bitmap bitm = getMyImage("Thanks!"); 我有一个名为 mat 的 Mat,声明如下: Ma
我想用 OpenCV drawContours 函数绘制自定义点序列。 我的代码: std::vector > contours; std::vector contour1; contour1.pus
我正在研究在 opencv python 中查找和绘制轮廓的示例。但是当我运行代码时,我只看到一个没有绘制轮廓的黑色窗口。我不知道我哪里错了。代码是: import numpy as np impor
我正在尝试使用 OpenCV 中的 cv2.drawContours 函数显示填充轮廓。我已经根据 Canny 检测得出的边缘图像开发了一个轮廓列表,并且正在为层次结构定义启用 RETR_EXTERN
我有一个要绘制的轮廓列表。其中一些轮廓自相交。 当我想用 OpenCV 绘制它们时,我只需使用 cv::drawContours 函数。 但是,这种行为很奇怪。 这里引用官方documentation
我遵循了 this page 上的教程但是当行 cv2.drawContours(im,contours,-1,(0,255,0),3) 被执行时,似乎什么也没有发生。我期待看到带有绿色轮廓的 sta
我正在尝试在 Xamarin 上开发移动应用程序。首先,我正在为 Android 设备做这件事。我希望 Oncamera 功能能够自动检测轮廓并测量物体的大小。作为主要步骤,我正在尝试实时检测轮廓。阅
需要堆栈溢出的强大帮助。实际上,我开发的应用程序必须通过 OCR(我正在使用 tesseract)文档进行分析,并提取我可以从中提取的所有文本。这是图像类型的示例: Image including t
我正在尝试从图像中绘制轮廓。我从我的网络摄像头得到了一个框架并提取了它的轮廓。然后,我按区域过滤它们,并调用 drawContours() 来显示它们。问题是当我尝试绘制过滤后的轮廓时...如果我绘制
我是在 Visual Studio 上使用 OpenCV 的新手,最近我重新安装了我的 VS2012 以使其使用 OpenCV 2.4.2 工作。 我正在尝试通过鼠标单击顶点并将它们推送到 CvSeq
我有一个 python 代码,我正在将它移植到 c++。我在 OpenCV c++ 中遇到了 drawContours 函数的奇怪问题。 self.contours[i] = cv2.convexHu
这个问题在这里已经有了答案: Contour shows dots rather than a curve when retrieving it from the list, but shows t
我有以下图像,其中包含无人机捕获的汽车和空 parking 位。我想检测空的公园空间并绘制一个看起来像预期图像的框。 这是我的代码: import cv2 import numpy as np fro
我有一个包含 4 个点的 vector : vector > data(4); data[0].push_back(Point(0,0)); data[1].push_back(Point(0,120
我试图找到最大的正方形并将其绘制在原始图像上。 当我打电话 drawContours(input,(screenCnt),-1,Scalar(255,0,0),3); 出现以下错误: E/cv::er
我正在尝试绘制最大物体的轮廓。 首先,我将展示一张绘制所有轮廓的图像: 为了找到最大的对象,我使用了这段代码: maxsize = 0 best = 0 count = 0 for cnt in
按照@Silencer 的建议,我使用了他发布的代码 here围绕我图像中的数字绘制轮廓。在某些时候,处理像 0,6,8,9 这样的数字时,我看到它们的内部轮廓(圆圈)也被填充了。我怎样才能防止这种情
我是一名优秀的程序员,十分优秀!