OpenCV編程->VideoCapture解析

首先看類的申明:

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; };
調用源碼如下:

	VideoCapture capture; 	capture.open(0);
capture.open(0)即是打開設備的端口號。

或者調用如下:

 std::string videoFile = "../test.avi";  cv::VideoCapture capture;  capture.open(videoFile);
檢測是否打開攝像頭或者視頻文件的函數,打開了返還true,沒打開返回false。
 CV_WRAP virtual bool isOpened() const;

介紹完了。。。。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章