从 openCV 中保存多个帧,并以时间作为其名称
Saving multiple frames from openCV with time as their name
我正在尝试编写一个代码来保存 openCV 视频流中的一些帧。 保存的图像的名称应该是时间: 这是我的代码:
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<conio.h>
#include <time.h>
using namespace cv;
using namespace std;
int main(){
int key = 0;
char dateStr[9];
char timeStr[9];
_strdate(dateStr);
_strtime(timeStr);
char buffer[20];
VideoCapture cap(1); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
namedWindow("image",1);
while(key!=27)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("image", frame);
if(key==13){
sprintf(buffer,"%s%s.tif",dateStr,timeStr);
imwrite(buffer,frame);
}
key = waitKey(1000);
}
destroyAllWindows();
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
当我运行它时,什么也没发生,我不止一次点击了 Enter 按钮,什么也没发生,顺便说一媒体太慢了。 任何想法!!.感谢您的帮助
2件事
:
流式传输速度很慢,因为您等待的时间太长。 更改 key = waitKey(1000);
中的值以更改程序的帧速率。
此外,如果您按回车键,则只会保存下一帧,而不会保存当前看到的帧。 应将该key = waitKey(1000);
语句移到if
语句之前。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 从持续时间构造std::chrono::system_clock::time_point
- 尝试导入pybind-opencv模块时出现libgtk错误
- OpenCV 函数 cv::remap() 的执行时间更长,当程序在两者之间进入睡眠状态时
- OpenCV的卡尔曼滤波器过渡矩阵如何处理时间(如t和t^2)进行运动预测?
- OpenCV 3.4 C++ Cuda 加速比 CPU 花费更多时间
- 如何使用OpenCV在视频中转到特定时间
- 如何使用opencv设置DMM 27UJ003-ML相机的曝光时间
- 从 openCV 中保存多个帧,并以时间作为其名称
- 如何在C++和OpenCV中测量KNN分类器训练的训练时间
- 视频的持续时间(OpenCV)
- opencv:检测最小矩形的时间复杂度
- iOS上的OpenCV:二进制大小、加载时间、速度等
- opencv 调整函数大小执行时间慢
- 在Windows 8.1上使用OpenCV在C++中加载图像需要很长时间
- opencv mat扫描随机时间窃取
- 按时间从视频中获取帧(openCV)
- OpenCV时间接触光流
- opencv转置第一次需要很长时间