圆hough中心坐标
circle hough center co-ordinates
在opencv
中,我使用Hough变换来查找圆,这里是代码
HoughCircles (diff, circles, CV_HOUGH_GRADIENT, 2, src.cols / 5, 200, 80, 20, 62);
for (size_t i = 0; i < circles.size(); i++ )
{
//if(circles[i][2]<62)
{
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
int radius = cvRound(circles[i][2]);
// draw the green circle center
circle( src, center, 3, Scalar(0,255,255), -1, 8, 0 );
// draw the blue circle outline
circle(src, center, radius, Scalar(0,255,0), 3, 8, 0 );
}
}
我面临的问题是,有时在它找到3个圆的情况下,第三个圆心坐标是分数,而不是整数。如果它找到4个圆,它会给出这个错误
xyz.exe中0x75ebc41f处未处理的异常:Microsoft C++异常:cv::内存位置0x002df08c出现异常。。
如果我尝试cout
中心坐标。
嗯,这很有趣。我运行了你的代码,并在之前和之后填写了,没有任何问题。老实说,我只在linux和mac机器上测试过。这是我的全长代码,试试看会发生什么。此外,请在此处查看此解决方案。
int main(int argc, char* argv[]) {
VideoCapture capture(0);
if (!capture.isOpened()) {
LOG(FATAL) << "COULD NOT OPEN CAPTURE";
}
Mat frame;
capture >> frame;
if (frame.empty()) {
LOG(FATAL) << "FRAME IS EMPTY!";
}
char key;
while ((int)key != 27) {
capture >> frame;
Mat gray;
cvtColor(frame, gray, CV_BGR2GRAY);
GaussianBlur(gray, gray, Size(9, 9), 2, 2);
vector<Vec3f> circles;
HoughCircles(gray, circles, CV_HOUGH_GRADIENT, 2, gray.cols/5,200,80,20,62);
for (size_t i = 0; i < circles.size(); ++i) {
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
int radius = cvRound(circles[i][2]);
// draw the green circle center
circle(frame, center, 3, Scalar(0,255,255), -1, 8, 0 );
// draw the blue circle outline
circle(frame, center, radius, Scalar(0,255,0), 3, 8, 0 );
}
imshow("frame", frame);
key = waitKey(1);
}
return 0;
}
相关文章:
- QGraphicsPolygonItem在拖动时未更新QPolygonF坐标
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- OpenGL 4.3 错误地将第 4 个纹理坐标映射到与第 3 个纹理坐标相同的位置
- 比较两个节点坐标的最佳方法是什么?
- 在 OpenGL 中将笛卡尔世界坐标转换为球面局部坐标
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 如何在C++中获取坐标?
- 如何将 x.y 坐标的值存储在不同的数组中
- 如何将鼠标坐标转换为"mm"
- 重心坐标并不总是有效(3d)
- 尝试渲染像素坐标时,简单线条渲染失败
- 使用 GTK3 C++获取指针坐标
- 从 CGAL 3D 网格生成中获取顶点坐标的 -6.27744e+66:mesh_implicit_sphere示例
- 我想制作设置鼠标回调函数,以便在仍然按下鼠标左键时连续传递坐标
- 将鼠标悬停在图片框上时,如何显示带有 x-y 坐标的十字准线光标?
- 跳转到通过输入坐标定义的控制台屏幕位置
- QImage::p ixel 和 QImage::setPixel 坐标超出范围误差
- 如何从 3d 对象文件中获取 3d 坐标
- 圆hough中心坐标