android 颜色检测opencv

android color detection opencv

我使用 opencv 颜色斑点检测来检测黑色背景的小白点。当点大时它可以检测到它,但是当点变小时,它就检测不到。 我认为我们可以为颜色斑点检测样本中的小点设置一个参数,但我找不到 that.any body 知道吗? 或任何 body 知道检测白色的更好更快的方法? 注意:在相机中只有一个白点,所有背景都是黑色的。

这是object大的时候的图(相机靠近object):

http://www.axgig.com/images/14410928700656745289.png

这是object小的时候(相机离object远):

http://www.axgig.com/images/00768609020826910230.png

我要检测白色的坐标point.How?

如果整个背景都是黑色的,而你感兴趣的区域是白色的,你可以使用Moments function in the Imgproc module. You can read about the math behind it at Wikipedia找到中心,但简单地说,将所有非零点的加权位置相加.获得 Moments 结构后,您可以通过以下方式计算中心:

x = moments.m10 / moments.m00
y = moments.m01 / moments.m00

在您的情况下,使用 Android 和 OpenCV,这是您将使用的代码:

// inputMat is the Mat that you took screenshots of earlier in the question.
Moments moments = Imgproc.moments(inputMat, true);
float center_x = moments.m10 / moments.m00;
float center_y = moments.m01 / moments.m00;
// now center_x and center_y have the coordinates of the center of the blob.