我如何使用OpenCV访问外部网络摄像头?
How do I access an external webcam with OpenCV?
最大的问题在于代码,无论我在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 << "nnplease enter at which point (X, Y) you want to rotate the imagen(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);
}
}
设备管理器->查找内部摄像头->禁用内部摄像头。默认的网络摄像头将变成你插入的任何一个网络摄像头div。
VideoCapture cap(1); //capture image from other webcam
相关文章:
- OpenCV 4.1.2 - 从网络摄像头获取帧并将其拆分
- 使用OpenCV和覆盆子上的多个网络摄像头拍摄延时摄影,出现多个V4L错误
- 使用源读取器从网络摄像头源获取 H264 样本
- 为什么我不能让 3 个网络摄像头与 pthreads 并行运行?
- 从 OpenCV 3 切换到 OpenCV 4 会导致网络摄像头以最大 5 fps 的速度录制,而不是通常的 30 f
- 媒体基金会可以允许多个客户端同时访问单个网络摄像头设备吗?
- 从C++调用网络摄像头并在 Python 中显示图像
- 从 WinPE 下的网络摄像头捕获?
- OpenCV没有显示来自Macbook网络摄像头的视频
- 使用OpenCV和C++在按键上截取网络摄像头源的屏幕截图
- 我正在尝试在树莓派中连接两个网络摄像头
- 使用 FFmpeg 编码和带有网络摄像头的 UDP
- TensorFlow OpenCV网络摄像头悬挂
- 使用来自视频文件或网络摄像头的 Kinect 面部跟踪
- OpenCV 将剪影与网络摄像头流隔离
- OpenCV-从C/C++中的默认网络摄像头获取图片-GTK问题
- 在 OpenCV 中,设置曝光会导致我的网络摄像头软件无法自动调整曝光
- 无法使用OpenCV从辅助网络摄像头读取VideoCapture中的帧
- 使用Opencv直接从网络摄像头获取灰度图像
- 使用Qt显示来自OpenCV的网络摄像头流