在Android中使用OpenCV加载图像 [英] Loading an image using OpenCV in Android

查看:300
本文介绍了在Android中使用OpenCV加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果本网站已经涵盖了这个问题,我很抱歉,但我似乎找不到直截了当的答案。我正在制作一个Android应用程序,它使用OpenCV拍摄照片,处理它以检测物体,并找出场景中这些物体的坐标。

I apologize if this question has already been covered on this site, but I can't seem to find a straight forward answer. I'm making an android app that uses OpenCV to take a picture, process it to detect objects, and figure out the coordinates of those objects in the scene.

所有我发现android的教程似乎是实时处理相机预览或使用c ++,我更倾向于不必走c ++之路。我确定我错过了一些简单的东西,但我不知道它是什么。

All the tutorials I find for android seem to be real time processing of the camera preview or using c++, which I would strongly prefer to not have to go down the c++ road. I'm sure I'm missing something simple but I don't know what it is.

另一方面,我试图检测的对象是台球在桌子上。什么是最好的预处理技术,以更好地检测球?我使用canny方法进行了快速测试,似乎从球上反射的光线破坏了圆形。

On another note, the objects I'm trying to detect are billiards balls on a table. What would be the best pre-processing technique to better detect the balls? I did a quick test using the canny method, and it seems that the light reflecting off the balls breaks up the circle shape.

推荐答案

要在Android中加载图像,您可以使用

To load images in Android, you can use

Bitmap bMap=BitmapFactory.decodeResource(getResources(),R.drawable.image1)

其中image1是Android项目的Resources文件夹下的图像。
然后在 android-opencv <中使用matToBitmap或MatToBitmap方法将Bitmap转换为字节或Mat并使用C ++(OpenCV)或Java进行处理/ a>。

where image1 is a image under Resources folder of your Android project. Then convert Bitmap to bytes or Mat and process in C++ (OpenCV) or Java with matToBitmap or MatToBitmap methods in android-opencv.

如果你习惯使用Mat数据类型进行处理,你可以使用(你需要 android-opencv 项目使用此项目)

If you are comfortable in processing using Mat data type, you can use (you need android-opencv project to use this)

Mat m = Highgui.imread("/media/path_to_image");

您可以使用blob,hough circle来检测台球。没有办法回答这个问题。你可以尝试使用标准化的RGB或Lab颜色空间来玩(去除台球的反射),看看你是否检测到了台球(通过运行霍夫圈,斑点探测器)。

You can use blobs, hough circles to detect billiard balls. There is no certain way to answer this. You can try using normalized RGB or Lab colorspaces to play around (to remove reflection of the billiard balls) to see if you detect billiard balls (by running hough circles, blob detectors).

实时场景将要求您使用机器学习技术通过使用某些特征向量来检测台球,然后进行训练和测试。

The real-time scenario will require you to use machine-learning techniques to detect billiard balls by using certain feature vectors, then do training and testing.

这篇关于在Android中使用OpenCV加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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