gpt4 book ai didi

c++ - 如何使用 OpenCV 访问外部网络摄像头?

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:54 24 4
gpt4 key购买 nike

最大的问题在于代码,无论我在 VideoCapture cap() 中输入哪个数字,它总是会找到我笔记本电脑的内部 webcap - 或者死于尝试。我试过进入设备并停用内部设备,但是它没有什么好处。(顺便说一下,我是这个论坛的新人,所以要温柔。)

这是代码(不包括旋转功能。)

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);

}
}

最佳答案

设备管理器 -> 找到内部网络摄像头 -> 禁用内部网络摄像头。默认网络摄像头将成为您插入的任何网络摄像头之后。

关于c++ - 如何使用 OpenCV 访问外部网络摄像头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7967404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com