C++ 使用C+;从多个网络摄像头捕获图片+;
我需要一个程序来捕获多个网络摄像头的图片,并将它们自动保存在Windows Vista中。我从你那里得到了基本代码。该代码在WindowsXP中运行,但当我在Vista上尝试使用它时,它会显示“失败”。每次执行时都会弹出不同的错误。如果我使用SDK平台会有帮助吗?有人有什么建议吗?我不能在多个网络摄像头上测试,因为我只有一个摄像头,但我确信我应该能够处理它。下面是一些示例代码(我使用Vista)和一个摄像头,让您开始使用C++ 使用C+;从多个网络摄像头捕获图片+;,c++,image,visual-c++,windows-vista,capture,C++,Image,Visual C++,Windows Vista,Capture,我需要一个程序来捕获多个网络摄像头的图片,并将它们自动保存在Windows Vista中。我从你那里得到了基本代码。该代码在WindowsXP中运行,但当我在Vista上尝试使用它时,它会显示“失败”。每次执行时都会弹出不同的错误。如果我使用SDK平台会有帮助吗?有人有什么建议吗?我不能在多个网络摄像头上测试,因为我只有一个摄像头,但我确信我应该能够处理它。下面是一些示例代码(我使用Vista)和一个摄像头,让您开始使用 #include <cv.h> #include <hi
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main()
{
// Start capturing on camera 0
VideoCapture cap(0);
if(!cap.isOpened()) return -1;
// This matrix will store the edges of the captured frame
Mat edges;
namedWindow("edges",1);
for(;;)
{
// Acquire the frame from cap into frame
Mat frame;
cap >> frame;
// Now, find the edges by converting to grayscale, blurring and then Canny edge detection
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
// Display the edges and the frame
imshow("edges", edges);
imshow("frame", frame);
// Terminate by pressing a key
if(waitKey(30) >= 0) break;
}
return 0;
}
如果程序在UAC关闭或运行administrator时工作,请确保选择保存结果的位置位于可写位置,如用户的“我的文档”文件夹。一般来说,根文件夹和程序文件文件夹对于普通用户是只读的
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main()
{
VideoCapture cap(0);
if(!cap.isOpened()) return -1;
for(;;)
{
Mat frame;
cap >> frame;
imshow("frame", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}