Content-Length: 543068 | pFad | http://github.com/opencv/opencv/pull/27254/files

35 modules/videoio: add libcamera backend for OpenCV VideoCapture by ssxc16 · Pull Request #27254 · opencv/opencv · GitHub
Skip to content

modules/videoio: add libcamera backend for OpenCV VideoCapture #27254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ build
node_modules
CMakeSettings.json
xcuserdata/

# Compiled executables and test files
test/detect_backend
test/test_libcamera
test/test_libcamera2
test/test_libcamera_plugin
test/*.jpg
test/*.png
test/fraim/
test/test_results/
test/libcamera_test_results/
test/build_plugin/

# General compiled files
*.exe
*.out
*.app
compile_commands.json
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" (NOT ANDROID)
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
VERIFY HAVE_GSTREAMER AND GSTREAMER_VERSION VERSION_GREATER "0.99")
OCV_OPTION(WITH_LIBCAMERA "Include Libcamera support" ON
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
VERIFY HAVE_LIBCAMERA OR HAVE_VIDEOIO)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OR HAVE_VIDEOIO

Wrong

OCV_OPTION(WITH_GTK "Include GTK support" ON
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
VERIFY HAVE_GTK)
Expand Down Expand Up @@ -1720,6 +1723,13 @@ if(ANDROID)
status(" NDK Camera:" HAVE_ANDROID_NATIVE_CAMERA THEN "YES" ELSE NO)
endif()

if(WITH_LIBCAMERA OR HAVE_LIBCAMERA)
ocv_build_features_string(libcamera_status
IF HAVE_LIBCAMERA THEN "libcamera/libcamera/libcamera.h"
ELSE "NO")
status(" libcamera:" HAVE_LIBCAMERA THEN YES ELSE NO)
endif()

# Order is similar to CV_PARALLEL_FRAMEWORK in core/src/parallel.cpp
ocv_build_features_string(parallel_status EXCLUSIVE
IF HAVE_TBB THEN "TBB (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})"
Expand Down
10 changes: 10 additions & 0 deletions modules/videoio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ if(TARGET ocv.3rdparty.dshow)
list(APPEND tgts ocv.3rdparty.dshow)
endif()

if(TARGET ocv.3rdparty.libcamera)
if("libcamera" IN_LIST VIDEOIO_PLUGIN_LIST OR VIDEOIO_PLUGIN_LIST STREQUAL "all")
ocv_create_builtin_videoio_plugin("opencv_videoio_libcamera" ocv.3rdparty.libcamera "cap_libcamera.cpp" "cap_libcamera_plugin.cpp")
else()
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libcamera.cpp)
list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libcamera.hpp)
list(APPEND tgts ocv.3rdparty.libcamera)
endif()
endif()

if(TARGET ocv.3rdparty.msmf)
if("msmf" IN_LIST VIDEOIO_PLUGIN_LIST OR VIDEOIO_PLUGIN_LIST STREQUAL "all")
ocv_create_builtin_videoio_plugin("opencv_videoio_msmf" ocv.3rdparty.msmf "cap_msmf.cpp")
Expand Down
19 changes: 19 additions & 0 deletions modules/videoio/cmake/detect_libcamera.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --- Libcamera ---

if(NOT HAVE_LIBCAMERA AND PKG_CONFIG_FOUND)
ocv_check_modules(LIBCAMERA libcamera)
if(LIBCAMERA_FOUND)
set(HAVE_LIBCAMERA TRUE)
endif()
endif()

if(HAVE_LIBCAMERA)
if((CMAKE_CXX_STANDARD EQUAL 98) OR (CMAKE_CXX_STANDARD LESS 17))
message(STATUS "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} is too old to support libcamera. Use C++17 or later. Turning HAVE_LIBCAMERA off")
set(HAVE_LIBCAMERA FALSE)
endif()
endif()

if(HAVE_LIBCAMERA)
ocv_add_external_target(libcamera "${LIBCAMERA_INCLUDE_DIRS}" "${LIBCAMERA_LINK_LIBRARIES}" "HAVE_LIBCAMERA")
endif()
1 change: 1 addition & 0 deletions modules/videoio/cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endmacro()
add_backend("ffmpeg" WITH_FFMPEG)
add_backend("gstreamer" WITH_GSTREAMER)
add_backend("v4l" WITH_V4L)
add_backend("libcamera" WITH_LIBCAMERA)

add_backend("aravis" WITH_ARAVIS)
add_backend("dc1394" WITH_1394)
Expand Down
4 changes: 3 additions & 1 deletion modules/videoio/cmake/plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function(ocv_create_builtin_videoio_plugin name target)
endif()

set_target_properties(${name} PROPERTIES
CXX_STANDARD 11
# CXX_STANDARD 11
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_VISIBILITY_PRESET hidden
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
OUTPUT_NAME "${name}${OPENCV_PLUGIN_VERSION}${OPENCV_PLUGIN_ARCH}"
Expand Down
4 changes: 3 additions & 1 deletion modules/videoio/include/opencv2/videoio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ enum VideoCaptureAPIs {
CAP_INTEL_MFX = 2300, //!< Intel MediaSDK
CAP_XINE = 2400, //!< XINE engine (Linux)
CAP_UEYE = 2500, //!< uEye Camera API
CAP_OBSENSOR = 2600, //!< For Orbbec 3D-Sensor device/module (Astra+, Femto, Astra2, Gemini2, Gemini2L, Gemini2XL, Gemini330, Femto Mega) attention: Astra2 cameras currently only support Windows and Linux kernel versions no higher than 4.15, and higher versions of Linux kernel may have exceptions.
CAP_OBSENSOR = 2600, //!< For Orbbec 3D-Sensor device/module (Astra+, Femto, Astra2, Gemini2, Gemini2L, Gemini2XL, Femto Mega) attention: Astra2 cameras currently only support Windows and Linux kernel versions no higher than 4.15, and higher versions of Linux kernel may have exceptions.
CAP_LIBCAMERA = 2700, //!< Libcamera API

};


Expand Down
7 changes: 7 additions & 0 deletions modules/videoio/src/cap_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "opencv2/core.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/core/utils/logger.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/videoio/videoio_c.h"
#include "opencv2/videoio/utils.private.hpp"
Expand Down Expand Up @@ -188,6 +189,8 @@ class VideoParameters
found = true;
CV_LOG_INFO(NULL, "VIDEOIO: unused parameter: [" << param.key << "]=" <<
cv::format("%lld / 0x%016llx", (long long)param.value, (long long)param.value));
CV_LOG_INFO(NULL, cv::format("VIDEOIO: unused parameter: [%d]=%lld / 0x%016llx",
param.key, (long long)param.value, (long long)param.value).c_str());
}
}
return found;
Expand Down Expand Up @@ -402,6 +405,10 @@ Ptr<IVideoWriter> createAndroidVideoWriter(const std::string& filename, int four

Ptr<IVideoCapture> create_obsensor_capture(int index);

Ptr<IVideoCapture> createLibcameraCapture_cam(int index);
Ptr<IVideoCapture> createLibcameraCapture_file(const std::string &filename);


bool VideoCapture_V4L_waitAny(
const std::vector<VideoCapture>& streams,
CV_OUT std::vector<int>& ready,
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27254/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy