title: Raspberry Pi becomes unresponsive when running OpenCV
body: <p>I have successfully installed OpenCV on my Raspberry Pi and have been fooling around with some simple webcam streaming, live canny-edge detection, and so forth, all using basic C and C++ code.</p>
  
  <p>However, I'm running into problems with the two webcams I'm using. The first, a really basic, cheap Logitech I had sitting around, works fine, but the image quality leaves a LOT to be desired. But when I switch to my Logitech 510c camera, the image is much better, but the Pi freezes.</p>
  
  <p>Rather, the streaming program continues to run fine, but I can't exit the program - the Raspberry Pi stops responding to the keyboard and the mouse, and the only way to quit is to unplug the Raspberry Pi. Here's an example of some of the code:</p>
  
  <pre><code>#include &lt;cv.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(){
  
    int c, i, j;
  
    //Capture frame from camera
    CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
    if(!capture){
      fprintf(stderr, "Error: capture is NULL \n");
      getchar();
      return -1;
    }
  
    //Set resolution of capture
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 256);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 192);
  
    //Create window for display
    cvNamedWindow("canny");
  
    while(true){
  
      //Find/mark edges using canny
      IplImage* frame = cvQueryFrame(capture);
      IplImage* grey = cvCreateImage(cvGetSize(frame), 8, 1);
      cvCvtColor(frame, grey, CV_RGB2GRAY);
      IplImage* frame2 = cvCreateImage(cvSize(grey-&gt;width+6, grey-&gt;height+6), grey-&gt;depth, grey-&gt;nChannels);
  
      CvPoint offset = cvPoint(3,3);
      cvCopyMakeBorder(grey, frame2, offset, IPL_BORDER_REPLICATE, cvScalarAll(0));
      IplImage* edges = cvCreateImage(cvGetSize(frame2), IPL_DEPTH_8U, frame2-&gt;nChannels);
      cvCanny(frame2, edges, 4900, 39200, 7);
  
      cvShowImage("canny", edges);
  
      //Wait for a keypress
      int c = cvWaitKey(10);
      if (c!=-1)
          break;
    } //End while
  
    cvReleaseCapture (&amp;capture);
    cvDestroyWindow("canny");
    return 0;
  } //End main
  </code></pre>
  
  <p>Is there a problem with my code? Do I need to use a different webcam? I've overclocked the Raspberry Pi; can it simply not handle the stream with a better-quality camera?</p>