访问视频的每一帧并对其进行处理
accessing each frame of video and processing it
我正在尝试编写一个程序,该程序使用带有CPP OPENCV
将视频文件的每一帧存储为图像。我已经通过ffmpeg
和mplayer
实现了这一目标。我想使用 OPENCV
.谁能帮忙?除了IMWRITE()
之外,还有其他功能可以将图像存储到文件中吗?
OPENCV
是否有任何功能可以获取设备特定端口上可用的视频实时流并实时处理? 即将每一帧流存储为图像?谁能帮我?
提前感谢..:)
保存所有带有递增编号文件名的图像,这对我有用:
const char* videofilename = "StopMoti2001.mpeg";
cv::VideoCapture cap(videofilename); // open a video file
if(!cap.isOpened()) // check if succeeded
{
std::cout << "file " << videofilename << " not found or could not be opened" << std::endl;
return;
}
cv::namedWindow("output");
unsigned long counter = 0;
cv::Mat frame;
// read frames until end of video:
while(cap.read(frame))
{
// display frame
cv::imshow("output", frame); cv::waitKey(25); // remove this line if you don't need the live output
// adjust the filename by incrementing a counter
std::stringstream filename (std::stringstream::in | std::stringstream::out);
filename << "image" << counter++ << ".jpg";
std::cout << "writing " << filename.str().c_str() << " to disk" << std::endl;
// save frame to file: image0.jpg, image1.jpg, and so on...
cv::imwrite(filename.str().c_str(),frame);
}
相关文章:
- gdb错误:Backtrace已停止:上一帧与此帧相同(堆栈已损坏?)
- 如何检测是否在缓冲绘画动画中绘制最后一帧?
- C++ 尝试优化每一帧将数据打印到二进制文件
- 当我在每一帧中多次使用正则表达式时,FPS 下降了
- 为什么除了最后一帧之外,每一帧都没有调用命令
- WinApi 在每一帧中绘制
- 如何确保文件在生成中仅处理一次
- 异常处理.一个人如何抛出迭代器
- Opencv 视频帧.我只能看到最后一帧
- OpenCV IOS Swift 2:如何实现 CvVideoCameraDelegate 协议处理视频帧
- 访问视频的每一帧并对其进行处理
- 如何处理一个子类有方法,而另一个没有方法的子类?
- Qt:显示实时视频,一次一帧
- Haar检测-保存图像的Mat,以便获得并显示前一帧
- 你将如何使用二维来处理一维内存
- OpenCV - 如何在局域网中的单独主机中处理视频的每一帧
- 在Qt/QML中的每一帧更新图像时运行时崩溃
- 设置GL_TEXTURE_MAX_ANISOTROPY_EXT会导致下一帧崩溃
- 在计算了一帧的SIFT或ORB之后,如何实时跟踪视频中的对象
- gstreamermm:如何提取 Gst::P layBin 的最后一帧视频