Skip to content

Commit

Permalink
Opencv 3 compatibility (#564)
Browse files Browse the repository at this point in the history
* Remove GTK from image_view.

It is no longer used at all in image_view.

Signed-off-by: Chris Lalancette <[email protected]>

* Reinstate OpenCV 3 compatibility.

While Foxy only supports Ubuntu 20.04 (and hence OpenCV 4),
we still strive to maintain Ubuntu 18.04 (which has OpenCV 3).
In this case, it is trivial to keep keep image_pipeline working
with OpenCV 3, so reintroduce compatibility with it.

Signed-off-by: Chris Lalancette <[email protected]>

* Fixes from review.

Signed-off-by: Chris Lalancette <[email protected]>

* One more fix.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Jul 15, 2020
1 parent 8604154 commit 2e0c6d4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion image_proc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ find_package(rcutils REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(OpenCV 4 REQUIRED)
find_package(OpenCV REQUIRED)
if(OpenCV_VERSION VERSION_LESS "3.2.0")
message(FATAL "Minimum OpenCV version is 3.2.0 (found version ${OpenCV_VERSION})")
endif()
find_package(image_geometry REQUIRED)

include_directories(
Expand Down
5 changes: 5 additions & 0 deletions image_proc/src/crop_decimate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ void debayer2x2toBGR(
int R, int G1, int G2, int B)
{
typedef cv::Vec<T, 3> DstPixel; // 8- or 16-bit BGR
#if CV_VERSION_MAJOR >= 4
dst.create(src.rows / 2, src.cols / 2, cv::traits::Type<DstPixel>::value);
#else
// Assume OpenCV 3 API
dst.create(src.rows / 2, src.cols / 2, cv::DataType<DstPixel>::type);
#endif

int src_row_step = src.step1();
int dst_row_step = dst.step1();
Expand Down
3 changes: 1 addition & 2 deletions image_publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ set( DEPENDENCIES
cv_bridge
)

find_package(OpenCV REQUIRED COMPONENTS core)
find_package(OpenCV REQUIRED COMPONENTS core imgcodecs videoio)
message(STATUS "opencv version ${OpenCV_VERSION}")
find_package(OpenCV 4 REQUIRED COMPONENTS ${opencv_4_components})

include_directories(include)

Expand Down
5 changes: 0 additions & 5 deletions image_view/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ if(ANDROID)
return()
endif()

find_package(GTK3)
add_definitions(-DHAVE_GTK)
include_directories(${GTK3_INCLUDE_DIRS})

add_library(image_view_nodes SHARED
src/disparity_view_node.cpp
src/extract_images_node.cpp
Expand All @@ -56,7 +52,6 @@ ament_target_dependencies(image_view_nodes
stereo_msgs
)
target_link_libraries(image_view_nodes
${GTK3_LIBRARIES}
${OpenCV_LIBRARIES}
${Boost_LIBRARIES}
)
Expand Down
1 change: 0 additions & 1 deletion image_view/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

<depend>camera_calibration_parsers</depend>
<depend>cv_bridge</depend>
<depend>gtk3</depend>
<depend>image_transport</depend>
<depend>message_filters</depend>
<depend>rclcpp</depend>
Expand Down

0 comments on commit 2e0c6d4

Please sign in to comment.