gpt4 book ai didi

c# - C# 中的 Hough Circle,动态内存

转载 作者:太空宇宙 更新时间:2023-11-03 16:49:40 24 4
gpt4 key购买 nike

我在从矩阵获取数据的动态内存分配中遇到问题

Image image_gray = new Image("im1.jpg");
Matrix circles = new Matrix(100, 1, 3);

问题一:不知道圈数如何定位动态内存?

Emgu.CV.CvInvoke.cvHoughCircles(image_gray, circles, HOUGH_TYPE.CV_HOUGH_GRADIENT,
2, 100, 200, 100, 10, 500);

问题2:现在圆是[100 ,3]的矩阵,如何得到

point center= Round (circle[i][1], circle[i][1])

如何获取

int radius= circle[i][2]; 

为了从矩阵获取数据,我的 for 循环应该是什么样子,转换应该是 point 和 int。

我已经试过了(不工作/错误)

for (int i=0; i < circles.Rows; i++) 
{ Matrix entry = circles.GetRow(i);

float x = entry[0];
float y = entry[1];
float r = entry[2];} // NOT WORKING

因为它不是只复制(必需的)(i)行,而是复制整个矩阵(圆圈)和 float x=......给出错误

No overload for method 'this' takes '1' arguments

请在这方面帮助我

问候


很抱歉回答我的问题。请给一些动态内存分配和矩阵数据的提示

最佳答案

文档表明它会增加矩阵以适应,但它也与此相矛盾,所以老实说,我会在具有更多圆圈的图像上尝试 1 行 1 列矩阵,看看它能给你什么。我看到您正在使用 Matrix 类型——我不知道您如何转换为 cvHoughCircles 所需的 IntPtr,但应该直接迭代每一行并提取结果,即 3 个 float :(x, y, r) -

for (int i=0; i < circles.Cols; i++) {
Matrix<float> entry = circles.GetRow(i);
float x = entry[0]; // guessing here - the doc'n is truly awful
float y = entry[1];
float r = entry[2];
}

关于c# - C# 中的 Hough Circle,动态内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4490346/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com