Ich entwickle eine Android App, die die Summe aller Punkte der gesehenen Domino Teile - gezeigt in Bild - mit OpenCV für Android berechnet.OpenCV: Dominoes Kreisspots/Disketten Erkennung
Das Problem ist, ich kann nicht einen Weg, um das Filtern andere Konturen finden und zu zählen nur Punkte die ich in den Dominosteine zu sehen, ich habe dann versucht HoughCircles verwenden Suche nach Canny Rand zu verwenden, aber ohne Ergebnis, wie ich perfekte Kreise keine absolute Draufsicht auf den Felsen haben und HoughCircles nur erkennen :)
Hier ist mein 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;
}
EDIT:
Ein einzigartiges Merkmal meiner Konturen nach der Schwelle ist, dass sie von innen total schwarz sind. Kann ich die durchschnittliche Farbe/Intensität für eine bestimmte Kontur berechnen?
gezeigt in welchem Bild? –
Nur hinzugefügt, sorry –