added support for V4L2CAM

This commit is contained in:
jario 2023-11-27 18:05:20 +08:00
parent ae21d40e2b
commit 4e4a479b08
3 changed files with 12 additions and 4 deletions

View File

@ -326,7 +326,7 @@ protected:
};
enum class CameraType {NONE, WEBCAM, G1, Q10, MIPI};
enum class CameraType {NONE, WEBCAM, V4L2CAM, G1, Q10, MIPI};
class CameraBase {
public:

View File

@ -1110,7 +1110,7 @@ void CameraBase::_run()
}
bool CameraBase::read(cv::Mat& image)
{
if (this->_type == CameraType::WEBCAM || this->_type == CameraType::G1 || this->_type == CameraType::MIPI)
if (this->_type != CameraType::NONE)
{
int n_try = 0;
while (n_try < 5000)

View File

@ -17,9 +17,17 @@ Camera::~Camera()
void Camera::openImpl()
{
if (this->_type == CameraType::WEBCAM)
if (this->_type == CameraType::WEBCAM || this->_type == CameraType::V4L2CAM)
{
this->_cap.open(this->_camera_id);
if (this->_type == CameraType::V4L2CAM)
{
this->_cap.open(this->_camera_id, cv::CAP_V4L2);
}
if (this->_type == CameraType::WEBCAM)
{
this->_cap.open(this->_camera_id);
}
if (this->_width > 0 && this->_height > 0)
{
this->_cap.set(cv::CAP_PROP_FRAME_WIDTH, this->_width);