Skip to content

Commit 75c2fed

Browse files
authored
Merge pull request #60 from stereolabs/add_zedcameraone_support
Add zedcameraone support
2 parents 04fb779 + 62e2a72 commit 75c2fed

19 files changed

+1593
-5853
lines changed

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@
9191
"__tree": "cpp",
9292
"queue": "cpp",
9393
"stack": "cpp",
94-
"locale": "cpp"
94+
"locale": "cpp",
95+
"*.ipp": "cpp",
96+
"ranges": "cpp",
97+
"__node_handle": "cpp",
98+
"filesystem": "cpp",
99+
"__bit_reference": "cpp",
100+
"__functional_03": "cpp",
101+
"__mutex_base": "cpp"
95102
},
96103
"C_Cpp.errorSquiggles": "disabled",
97104
"editor.tabSize": 4

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
LATEST CHANGES
22
==============
33

4+
2024-12-03
5+
----------
6+
- The `zedxonesrc` element now uses the ZED SDK object `sl::CameraOne` instead of the `zedx-one-capture` library
7+
8+
* ZED X One images are now automatically rectified
9+
* ZED X One IMU data can be retrieved as image metadata
10+
* ZED X One 4K supports HDR mode
11+
412
2024-04-23
513
----------
614
- Add new `zedxonesrc` element to get ZED X One color stream and control the camera

README.md

Lines changed: 174 additions & 176 deletions
Large diffs are not rendered by default.

gst-zed-demux/gstzeddemux.cpp

Lines changed: 402 additions & 184 deletions
Large diffs are not rendered by default.

gst-zed-demux/gstzeddemux.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ struct _GstZedDemux {
4040

4141
GstPad *sinkpad;
4242
GstPad *srcpad_left;
43+
GstPad *srcpad_mono;
4344
GstPad *srcpad_aux;
4445
GstPad *srcpad_data;
4546

4647
GstCaps *caps_left;
48+
GstCaps *caps_mono;
4749
GstCaps *caps_aux;
4850

4951
gboolean is_depth;
52+
gboolean is_mono;
5053
gboolean stream_data;
5154
};
5255

gst-zed-src/gstzedsrc.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,8 +2165,9 @@ static gboolean gst_zedsrc_calculate_caps(GstZedSrc *src) {
21652165
}
21662166

21672167
static gboolean gst_zedsrc_start(GstBaseSrc *bsrc) {
2168-
#if (ZED_SDK_MAJOR_VERSION < 4)
2169-
GST_ELEMENT_ERROR(src, LIBRARY, FAILED, ("Wrong ZED SDK version. SDK v4.0.x required "),
2168+
#if (ZED_SDK_MAJOR_VERSION != 4 && ZED_SDK_MINOR_VERSION != 2 && ZED_SDK_SUB_VERSION != 2)
2169+
GST_ELEMENT_ERROR(src, LIBRARY, FAILED,
2170+
("Wrong ZED SDK version. SDK v4.2.2 required "),
21702171
(NULL));
21712172
#endif
21722173

@@ -2724,26 +2725,36 @@ static GstFlowReturn gst_zedsrc_fill(GstPushSrc *psrc, GstBuffer *buf) {
27242725
sl::Mat depth_data;
27252726

27262727
// ----> Mats retrieving
2728+
auto check_ret = [src](sl::ERROR_CODE ret) {
2729+
if (ret != sl::ERROR_CODE::SUCCESS) {
2730+
GST_ELEMENT_ERROR(src, RESOURCE, FAILED,
2731+
("Grabbing failed with error: '%s' - %s", sl::toString(ret).c_str(),
2732+
sl::toVerbose(ret).c_str()),
2733+
(NULL));
2734+
return false;
2735+
}
2736+
return true;
2737+
};
2738+
27272739
if (src->stream_type == GST_ZEDSRC_ONLY_LEFT) {
27282740
ret = src->zed.retrieveImage(left_img, sl::VIEW::LEFT, sl::MEM::CPU);
2741+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27292742
} else if (src->stream_type == GST_ZEDSRC_ONLY_RIGHT) {
27302743
ret = src->zed.retrieveImage(left_img, sl::VIEW::RIGHT, sl::MEM::CPU);
2744+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27312745
} else if (src->stream_type == GST_ZEDSRC_LEFT_RIGHT) {
27322746
ret = src->zed.retrieveImage(left_img, sl::VIEW::LEFT, sl::MEM::CPU);
2747+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27332748
ret = src->zed.retrieveImage(right_img, sl::VIEW::RIGHT, sl::MEM::CPU);
2749+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27342750
} else if (src->stream_type == GST_ZEDSRC_DEPTH_16) {
27352751
ret = src->zed.retrieveMeasure(depth_data, sl::MEASURE::DEPTH_U16_MM, sl::MEM::CPU);
2752+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27362753
} else if (src->stream_type == GST_ZEDSRC_LEFT_DEPTH) {
27372754
ret = src->zed.retrieveImage(left_img, sl::VIEW::LEFT, sl::MEM::CPU);
2755+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27382756
ret = src->zed.retrieveMeasure(depth_data, sl::MEASURE::DEPTH, sl::MEM::CPU);
2739-
}
2740-
2741-
if (ret != sl::ERROR_CODE::SUCCESS) {
2742-
GST_ELEMENT_ERROR(src, RESOURCE, FAILED,
2743-
("Grabbing failed with error: '%s' - %s", sl::toString(ret).c_str(),
2744-
sl::toVerbose(ret).c_str()),
2745-
(NULL));
2746-
return GST_FLOW_ERROR;
2757+
if(!check_ret(ret)) return GST_FLOW_ERROR;
27472758
}
27482759
// <---- Mats retrieving
27492760

@@ -2910,7 +2921,7 @@ static GstFlowReturn gst_zedsrc_fill(GstPushSrc *psrc, GstBuffer *buf) {
29102921
rt_params.object_class_detection_confidence_threshold = class_det_conf;
29112922

29122923
sl::Objects det_objs;
2913-
sl::ERROR_CODE ret = src->zed.retrieveObjects(det_objs, rt_params, OD_INSTANCE_MODULE_ID);
2924+
ret = src->zed.retrieveObjects(det_objs, rt_params, OD_INSTANCE_MODULE_ID);
29142925

29152926
if (ret == sl::ERROR_CODE::SUCCESS) {
29162927
if (det_objs.is_new) {
@@ -3004,7 +3015,7 @@ static GstFlowReturn gst_zedsrc_fill(GstPushSrc *psrc, GstBuffer *buf) {
30043015
rt_params.skeleton_smoothing = src->bt_rt_skel_smoothing;
30053016

30063017
sl::Bodies bodies;
3007-
sl::ERROR_CODE ret = src->zed.retrieveBodies(bodies, rt_params, BT_INSTANCE_MODULE_ID);
3018+
ret = src->zed.retrieveBodies(bodies, rt_params, BT_INSTANCE_MODULE_ID);
30083019

30093020
if (ret == sl::ERROR_CODE::SUCCESS) {
30103021
if (bodies.is_new) {

gst-zedxone-src/CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@ endif()
1414

1515
add_definitions(-Werror=return-type)
1616

17-
set(libname gstzedxonesrc)
17+
option(LINK_SHARED_ZED "Link with the ZED SDK shared executable" ON)
18+
19+
if(NOT LINK_SHARED_ZED AND MSVC)
20+
message(FATAL_ERROR "LINK_SHARED_ZED OFF : ZED SDK static libraries not available on Windows")
21+
endif()
22+
23+
include_directories(${CUDA_INCLUDE_DIRS})
24+
include_directories(${ZED_INCLUDE_DIRS})
25+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
26+
27+
link_directories(${ZED_LIBRARY_DIR})
28+
link_directories(${CUDA_LIBRARY_DIRS})
29+
link_directories(${LIBRARY_INSTALL_DIR})
1830

19-
add_subdirectory(lib)
31+
set(libname gstzedxonesrc)
2032

2133
set(SOURCES
2234
gstzedxonesrc.cpp
@@ -26,10 +38,6 @@ set(HEADERS
2638
gstzedxonesrc.h
2739
)
2840

29-
link_directories(
30-
${LIBRARY_INSTALL_DIR}
31-
)
32-
3341
message( " * ${libname} plugin added")
3442

3543
add_library(${libname} MODULE
@@ -47,7 +55,14 @@ else()
4755
add_definitions(-O2)
4856
endif()
4957

50-
add_dependencies (${libname} zedarguscapture)
58+
SET(ZED_LIBS
59+
${ZED_LIBRARIES}
60+
${CUDA_CUDA_LIBRARY}
61+
${CUDA_CUDART_LIBRARY}
62+
${CUDA_NPP_LIBRARIES_ZED}
63+
)
64+
65+
add_dependencies (${libname} gstzedmeta)
5166

5267
target_link_libraries (
5368
${libname} LINK_PUBLIC
@@ -56,7 +71,8 @@ target_link_libraries (
5671
${GSTREAMER_LIBRARY}
5772
${GSTREAMER_BASE_LIBRARY}
5873
${GSTREAMER_VIDEO_LIBRARY}
59-
${CMAKE_CURRENT_BINARY_DIR}/lib/libzedarguscapture.so
74+
${ZED_LIBS}
75+
${CMAKE_CURRENT_BINARY_DIR}/../gst-zed-meta/libgstzedmeta.so
6076
)
6177

6278
install(TARGETS ${libname} LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR})

0 commit comments

Comments
 (0)