SpireCV/video_io/driver/sv_camera_streaming.cpp

75 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:57:22
* @FilePath: /SpireCV/video_io/driver/sv_camera_streaming.cpp
*/
#include "sv_camera_privately.h"
class sv_camera_Streaming : public sv_p::CameraBase
{
private:
std::string _name = "\0";
public:
bool setName(const std::string &name);
virtual sv::CameraType getType(void) { return sv::CameraType::STREAMING; }
std::string getName(void) { return this->_name; }
bool open(void);
sv_camera_Streaming(int timeOut);
~sv_camera_Streaming();
static CameraBase *creat(int timeOut)
{
return new sv_camera_Streaming(timeOut);
}
};
sv_camera_Streaming::sv_camera_Streaming(int timeOut) : sv_p::CameraBase(timeOut)
{
}
bool sv_camera_Streaming::setName(const std::string &name)
{
bool ret = false;
if (!this->cap.isOpened())
{
this->_name = name;
ret = true;
}
return ret;
}
bool sv_camera_Streaming::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());
// 开启读取线程
std::thread readLoop(&CameraBase::readThread, this);
this->readThreadHandle = readLoop.native_handle();
readLoop.detach();
}
return ret;
}