forked from floratest1/SpireCV
80 lines
1.5 KiB
C++
80 lines
1.5 KiB
C++
/*
|
|
* @Description:
|
|
* @Author: L LC @amov
|
|
* @Date: 2023-12-21 11:30:40
|
|
* @LastEditors: L LC @amov
|
|
* @LastEditTime: 2023-12-21 17:56:34
|
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_file.cpp
|
|
*/
|
|
#include "sv_camera_privately.h"
|
|
|
|
class sv_camera_FILE : public sv_p::CameraBase
|
|
{
|
|
private:
|
|
std::string _name = "\0";
|
|
|
|
public:
|
|
bool setName(const std::string &name);
|
|
|
|
virtual sv::CameraType getType(void) { return sv::CameraType::VIDEOFILE; }
|
|
std::string getName(void) { return this->_name; }
|
|
|
|
bool open(void);
|
|
bool read(cv::Mat &image)
|
|
{
|
|
return this->cap.read(image);
|
|
}
|
|
bool readNoBlock(cv::Mat &image)
|
|
{
|
|
return this->read(image);
|
|
}
|
|
|
|
sv_camera_FILE(int timeOut);
|
|
~sv_camera_FILE();
|
|
|
|
static CameraBase *creat(int timeOut)
|
|
{
|
|
return new sv_camera_FILE(timeOut);
|
|
}
|
|
};
|
|
|
|
sv_camera_FILE::sv_camera_FILE(int timeOut) : sv_p::CameraBase(timeOut)
|
|
{
|
|
}
|
|
|
|
bool sv_camera_FILE::setName(const std::string &name)
|
|
{
|
|
bool ret = false;
|
|
if (!this->cap.isOpened())
|
|
{
|
|
this->_name = name;
|
|
ret = true;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
bool sv_camera_FILE::open(void)
|
|
{
|
|
bool ret = false;
|
|
|
|
if (this->_name != "\0")
|
|
{
|
|
ret = this->cap.open(this->_name);
|
|
}
|
|
|
|
if (ret)
|
|
{
|
|
// 设置属性
|
|
this->setFps(this->getExpectFps());
|
|
this->setBrightness(this->getBrightness());
|
|
this->setContrast(this->getContrast());
|
|
this->setSaturation(this->getSaturation());
|
|
this->setHue(this->getHue());
|
|
this->setExposure(this->getExposure());
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|