Ask Your Question

Sofia's profile - activity

2017-08-09 16:33:36 -0600 received badge  Famous Question (source)
2015-09-27 15:22:22 -0600 received badge  Notable Question (source)
2014-11-16 07:05:01 -0600 received badge  Popular Question (source)
2013-04-18 15:01:37 -0600 commented answer Getting a point from a contour opencv android

Thanks for your answer ! It helped me out a lot !

2013-04-18 14:58:40 -0600 received badge  Editor (source)
2013-04-18 14:50:15 -0600 received badge  Scholar (source)
2013-04-13 16:41:17 -0600 asked a question Getting a point from a contour opencv android

Hi everyone !

I am trying to extract a point from a contour in opencv android, but I can't seem to find an equivalent for cvGetSeqElem, so I don't really know what to do. Here is my code :

            Imgproc.findContours(mGray, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
            Mat maxContour = contours.get(idx);

            for(int i=0; i< maxContour.total();i++)
            {
                Point v= ? //This is where I would write new Point(Imgproc.cvGetSeqElem(maxContour, i)) 
            }`

Does someone know the android equivalent for cvGetSeqElem? Or some other way to extract the points?

Edit : The question is solved. I just thought I would post the working code in case someone is interested. I get the biggest contour detected and extract the points from it :

          List<MatOfPoint>contours= new ArrayList<MatOfPoint>();
          Imgproc.findContours(mGray, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
          for (int idx = 0; idx < contours.size(); idx++) 
          {
                MatOfPoint contour = contours.get(idx);
                double contourarea = Imgproc.contourArea(contour);
                if (contourarea > maxContourArea) 
                {
                         maxContour = contour;
                         maxContourArea = contourarea;
                         maxAreaIdx = idx;
                }
          }

          points_contour = maxContour.toArray();
          nbPoints = points_contour.length; 

          for(int i=0; i< nbPoints;i++)
          {
                  Point v=points_contour[i];
          }