title: How do I access an external webcam with OpenCV?
body: <p>The big problem lies in the fact that the code, no matter which number I type in to VideoCapture cap(), it will always find the internal webcap of my laptop - Or die trying.
  I have tried going in to devices and deactivated the internal one, but
  it did little good.
  (By the way, I'm new at this forum, so be gentle.)</p>
  
  <p>Here's the code ( Not including the Rotation function.)</p>
  
  <pre><code>int main()
  {   
  // NOW WITH WEBCAM INPUT!!
      VideoCapture cap(0);//capture image from webcam
      cap.open(true); 
      Mat image;
      cap&gt;&gt;image; //applying the captured image to Mat image
      //Mat image = imread("Tulips.jpg"); // reading the image
      double degrees; // Number of degrees we want to rotate the image
      double oregoX = image.cols / 2; //X-center of the image
      double oregoY = image.rows / 2; //Y-center of the image
  
  //user inputs
  cout &lt;&lt; "please enter the number of degrees you wish to turn the image" &lt;&lt; endl;
  cin &gt;&gt; degrees;
  
  cout &lt;&lt; "\n\nplease enter at which point (X, Y) you want to rotate the image\n(make space not comma)\n" &lt;&lt; endl;
  cout &lt;&lt; "The center of the image is at " &lt;&lt; oregoX &lt;&lt; ", " &lt;&lt; oregoY &lt;&lt; endl;
  cin &gt;&gt; oregoX &gt;&gt; oregoY;
  
  while (true){
      cap&gt;&gt;image;
  
      if (!image.data) break;
      if (waitKey(30) &gt;= 0) break;
  
      cvtColor(image, image, CV_8U); //Converting image to 8-bit
      Mat grayImage; //creating a canvas for the grayscale image
      cvtColor(image, grayImage, CV_RGB2GRAY); //creating the grayscale image
  
  
  
      // Here we create a canvas with the same size as the input image, later to put in the rotated data
      Mat imageOut(grayImage.rows, grayImage.cols, CV_8U);
  
  
  
      Rotation(grayImage, imageOut, degrees, oregoX, oregoY); //Performing the rotation on the image using the Rotation() funcion
  
      imshow("The Gray Image", grayImage);
      imshow("The rotated image", imageOut);
  
  }
  </code></pre>
  
  <p>}</p>