目标检测机器人的OpenCV [英] object detection android opencv

查看:207
本文介绍了目标检测机器人的OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拍摄照片后用Android手机我想通过点击进去,例如识别画面中的对象。在大多数情况下,可能的对象:
1.标尺
2.人
3.铅笔
我使用的Andr​​oid prebuilt-OpenCV的版本2.3.1,我试图点击进入标尺对象,此时,floodFill它来标记它,但如果轮廓没有关闭整个画面将被填充。
一)我也试着点击进入标尺对象,去南,北,东,西看看那里的边缘,并收集这些坐标,但是我遇到了沉重的问题有(不要问)。

After taking a picture with an android phone I want to identify an object in the picture by clicking into it for example. Possible objects in most cases:
1. Ruler
2. Person
3. Pencil
I am using android prebuilt-opencv version 2.3.1 and I tried to click into the ruler object and floodfill it to mark it, but if the contours are not closed the whole picture will be filled.
a) I also tried to click into ruler object and go south, north, east, west to look where the edges are and collect these coordinates, but I ran into heavy problems there (don´t ask).

问题:
1.是否有可能以某种方式关闭轮廓只需填写通缉对象?
2.什么我真的想看到的是底部,(如)统治者的高度的坐标。
任何其他的解决方案是AP preciated。你将如何实现呢?

Questions:
1. Is it possible to close the contours somehow to just fill the wanted object?
2. What I ACTUALLY want to find are the coordinates of the bottom AND the height of (e.g.) the ruler.
ANY other solutions are appreciated. How would you realize it?

更新:我固定一个问题),并使用这种方法的时刻(很不高兴)。我也试过Entreco的做法,但似乎并没有现在给所需的解决方案。

Update:I fixed the problem with a) and use this approach at the moment (not happy about it). I also tried Entreco ´s approach, but seem not to give the wanted solution by now.

推荐答案

我不知道你是否尝试过这一点,但通常情况下,你可以先处理图像达到更好的效果。

I don't know if you tried this, but usually, you can achieve better results by processing the image first.

1)适用<一href="http://opencv.willowgarage.com/documentation/cpp/image_filtering.html#cv-gaussianblur">GuassianBlur以消除噪音

2)应用<一href="http://opencv.willowgarage.com/documentation/cpp/miscellaneous_image_transformations.html#cv-adaptivethreshold">AdaptiveThreshold - >将图像转换成黑白

2) Apply AdaptiveThreshold -> to convert the image to black and white

3)应用扩张操作,填补缝隙

3) Apply Dilate operation, to fill the cracks

使用的AdaptiveThreshold和扩张操作不同的设置,你也许可以得到封闭轮廓......

By using different settings for the AdaptiveThreshold and the Dilate operation, you might be able to get closed contours...

我用一个例子是这样的:

An example I used is like this:

// 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);

这篇关于目标检测机器人的OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆