Android用OpenCVを使用して、画像中に表示されている、見られているドミノのすべての点の合計を計算するAndroidアプリを開発しています。OpenCV:ドミノサークルスポット/ディスク検出
問題は、私は他の輪郭をフィルタリングし、私がドミノに表示ドットのみをカウントする方法を見つけることができません、ですが、私は、その後、HoughCirclesを使用見つけるキャニーエッジを使用しようとしましたが、結果なしで
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;
}
EDIT:
私は岩の絶対的な上面図を持っていないとHoughCirclesは完璧な円を検出するようにのみここで:)は、私のコードです
スレッショルド後の私の輪郭のユニークな特徴の一つは、内側から完全に黒色です。それで、とにかく、私は与えられた輪郭の平均色/強度を計算できますか?
この図では、 –
ちょうどそれを追加、ごめんなさい –