Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Understand that most of the C interface of OpenCV deals with <code>IplImage</code>, not <code>Buffer</code> nor any other custom data type. In other words, doing:</p> <pre><code>Buffer B = Buf; cvThreshold( B, B, 200, 255, CV_THRESH_BINARY ); </code></pre> <p>will issue a compiling error because <code>cvThreshold()</code> requires the data to be encapsulated in an <code>IplImage</code>.</p> <p>I don't want to run the risk of being Captain Obvious, but you need to convert <code>Buffer</code> to <code>IplImage</code>. So how do you do that, one might ask. Well, <code>IplImage</code> is simple data type that holds these important pieces of information together:</p> <ul> <li>The <strong>size</strong> of the image (width/height);</li> <li>The <strong>bit depth</strong> of the image;</li> <li>The <strong>number of channels</strong>;</li> <li>And the <strong>data</strong> (pixels) of the image;</li> </ul> <p>And <a href="https://stackoverflow.com/a/10125322/176769">how do you create a <code>IplImage</code> from scratch</a>? Call <a href="http://opencv.willowgarage.com/documentation/operations_on_arrays.html#createimageheader" rel="nofollow noreferrer"><code>cvCreateImageHeader()</code></a> followed by <a href="http://opencv.willowgarage.com/documentation/operations_on_arrays.html?highlight=cvsetdata#cvSetData" rel="nofollow noreferrer"><code>cvSetData()</code></a>. </p> <p><strong>Note</strong>: for the <em>depth</em> parameter, you might want to use either <a href="http://opencv.willowgarage.com/documentation/basic_structures.html#iplimage" rel="nofollow noreferrer">IPL_DEPTH_16U or IPL_DEPTH_16S</a>. If your image is RGB, the <em>number of channels</em> is 3. After you are done using the <code>IplImage</code>, don't forget to call <code>cvReleaseImage()</code> to free it's resources. </p> <p>I believe the real challenge is: how will you extract all these information from <code>Buffer</code>. Good luck!</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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