title: OpenCV Having issues with cv::FAST
body: <p>I'm trying to use the open CV FAST algorithim in order to detect corners from a video feed. The method call and set-up seems pretty straight forward yet I'm running into a few problems. When I try and use this code    </p>
  
  <pre><code>  while(run)
  {
      clock_t begin,end;
      img = cvQueryFrame(capture);
  
      key = cvWaitKey(10);
  
  
      cvShowImage("stream",img);
      //Cv::FAST variables
      int threshold=9;
      vector&lt;KeyPoint&gt; keypoints;
  
      if(key=='a'){
          //begin = clock();
  
  
          Mat mat(tempImg);
  
          FAST(mat,keypoints,threshold,true);
          //end = clock();
          //cout &lt;&lt; "\n TIME FOR CALCULATION: " &lt;&lt; double(diffClock(begin,end)) &lt;&lt; "\n" ;
  
      }
  </code></pre>
  
  <p>I get this error:</p>
  
  <p>OpenCV Error: Assertion failed (image.data &amp;&amp; image.type() == CV_8U) in unknown
  function, file ........\ocv\opencv\src\cvaux\cvfast.cpp, line 6039</p>
  
  <p>So I figured its a problem with the depth of the image so I when I add this:</p>
  
  <pre><code>    IplImage* tempImg = cvCreateImage(Size(img-&gt;width,img-&gt;height),8,1);
          cvCvtColor(img,tempImg,CV_8U);
  </code></pre>
  
  <p>I get:</p>
  
  <p>OpenCV Error: Bad number of channels (Incorrect number of channels for this conv
  ersion code) in unknown function, file ........\ocv\opencv\src\cv\cvcolor.cpp
  , line 2238</p>
  
  <p>I've tried using a Mat instead of a IplImage to capture but I keep getting the same kind of errors.</p>
  
  <p>Any suggestions or help?
  Thanks in advance.</p>
  
  <p>The entire file just to make it easier for anyone:</p>
  
  <pre><code>    #include "cv.h"
      #include "cvaux.hpp"
      #include "highgui.h"
  
      #include &lt;time.h&gt;
      #include &lt;iostream&gt;
  
  
  
      double diffClock(clock_t begin, clock_t end);
  
      using namespace std;
      using namespace cv;
  
      int main(int argc, char** argv)
      {
  //Create Mat img for camera capture 
  IplImage* img;
  bool run = true;
  
  CvCapture* capture= 0;
  capture = cvCaptureFromCAM(-1);
  int key =0;
  cvNamedWindow("stream", 1);
  
  while(run)
  {
      clock_t begin,end;
      img = cvQueryFrame(capture);
  
      key = cvWaitKey(10);
  
  
      cvShowImage("stream",img);
      //Cv::FAST variables
      int threshold=9;
      vector&lt;KeyPoint&gt; keypoints;
  
      if(key=='a'){
          //begin = clock();
          IplImage* tempImg = cvCreateImage(Size(img-&gt;width,img-&gt;height),8,1);
          cvCvtColor(img,tempImg,CV_8U);
  
          Mat mat(img);
  
          FAST(mat,keypoints,threshold,true);
          //end = clock();
          //cout &lt;&lt; "\n TIME FOR CALCULATION: " &lt;&lt; double(diffClock(begin,end)) &lt;&lt; "\n" ;
  
      }
      else if(key=='x'){
          run= false;
      }
  }
  cvDestroyWindow( "stream" );
  return 0;
  </code></pre>
  
  <p>}</p>