在C#中,我试图在图像中找到角落。该图像是使用相机拍摄的,因此并非每次拍摄都完全相同。
用相机拍摄的图像如下:
我已经成功获得了Dark / Light部分的顶部边缘。在这条线上,我想找到角落。
这是我从图像中获得的数据数组。数组中值为0的项目是图像中未找到暗/亮边缘的列:
int[] items = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 338, 336, 335, 335, 335, 334, 334, 334, 334, 334, 334, 334, 334, 333, 333, 333, 333, 332, 332, 332, 332, 332, 332, 332, 332, 331, 331, 331, 331, 331, 331, 331, 331, 330, 330, 329, 329, 329, 328, 328, 327, 327, 326, 326, 326, 325, 325, 325, 325, 325, 324, 324, 324, 324, 324, 324, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 318, 318, 318, 318, 318, 318, 318, 318, 318, 317, 317, 317, 317, 317, 317, 317, 317, 316, 316, 316, 316, 316, 316, 315, 315, 315, 315, 315, 315, 314, 314, 314, 314, 314, 313, 313, 313, 313, 313, 313, 312, 312, 312, 312, 312, 311, 311, 311, 311, 311, 310, 310, 310, 310, 309, 309, 309, 309, 308, 308, 308, 308, 307, 307, 307, 307, 307, 306, 306, 306, 305, 305, 305, 305, 304, 304, 304, 304, 304, 303, 303, 303, 303, 302, 302, 302, 302, 301, 301, 301, 301, 300, 300, 300, 300, 299, 299, 299, 299, 299, 298, 298, 298, 298, 297, 297, 297, 297, 297, 296, 296, 296, 296, 296, 295, 295, 295, 295, 295, 294, 294, 294, 294, 293, 293, 293, 293, 293, 293, 292, 292, 292, 292, 292, 292, 291, 291, 291, 291, 291, 291, 291, 291, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 290, 290, 290, 290, 290, 291, 291, 291, 292, 292, 293, 294, 294, 295, 295, 296, 297, 298, 299, 300, 300, 301, 302, 303, 304, 305, 306, 307, 308, 310, 311, 313, 315, 317, 320, 323, 327, 337, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
现在,我正在寻找一种找到拐角点的不错的方法,我已经尝试了多种方法,但是使用同一物体的相机拍摄的不同图像在结果上的差异相差很大。因此,我正在寻找一种更好地实现此目的的方法(可能有一种我不知道的算法)。
如何从我拥有的数组中计算/找到那两条红线?
答案 0 :(得分:1)
应用阈值处理使图像成为二进制,提取边界像素,然后使用霍夫变换获得直线并选择投票最多的直线。
明智的做法是使用一些成像库,例如OpenCV或其他适合c#的库。