目标:比如在利用双目处理视频流的情况下,车载摄像头一般可以达到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