opencv读取摄像头实时流代码:

 #include <opencv2/opencv.hpp>
#include <iostream> using namespace cv;
using namespace std; int main()
{
VideoCapture inputCamera;
string videoStreamAddress = "此处填写摄像机的URL";
inputCamera.open(videoStreamAddress); if (!inputCamera.isOpened())
{
cout << "摄像头打开失败!" << endl;
return false;
} // obtain the video parameters
int rate = inputCamera.get(CV_CAP_PROP_FPS); //the rate of video frame
int frameHeight = inputCamera.get(CV_CAP_PROP_FRAME_HEIGHT); // the height of video frame
int frameWidth = inputCamera.get(CV_CAP_PROP_FRAME_WIDTH); // the width of video frame Mat cutImage;
char c;
while (true)
{
inputCamera >> cutImage; imshow("cutImage", cutImage); c = waitKey();
if (c == ) break;
} return ;
}
04-14 12:27