政务网站建设论文,android app开发教程,化妆品网站优化,搜索引擎怎么收录网站下面这行代码是获取摄像头每帧的时间戳#xff1a; double timestamp cap.get(cv::CAP_PROP_POS_MSEC); 改变帧率的方法是#xff1a;
cap.set(cv::CAP_PROP_FPS, 30); //帧率改为30
但是实际测试时发现帧率并未被改变#xff0c;这个可能和VideoCapture cap(cv::CAP_V…
下面这行代码是获取摄像头每帧的时间戳 double timestamp cap.get(cv::CAP_PROP_POS_MSEC); 改变帧率的方法是
cap.set(cv::CAP_PROP_FPS, 30); //帧率改为30
但是实际测试时发现帧率并未被改变这个可能和VideoCapture cap(cv::CAP_V4L2)有关cv::CAP_V4L2只是其中一种读取方法这个参数可能需要和相机采用的驱动方法有关。 编译
g camera_data.cpp -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio
#include iostream
#include string
#include sstream
#include fstream#include time.husing namespace std;// OpenCV includes
#include opencv2/core.hpp
#include opencv2/highgui.hpp
using namespace cv;int main(int argc, const char** argv)
{// 1.创建视频采集对象;VideoCapture cap(cv::CAP_V4L);// 2.打开默认相机;cap.open(0);int curFPScap.get(cv::CAP_PROP_FPS);cout FPS: curFPSendl;cap.set(cv::CAP_PROP_FPS, 30);int curFpsSetcap.get(cv::CAP_PROP_FPS);cout set FPS: curFpsSetendl;// 3.判断相机是否打开成功;if (!cap.isOpened())return -1;namedWindow(Video, 1);for (;;){// 获取新的一帧;Mat frame;double timestamp cap.get(cv::CAP_PROP_POS_MSEC);coutfixed;couttime: timestampendl;time_t end_time time(NULL);printf(ctime is %s\n,ctime(end_time)); //得到日历时间cap frame;if (frame.empty())return 0;// 显示新的帧;imshow(Video, frame);// cv::waitKey(1);// 按键退出显示;if (waitKey(3) 0) break;}// 5.释放视频采集对象;cap.release();return 0;
}