title: How to use CvInRange in Emgu CV
body: <p>I am learning to use Emgu CV and stumbled upon this Open CV example : <a href="http://aishack.in/tutorials/tracking-colored-objects-in-opencv/" rel="nofollow noreferrer">http://aishack.in/tutorials/tracking-colored-objects-in-opencv/</a></p>
  
  <p>I want to recreate the <code>CvInRange</code> function in Emgu by creating this code :</p>
  
  <pre><code>// create upper &amp; lower limit (HSV)
  MCvScalar botLimit = new MCvScalar(20, 100, 100);
  MCvScalar uprLimit = new MCvScalar(30, 255, 255);
  
  // prepare the destination
  Image&lt;Hsv, byte&gt; imageHSVDest = new Image&lt;Hsv, byte&gt;(imageWidth, imageHeight);
  
  // 
  CvInvoke.cvInRange(imageHSV, botLimit, uprLimit, imageHSVDest);
  </code></pre>
  
  <p>the <code>CvInvoke.cvInRange()</code> produce this error message (in vs2010) :</p>
  
  <blockquote>
    <p>Error  1   The best overloaded method match for 'Emgu.CV.CvInvoke.cvInRange(System.IntPtr, System.IntPtr, System.IntPtr, System.IntPtr)' has some invalid arguments<br>
        Error   2   Argument 2: cannot convert from 'Emgu.CV.Structure.MCvScalar' to 'System.IntPtr'
        Error   3   Argument 3: cannot convert from 'Emgu.CV.Structure.MCvScalar' to 'System.IntPtr'</p>
  </blockquote>
  
  <p>It seems there is a mismatch data type. I have searched how to convert Emgu <code>MCvScalar</code> to <code>IntPtr</code> to no avail. </p>
  
  <p>I used the <code>MCvScalar</code> by translating OpenCV <code>cvScalar(20, 100, 100)</code> from the example. Is this wrong?</p>