视频读取,缓冲,处理,输出

在处理高帧率视频流如30fps时,如果图像处理速度无法匹配,需要采用缓冲机制来避免延迟。本文介绍了如何使用OpenCV的VedioCapture进行视频读取,并通过缓冲区设计,以应对图像处理速度不足的问题。文中提到了基于图漾双目相机的缓冲原理,但未给出详细代码,仅阐述了核心思想,包括枚举与switch的使用。此外,附录中提供了关于内存复制函数memcpy、虚函数以及SampleBuffer缓存队列的相关文章链接。
摘要由CSDN通过智能技术生成

目标:比如在利用双目处理视频流的情况下,车载摄像头一般可以达到30fps,而图像处理(基于双目的深度生成)却很难达到30fps的处理速度。这就需要缓冲机制。

以前,用过双目,目前只有一个罗技摄像头。

 

//由于处理速度有限,仅播放当前的,避免延迟;且需要存储上一时刻的,作为计算数据,
//实现方式:list一样建立缓冲区;
//有空再写吧



1.视频读取

#include<opencv2\opencv.hpp>
#include<iostream>
using namespace cv;
//using namespace std;
int main()
{
	VideoCapture capture(0);
	while (1)
	{
		Mat frame;
		capture >> frame;
		imshow("vedio shows", frame);
		waitKey(30);
	}
	return 0;
}

VedioCapture的类定义 

class CV_EXPORTS_W VideoCapture
{
public:
    CV_WRAP VideoCapture();
    CV_WRAP VideoCapture(const string& filename);
    CV_WRAP VideoCapture(int device);

    virtual ~VideoCapture();
    CV_WRAP virtual bool open(const string& filename);
    CV_WRAP virtual bool open(int device);
    CV_WRAP virtual bool isOpened() const;
    CV_WRAP virtual void release();

    CV_WRAP virtual bool grab();
    CV_WRAP virtual bool retrieve(CV_OUT Mat& image, int channel=0);
    virtual VideoCapture& operator >> (CV_OUT Mat& image);
    CV_WRAP virtual bool read(CV_OUT Mat& image);

    CV_WRAP virtual bool set(int propId, double value);
    CV_WRAP virtual double get(int propId);

protected:
    Ptr<CvCapture> cap;
};

2.缓冲

此处以图漾双目相机示例。c++ opencv2.4.9,不能运行,只是讲原理。图漾官网有示例程序可以运行

//声明把缓冲区数据复制到目标的CopyBuffer程序,后面有定义
void CopyBuffer(percipio::ImageBuffer *pbuf, cv::Mat &img);


//处理子程序,percipio为图漾的自带类
percipio::ImageBuffer pimage;   
//后面有定义,采用的structx形式,形式上和class类差不多,不过class权限默认是private࿰
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值