OpenCV的:多米诺骨牌圆点/磁盘检测

编程入门 行业动态 更新时间:2024-10-15 00:27:33
本文介绍了OpenCV的:多米诺骨牌圆点/磁盘检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开发一个Android应用程序的计算之中,看到的多米诺骨牌件-shown使用OpenCV进行Android的图片 - 的所有点的总和。

I am developing an Android app that calculates the sum of all points of the being-seen dominoes pieces -shown in picture- using OpenCV for Android.

现在的问题是,我无法找到一个方法来过滤其他轮廓,只计算点我在多米诺骨牌看到,我试图用Canny边缘寻找,然后使用HoughCircles,但没有结果,因为我没有岩石和HoughCircles绝对俯视探测正圆只:)

The problem is, I can't find a way to filtering other contours and counting only dots I see in the dominoes, I tried to use Canny edge finding then use HoughCircles, but with no result, as I don't have an absolute top view of the rocks and HoughCircles detect perfect circles only :)

下面是我的code:

public Mat onCameraFrame(Mat inputFrame) { inputFrame.copyTo(mRgba); Mat grey = new Mat(); // Make it greyscale Imgproc.cvtColor(mRgba, grey, Imgproc.COLOR_RGBA2GRAY); // init contours arraylist List<MatOfPoint> contours = new ArrayList<MatOfPoint>(200); //blur Imgproc.GaussianBlur(grey, grey, new Size(9,9), 10); Imgproc.threshold(grey, grey, 80, 150, Imgproc.THRESH_BINARY); // because findContours modifies the image I back it up Mat greyCopy = new Mat(); grey.copyTo(greyCopy); Imgproc.findContours(greyCopy, contours, new Mat(), Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_NONE); // Now I have my controus pefectly MatOfPoint2f mMOP2f1 = new MatOfPoint2f(); //a list for only selected contours List<MatOfPoint> SelectedContours = new ArrayList<MatOfPoint>(400); for(int i=0;i<contours.size();i++) { if(here I should put a condition that distinguishes my spots, eg: if contour inside is black and is a black disk) { SelectedContours.add(contours.get(i)); } } Imgproc.drawContours(mRgba, SelectedContours, -1, new Scalar(255,0,0,255), 1); return mRgba; }

编辑:

我的轮廓,一个独特的功能后,门槛是他们是全黑的里面,反正是有,我可以计算平均色彩/亮度为给定的轮廓?

One unique feature of my contours after threshold is they're totally black from inside, is there anyway I could calculate the mean color/intensity for a given contour ?

推荐答案

有一个类似的问题和SO可能的解决方案,名为Detection对图片硬币(和合适的椭圆)。在这里你会找到有关的OpenCV的功能有些recomendations fitEllipse 。

There is a similiar problem and possible solution on SO, titled Detection of coins (and fit ellipses) on an image. Here you will find some recomendations about opencv's function fitEllipse.

您应该看看这对OpenCV的函数的详细信息 fitEllipse 。

You should take a look at this for more info on opencv's function fitEllipse.

此外,检测的图像只有黑色的元素,你可以使用HSV颜色模型,发现只有黑色的颜色。您可以这里找到一个解释。

Also, to detect only black elements in an image, you can use HSV color model, to find only black colors. You can find an explanation here.

更多推荐

OpenCV的:多米诺骨牌圆点/磁盘检测

本文发布于:2023-11-29 11:45:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646306.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:磁盘   圆点   多米诺骨牌   OpenCV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!