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 and Joshua Whitley committed Jul 15, 2020
1 parent 5ae707d commit 0153ede
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 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 3 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
7 changes: 4 additions & 3 deletions image_proc/src/crop_decimate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +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_MAJOR_VERSION >= 3 && CV_MINOR_VERSION > 2
#if CV_VERSION_MAJOR >= 4
dst.create(src.rows / 2, src.cols / 2, cv::traits::Type<DstPixel>::value);
#else
#else
// Assume OpenCV 3 API
dst.create(src.rows / 2, src.cols / 2, cv::DataType<DstPixel>::type);
#endif
#endif

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

set(opencv_2_components core highgui)
set(opencv_3_components core imgcodecs videoio)
find_package(OpenCV REQUIRED COMPONENTS core)
find_package(OpenCV REQUIRED COMPONENTS core imgcodecs videoio)
message(STATUS "opencv version ${OpenCV_VERSION}")
if(OpenCV_VERSION VERSION_LESS "3.0.0")
find_package(OpenCV 2 REQUIRED COMPONENTS ${opencv_2_components})
else()
find_package(OpenCV 3 REQUIRED COMPONENTS ${opencv_3_components})
endif()

include_directories(include)

Expand Down
6 changes: 0 additions & 6 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(GTK2)
add_definitions(-DHAVE_GTK)
include_directories(${GTK2_INCLUDE_DIRS})

add_library(image_view_nodes SHARED
src/disparity_view_node.cpp
src/extract_images_node.cpp
Expand All @@ -56,8 +52,6 @@ ament_target_dependencies(image_view_nodes
stereo_msgs
)
target_link_libraries(image_view_nodes
${GTK_LIBRARIES}
${GTK2_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>gtk2</depend>
<depend>image_transport</depend>
<depend>message_filters</depend>
<depend>rclcpp</depend>
Expand Down

0 comments on commit 0153ede

Please sign in to comment.