0
此代碼是OpenCV的C++:此代碼到OpenCV Java的翻譯是什麼?
lines = cvHoughCircles(frame2, storage, CV_HOUGH_GRADIENT, 1, 50, 300, 60, 10, 600);
for (int i = 0; i < lines.total(); i++) {
//Would like the code to go here
CvPoint2D32f point = new CvPoint2D32f(cvGetSeqElem(lines, i));
cvCircle(src, cvPoint((int)point.x(), (int)point.y()), 3, CvScalar.WHITE, -1, 8, 0);
Point p = new Point((int)point.x(), (int)point.y());
points.add(p);
}
中有什麼新的Java API的記者?我無法獲得CvPoint2D32f
,cvGetSeqElem
和CV_AA
。我發現存在於JavaCV中,但在OpenCV Java api中找不到它們。
感謝
編輯:
我已經改變了我的代碼,我現在有:
MatOfPoint3 circles = new MatOfPoint3();
Imgproc.HoughCircles(image, circles, Imgproc.CV_HOUGH_GRADIENT,2, image.rows()/4,200,100,0,0);
for(Point3 circle : circles.toArray()){
Point center = new Point(circle.x, circle.y);
int radius = (int) Math.round(circle.z);
Core.circle(image, center, radius, new Scalar(0,255,0), 6, 8, 0);
}
但是我在for(Point3 circle : circles.toArray())
錯誤:
Exception in thread "main" java.lang.UnsupportedOperationException: Mat data type is not compatible: 21
at org.opencv.core.Mat.get(Mat.java:2581)
at org.opencv.core.MatOfPoint3.toArray(MatOfPoint3.java:64)
at org.opencv.core.MatOfPoint3.toList(MatOfPoint3.java:76)
at main.java.DetectFaceDemo.run(HelloOpenCV.java:60)
at main.java.HelloOpenCV.main(HelloOpenCV.java:83)
對此有何想法?由於
編輯2:
解決最後的編輯問題存在於 MatOfPoint3 circles = new MatOfPoint3();
它必須是 MatOfPoint3f circles = new MatOfPoint3f();
「cvGetSeqElem」和「CV_AA」呢?我找不到他們。謝謝 –
猜猜我不需要'cvGetSeqElem'。 (Point3 circle:circles.toArray()){ Point center = new Point(circle.x,circle.y); int radius =(int)Math.round(circle.z); Core.circle(image,center,radius,new Scalar(0,255,0),6,CV_AA,0); }' 現在只有'CV_AA'丟失 –