gpt4 book ai didi

java - 使用opencv或javacv识别图像中具有相同颜色的轮廓?

转载 作者:行者123 更新时间:2023-12-01 15:12:50 25 4
gpt4 key购买 nike

这个问题与我的previous question有关在那个问题中,我使用彩色图像作为输入,它通过使用线条颜色来识别,但我想知道如何使用灰度图像来识别这种图像。这是灰度输入图像,必须识别

enter image description here

我需要识别以下对象及其位置(x 和 y 坐标)。

enter image description here

请有人用简单的代码示例解释一下以识别这些对象,我还需要识别这些对象的连接线(如下图所示)。

enter image description here

请用简单的代码示例来解释这一点。

最佳答案

解决方案的概念与上一个问题相同 - 使用扩张和侵 eclipse :

Mat src = imread("input.jpg"), tmp;

cvtColor(src, tmp, CV_BGR2GRAY);
threshold(tmp, tmp, 200, 255, THRESH_OTSU);

Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1, 1));
dilate(tmp, tmp, element);
erode(tmp, tmp, element);

结果:

enter image description here

关于java - 使用opencv或javacv识别图像中具有相同颜色的轮廓?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12088176/

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