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.)
Here's the code ( Not including the Rotation function.)
int main()
{
// NOW WITH WEBCAM INPUT!!
VideoCapture cap(0);//capture image from webcam
cap.open(true);
Mat image;
cap>>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 << "please enter the number of degrees you wish to turn the image" << endl;
cin >> degrees;
cout << "\n\nplease enter at which point (X, Y) you want to rotate the image\n(make space not comma)\n" << endl;
cout << "The center of the image is at " << oregoX << ", " << oregoY << endl;
cin >> oregoX >> oregoY;
while (true){
cap>>image;
if (!image.data) break;
if (waitKey(30) >= 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);
}
}
Device manager -> Locate internal webcam -> Disable internal webcam. The default webcam will then become whichever webcam that you plug in afterwards.
VideoCapture cap(1); //capture image from other webcam
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.