Dies ist, was ich versucht habe.Ich habe die Ausgabe als Graustufenbild in img2 eines Imageview-Objekts.In android Wie zähle ich die Anzahl der Zeilen in einem Bild mit openCV
Das Problem ist, wie Linien.Cols() alles als eine Linie betrachtet.
Ich möchte die Anzahl genau die Anzahl der größeren Linien wie im 1stpic gezeigt (ich meine die Linien, die den Parkplatz trennt, in denen das Auto ocupy) My output image Kann mir jemand wie man die genaue Anzahl zu bekommen Park lines.I OpenCV Version 2.4.I verwendet haben für die letzten 2 Tage auf dieser arbeitet
public String getCount() {
Bitmap bitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.park);
mat = new Mat();
edges = new Mat();
Mat mRgba = new Mat(612, 816, CvType.CV_8UC1);
Mat lines = new Mat();
Utils.bitmapToMat(bitmap, mat);
Imgproc.Canny(mat, edges, 50, 90);
int threshold = 50;
int minLineSize = 20;
int lineGap = 20;
Imgproc.HoughLinesP(edges, lines, 1, Math.PI/180, threshold, minLineSize, lineGap);
int count = lines.cols();
int coun= lines.rows();
System.out.println("count = " + count);
System.out.println("coun = " + coun);
String cou = String.valueOf(count);
for (int x = 0; x < lines.cols(); x++) {
double[] vec = lines.get(0, x);
double x1 = vec[0],
y1 = vec[1],
x2 = vec[2],
y2 = vec[3];
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
Core.line(mRgba, start, end, new Scalar(255, 0, 0), 3);
}
Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mRgba, bmp);
bitmap = bmp;
Drawable d = new BitmapDrawable(Resources.getSystem(), bitmap);
img2.setImageDrawable(d);
return cou;
}