Commit 0d65397a authored by Pavel Rojtberg's avatar Pavel Rojtberg Committed by Maksim Shabunin

videoio: remove cap_libv4l in favour of cap_v4l

cap_libv4l depends on an external library (libv4l) yet is still larger
(1966 loc vs 1822 loc).
It was initially introduced copy pasting cap_v4l in order to offload
various color conversions to libv4l.
However nowadays we handle most of the needed color conversions inside
OpenCV. Our own implementation is better tested and (probably) also
better performing. (as it can optionally leverage IPP/ OpenCL)

Currently cap_v4l is better maintained and generally the code is in
better shape. There is however an API
difference in getting unconverted frames:
* on cap_libv4l one need to set `CV_CAP_MODE_GRAY=1` or
`CV_CAP_MODE_YUYV=1`
* on cap_v4l one needs to set `CV_CAP_PROP_CONVERT_RGB=0`

the latter is more flexible though as it also allows accessing undecoded
JPEG images.

fixes #4563
parent 5459c11e
...@@ -259,7 +259,6 @@ OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF ...@@ -259,7 +259,6 @@ OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32 OR MINGW) ) OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32 OR MINGW) )
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) ) OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID AND NOT APPLE) ) OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID AND NOT APPLE) )
OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" OFF IF (UNIX AND NOT ANDROID AND NOT APPLE) )
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM AND NOT WINRT) ) OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM AND NOT WINRT) )
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" ON IF WIN32 ) OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" ON IF WIN32 )
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT WINRT) ) OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT WINRT) )
...@@ -1304,10 +1303,8 @@ if(APPLE) ...@@ -1304,10 +1303,8 @@ if(APPLE)
endif() endif()
endif() endif()
if(WITH_V4L OR WITH_LIBV4L OR HAVE_LIBV4L OR HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO) if(WITH_V4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
status(" libv4l/libv4l2:" HAVE_LIBV4L THEN "${ALIASOF_libv4l1_VERSION} / ${ALIASOF_libv4l2_VERSION}" ELSE "NO")
ocv_build_features_string(v4l_status ocv_build_features_string(v4l_status
IF HAVE_CAMV4L THEN "linux/videodev.h"
IF HAVE_CAMV4L2 THEN "linux/videodev2.h" IF HAVE_CAMV4L2 THEN "linux/videodev2.h"
IF HAVE_VIDEOIO THEN "sys/videoio.h" IF HAVE_VIDEOIO THEN "sys/videoio.h"
ELSE "NO") ELSE "NO")
......
...@@ -156,18 +156,8 @@ if(WITH_XINE) ...@@ -156,18 +156,8 @@ if(WITH_XINE)
endif(WITH_XINE) endif(WITH_XINE)
# --- V4L --- # --- V4L ---
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO) ocv_clear_vars(HAVE_CAMV4L2 HAVE_VIDEOIO)
if(WITH_V4L) if(WITH_V4L)
if(WITH_LIBV4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L1 VIDEOIO)
CHECK_MODULE(libv4l2 HAVE_LIBV4L2 VIDEOIO)
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
set(HAVE_LIBV4L YES)
else()
set(HAVE_LIBV4L NO)
endif()
endif()
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2) CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO) CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
endif(WITH_V4L) endif(WITH_V4L)
......
...@@ -116,9 +116,6 @@ ...@@ -116,9 +116,6 @@
/* GDCM DICOM codec */ /* GDCM DICOM codec */
#cmakedefine HAVE_GDCM #cmakedefine HAVE_GDCM
/* V4L/V4L2 capturing support via libv4l */
#cmakedefine HAVE_LIBV4L
/* Microsoft Media Foundation Capture library */ /* Microsoft Media Foundation Capture library */
#cmakedefine HAVE_MSMF #cmakedefine HAVE_MSMF
......
...@@ -62,12 +62,11 @@ yum install cmake ...@@ -62,12 +62,11 @@ yum install cmake
yum install python-devel numpy yum install python-devel numpy
yum install gcc gcc-c++ yum install gcc gcc-c++
@endcode @endcode
Next we need **GTK** support for GUI features, Camera support (libdc1394, libv4l), Media Support Next we need **GTK** support for GUI features, Camera support (libdc1394, v4l), Media Support
(ffmpeg, gstreamer) etc. (ffmpeg, gstreamer) etc.
@code{.sh} @code{.sh}
yum install gtk2-devel yum install gtk2-devel
yum install libdc1394-devel yum install libdc1394-devel
yum install libv4l-devel
yum install ffmpeg-devel yum install ffmpeg-devel
yum install gstreamer-plugins-base-devel yum install gstreamer-plugins-base-devel
@endcode @endcode
......
...@@ -66,12 +66,11 @@ sudo apt-get install python-devel numpy ...@@ -66,12 +66,11 @@ sudo apt-get install python-devel numpy
sudo apt-get install gcc gcc-c++ sudo apt-get install gcc gcc-c++
``` ```
Next we need **GTK** support for GUI features, Camera support (libv4l), Media Support Next we need **GTK** support for GUI features, Camera support (v4l), Media Support
(ffmpeg, gstreamer) etc. (ffmpeg, gstreamer) etc.
``` ```
sudo apt-get install gtk2-devel sudo apt-get install gtk2-devel
sudo apt-get install libv4l-devel
sudo apt-get install ffmpeg-devel sudo apt-get install ffmpeg-devel
sudo apt-get install gstreamer-plugins-base-devel sudo apt-get install gstreamer-plugins-base-devel
``` ```
......
...@@ -105,9 +105,7 @@ if(HAVE_GSTREAMER) ...@@ -105,9 +105,7 @@ if(HAVE_GSTREAMER)
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp) list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp)
endif(HAVE_GSTREAMER) endif(HAVE_GSTREAMER)
if(HAVE_LIBV4L) if(HAVE_CAMV4L2 OR HAVE_VIDEOIO)
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libv4l.cpp)
elseif(HAVE_CAMV4L2 OR HAVE_VIDEOIO)
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp) list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp)
endif() endif()
......
...@@ -89,7 +89,7 @@ See @ref videoio_overview for more information. ...@@ -89,7 +89,7 @@ See @ref videoio_overview for more information.
enum VideoCaptureAPIs { enum VideoCaptureAPIs {
CAP_ANY = 0, //!< Auto detect == 0 CAP_ANY = 0, //!< Auto detect == 0
CAP_VFW = 200, //!< Video For Windows (obsolete, removed) CAP_VFW = 200, //!< Video For Windows (obsolete, removed)
CAP_V4L = 200, //!< V4L/V4L2 capturing support via libv4l CAP_V4L = 200, //!< V4L/V4L2 capturing support
CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L
CAP_FIREWIRE = 300, //!< IEEE 1394 drivers CAP_FIREWIRE = 300, //!< IEEE 1394 drivers
CAP_FIREWARE = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE CAP_FIREWARE = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE
......
This diff is collapsed.
...@@ -82,7 +82,7 @@ static const struct VideoBackendInfo builtin_backends[] = ...@@ -82,7 +82,7 @@ static const struct VideoBackendInfo builtin_backends[] =
// Linux, some Unix // Linux, some Unix
#if defined HAVE_CAMV4L2 #if defined HAVE_CAMV4L2
DECLARE_BACKEND(CAP_V4L2, "V4L2", MODE_CAPTURE_ALL), DECLARE_BACKEND(CAP_V4L2, "V4L2", MODE_CAPTURE_ALL),
#elif defined HAVE_LIBV4L || defined HAVE_CAMV4L #elif defined HAVE_CAMV4L
DECLARE_BACKEND(CAP_V4L, "V4L", MODE_CAPTURE_ALL), DECLARE_BACKEND(CAP_V4L, "V4L", MODE_CAPTURE_ALL),
#endif #endif
...@@ -493,7 +493,7 @@ void VideoCapture_create(CvCapture*& capture, Ptr<IVideoCapture>& icap, VideoCap ...@@ -493,7 +493,7 @@ void VideoCapture_create(CvCapture*& capture, Ptr<IVideoCapture>& icap, VideoCap
default: default:
CV_LOG_WARNING(NULL, "VideoCapture(filename=" << filename << ") was built without support of requested backendID=" << (int)api); CV_LOG_WARNING(NULL, "VideoCapture(filename=" << filename << ") was built without support of requested backendID=" << (int)api);
break; break;
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO #if defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
case CAP_V4L: case CAP_V4L:
TRY_OPEN_LEGACY(cvCreateCameraCapture_V4L(filename.c_str())) TRY_OPEN_LEGACY(cvCreateCameraCapture_V4L(filename.c_str()))
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment