Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Drawing a rect around points - java, opencv

I am developing a simple program that detects two corners in an image and then draws a rectangle around both the points. It detects the corners perfectly, but i am having trouble drawing around the corners with a rectangle.. any help would be greatly appreciated..

Imgproc.cvtColor(image, image, Imgproc.COLOR_RGB2GRAY);
                    equalizeHist(image, image);
                    MatOfPoint newcorners = new MatOfPoint();
                    Imgproc.goodFeaturesToTrack(image, newcorners, 2, 0.01, 10);

                    Point[] cornerpoints = newcorners.toArray();

                    for (Point points : cornerpoints) {
                        circle(image, points, 1, new Scalar(100,100,100), -1);
                    }

                   rectangle(image, new Point(cornerpoints[0].x, cornerpoints[0].y), new Point(cornerpoints[0].x + cornerpoints[1].x, cornerpoints[0].y + cornerpoints[1].y), new Scalar(255, 255, 0));