用 Android 手机拍照后,我想通过点击来识别图片中的对象,例如。大多数情况下可能的对象:
1.尺子
2.人
3. 铅笔
我使用的是 android prebuilt-opencv 2.3.1 版,我尝试点击标尺对象并对其进行填充以标记它,但如果轮廓未闭合,整个图片将被填充。
a) 我还尝试单击标尺对象并向南、北、东、西移动以查看边缘位置并收集这些坐标,但我在那里遇到了严重的问题(不要问)。
问题:
1. 是否可以通过某种方式关闭轮廓以填充想要的对象?
2. 我实际上想要找到的是底部的坐标和(例如)标尺的高度。
任何其他解决方案表示赞赏。你将如何实现它?
更新:我用 a) 解决了这个问题,现在使用这种方法(对此并不满意)。我也试过 Entreco 的方法,但现在似乎没有给出想要的解决方案。
最佳答案
不知道你有没有试过,但通常情况下,先处理图像可以获得更好的效果。
1) 申请GuassianBlur消除噪音
2) 申请AdaptiveThreshold -> 将图像转换为黑白图像
3) 申请Dilate操作,填补裂缝
通过对 AdaptiveThreshold 和 Dilate 操作使用不同的设置,您可能能够获得闭合轮廓...
我用的一个例子是这样的:
// 1) Apply gaussian blur to remove noise
Imgproc.GaussianBlur(mGraySubmat, mIntermediateMat, new Size(11,11), 0);
// 2) AdaptiveThreshold -> classify as either black or white
Imgproc.adaptiveThreshold(mIntermediateMat, mIntermediateMat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 5, 2);
// 3) Invert the image -> so most of the image is black
Core.bitwise_not(mIntermediateMat, mIntermediateMat);
// 4) Dilate -> fill the image using the MORPH_DILATE
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_DILATE, new Size(3,3), new Point(1,1));
Imgproc.dilate(mIntermediateMat, mIntermediateMat, kernel);
关于android - 物体检测android opencv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7786622/