title: Draw convex hull on android
body: <p>I try to draw convex hull on image.For this, I find all contours and select max area contour. <code>drawContours</code> accepts <code>MatOfPoint</code> but <code>convexHull</code> gives me <code>MatOfInt</code>. I read this <a href="https://stackoverflow.com/questions/17586948/convex-hull-on-java-android-opencv-2-3">question</a> and run some codes. Some of them draw convex hull, but they cannot find really convex points. </p>
  
  <p>I use below code, but it has a runtime error on last line <code>m.fromArray(hullpoints.get(i));</code>. <code>hullpoints.get(i)</code> has only one point and the code cannot create <code>MatOfPoint</code> object. How can I convert to <code>MatOfPoint</code> from <code>MatOfInt</code> ?</p>
  
  <pre><code>        // Find the convex hull
          List&lt;MatOfInt&gt; hull = new ArrayList&lt;MatOfInt&gt;();
          for(int j=0; j &lt; contours.size(); j++){
              hull.add(new MatOfInt());
          }
          for(int j=0; j &lt; contours.size(); j++){
              Imgproc.convexHull(contours.get(j), hull.get(j));
          }
  
          // Convert MatOfInt to MatOfPoint for drawing convex hull
          // Loop over all contours
          List&lt;Point[]&gt; hullpoints = new ArrayList&lt;Point[]&gt;();
          for(int j=0; j &lt; hull.size(); j++){
              Point[] points = new Point[hull.get(j).rows()];
  
              // Loop over all points that need to be hulled in current contour
              for(int k=0; k &lt; hull.get(j).rows(); k++){
                  int index2 = (int)hull.get(j).get(k, 0)[0];
                  points[k] = new Point(contours.get(j).get(index2, 0)[0], contours.get(j).get(index2, 0)[1]);
              }
              hullpoints.add(points);
          }
  
          // Convert Point arrays into MatOfPoint
          List&lt;MatOfPoint&gt; hullmop = new ArrayList&lt;MatOfPoint&gt;();
          for(int j=0; j &lt; hullpoints.size(); j++){
              MatOfPoint m = new MatOfPoint();
              m.fromArray(hullpoints.get(i));
              hullmop.add(m);
          }
  </code></pre>