Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the translation of this code to OpenCV Java?
    primarykey
    data
    text
    <p>This code is OpenCV c++:</p> <pre><code>lines = cvHoughCircles(frame2, storage, CV_HOUGH_GRADIENT, 1, 50, 300, 60, 10, 600); for (int i = 0; i &lt; 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); } </code></pre> <p>What is the correspondent in the new Java Api? I cannot get <code>CvPoint2D32f</code>, <code>cvGetSeqElem</code> and <code>CV_AA</code>. I found that existed in JavaCV but cannot find them in OpenCV Java api.</p> <p>Thanks</p> <p><strong>EDIT:</strong></p> <p>I've changed my code and now I have:</p> <pre><code>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); } </code></pre> <p>However I got an error at <code>for(Point3 circle : circles.toArray())</code>:</p> <pre><code>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) </code></pre> <p>Any thoughts on this? Thanks</p> <p><strong>EDIT 2:</strong></p> <p>The solution to last edit problem resides in <code>MatOfPoint3 circles = new MatOfPoint3();</code></p> <p>It must be <code>MatOfPoint3f circles = new MatOfPoint3f();</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload