diff --git a/include/sv_video_base.h b/include/sv_video_base.h index 5c20051..e9ee23c 100644 --- a/include/sv_video_base.h +++ b/include/sv_video_base.h @@ -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: diff --git a/video_io/sv_video_base.cpp b/video_io/sv_video_base.cpp index ea57b54..3a78973 100644 --- a/video_io/sv_video_base.cpp +++ b/video_io/sv_video_base.cpp @@ -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) diff --git a/video_io/sv_video_input.cpp b/video_io/sv_video_input.cpp index 5ca7bfa..4bdde60 100644 --- a/video_io/sv_video_input.cpp +++ b/video_io/sv_video_input.cpp @@ -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);