Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract area detected by color using OpenCV in Android
    primarykey
    data
    text
    <p>The sample project named "color-blob-detection" that comes with the openCV SDK for android can be used to identify an area of a particular color. What I require is to extract that area and save it into the phone memory as a bitmap.</p> <p>This is what I have understood so far:</p> <p>There is a list of contours:</p> <pre><code>List&lt;MatOfPoint&gt; contours = new ArrayList&lt;MatOfPoint&gt;(); </code></pre> <p>Contours are found using:</p> <pre><code>Imgproc.findContours(mDilatedMask, contours, mHierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); </code></pre> <p>This finds the max contour area:</p> <pre><code>double maxArea = 0; Iterator&lt;MatOfPoint&gt; each = contours.iterator(); while (each.hasNext()) { MatOfPoint wrapper = each.next(); double area = Imgproc.contourArea(wrapper); if (area &gt; maxArea) maxArea = area; } </code></pre> <p>I would like to know how this largest area can be saved into the sdcard as a bitmap. Any help is greatly appreciated!</p> <p>//////EDIT</p> <p>This is used to draw Contours. I am not sure whether this is the correct way:</p> <pre><code> Imgproc.cvtColor(mDilatedMask, mDilatedMask, Imgproc.COLOR_GRAY2BGR); Imgproc.drawContours(mDilatedMask, contours, -1, new Scalar(0, 255, 0), 1); Toast.LENGTH_LONG).show(); Bitmap bmpOut = Bitmap.createBitmap(mDilatedMask.cols(), mDilatedMask.rows(), Bitmap.Config.ARGB_8888); Utils.matToBitmap(mDilatedMask, bmpOut); try { bmpOut.compress(CompressFormat.JPEG, 100, new FileOutputStream("/sdcard/mediaAppPhotos/bigrect.jpg")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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