Ask Your Question

lm1993's profile - activity

2020-01-07 20:44:47 -0600 received badge  Popular Question (source)
2016-01-24 09:29:41 -0600 commented question finding the highest / lowest contours in a ROI

apologies for my slow reply. yeah i want to find the highest point and lowest point in the contours and output it as a Point

2016-01-23 11:30:06 -0600 asked a question finding the highest / lowest contours in a ROI

I am developing an app that searches for contours within a region of interest. I only want to display the top and bottom contours. I have managed to find the contours but i only want to display the highest and lowest contours. I have made a for loop that loops through the contours but i am unsure how to progress.. anyone got any ideas?

Thankyou in advance

RoiMat= image.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width);

                    Imgproc.cvtColor(RoiMat, RoiMat, Imgproc.COLOR_RGB2GRAY);
                    equalizeHist(RoiMat, RoiMat);
                    Imgproc.GaussianBlur(RoiMat, RoiMat, new Size(5, 5), 0);
                    Imgproc.threshold(RoiMat, RoiMat, 100, 255, Imgproc.THRESH_BINARY_INV);

                    List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
                    Mat hierarchy = new Mat();
                    Imgproc.findContours(RoiMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);


                    for (int contourIdx = 0; contourIdx < contours.size(); contourIdx++) {
                        //search for the highest and lowest contours here and output as points.
Mat contour = contours.get(idx);
                    }
2016-01-22 09:05:09 -0600 received badge  Enthusiast
2016-01-20 09:05:44 -0600 received badge  Scholar (source)
2016-01-20 09:05:40 -0600 received badge  Supporter (source)
2016-01-20 06:43:26 -0600 asked a question 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));
2016-01-17 13:56:40 -0600 received badge  Editor (source)
2016-01-15 04:33:03 -0600 asked a question goodFeaturesToTrack on a submat

I am using the goodfeaturestotrack function of opencv and I want to only search for features in a ROI. I have set the ROI as newSubMat then ran goodfeaturestotrack. I now want to copy the points back into the original image to be displayed.. I have tried this below but got no luck. anyone see where i am going wrong?? Thanks

                newSubMat = originalimage.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width);
                Imgproc.cvtColor(newSubMat , newSubMat , Imgproc.COLOR_RGB2GRAY);

                MatOfPoint corners = new MatOfPoint();
                Imgproc.goodFeaturesToTrack(newSubMat , corners, 4, 0.01, 10);

                Point[] points = corners.toArray();
                for (Point point : points) {
                    circle(newSubMat , point, 4, new Scalar(255, 0, 255), -3);
                }

                Imgproc.cvtColor(newSubMat , newSubMat , Imgproc.COLOR_GRAY2RGB);