From 03447b7d3170bd9e391b06e79ca0066673c064dc Mon Sep 17 00:00:00 2001 From: PushyamiKaveti Date: Tue, 24 May 2022 10:43:34 -0400 Subject: [PATCH 1/4] works with ubtuntu 20.04. changes to opencv includes and function calls --- include/spinnaker_sdk_camera_driver/std_include.h | 1 - src/capture.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/spinnaker_sdk_camera_driver/std_include.h b/include/spinnaker_sdk_camera_driver/std_include.h index 24c196b..ca09ad6 100755 --- a/include/spinnaker_sdk_camera_driver/std_include.h +++ b/include/spinnaker_sdk_camera_driver/std_include.h @@ -6,7 +6,6 @@ #include "SpinGenApi/SpinnakerGenApi.h" // OpenCV -#include #include // ROS diff --git a/src/capture.cpp b/src/capture.cpp index 19c2660..bc6d1b6 100755 --- a/src/capture.cpp +++ b/src/capture.cpp @@ -997,7 +997,7 @@ void acquisition::Capture::run_soft_trig() { // Camera directories created at first save - if (LIVE_)namedWindow("Acquisition", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); + if (LIVE_)namedWindow("Acquisition", WINDOW_NORMAL | WINDOW_KEEPRATIO); int count = 0; @@ -1046,7 +1046,7 @@ void acquisition::Capture::run_soft_trig() { } } - int key = cvWaitKey(1); + int key = waitKey(1); ROS_DEBUG_STREAM("Key press: "<<(key & 255)< nframes_) { ROS_INFO_STREAM(nframes_ << " frames recorded. Terminating..."); - cvDestroyAllWindows(); + destroyAllWindows(); break; } } From 063742ba90bad2dcfce9643c516c579189d7e061 Mon Sep 17 00:00:00 2001 From: PushyamiKaveti Date: Thu, 16 Jun 2022 17:52:34 -0400 Subject: [PATCH 2/4] added way to choose corresponding opencv functions and includes based on the version found in CMakelists.txt --- CMakeLists.txt | 1 + include/spinnaker_sdk_camera_driver/capture.h | 1 - .../spinnaker_configure.h.in | 1 + .../spinnaker_sdk_camera_driver/std_include.h | 9 +++++++-- src/capture.cpp | 20 +++++++++++++++++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3df184f..787c565 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ find_package(trigger_msgs) find_package(Spinnaker REQUIRED) message("spinnaker lib : " ${Spinnaker_LIBRARIES}) find_package(OpenCV REQUIRED) + # use LibUnwind only for x86_64 or x86_32 architecture # do not use LibUnwind for arm architecture if(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64 OR x86_32) diff --git a/include/spinnaker_sdk_camera_driver/capture.h b/include/spinnaker_sdk_camera_driver/capture.h index 5539ed8..a0916ab 100755 --- a/include/spinnaker_sdk_camera_driver/capture.h +++ b/include/spinnaker_sdk_camera_driver/capture.h @@ -4,7 +4,6 @@ #include "std_include.h" #include "serialization.h" #include "camera.h" -#include "spinnaker_configure.h" #include #include //ROS diff --git a/include/spinnaker_sdk_camera_driver/spinnaker_configure.h.in b/include/spinnaker_sdk_camera_driver/spinnaker_configure.h.in index 3589f3b..57d57c7 100644 --- a/include/spinnaker_sdk_camera_driver/spinnaker_configure.h.in +++ b/include/spinnaker_sdk_camera_driver/spinnaker_configure.h.in @@ -1 +1,2 @@ #cmakedefine trigger_msgs_FOUND +#define OPENCV_VERSION @OpenCV_VERSION_MAJOR@ diff --git a/include/spinnaker_sdk_camera_driver/std_include.h b/include/spinnaker_sdk_camera_driver/std_include.h index ca09ad6..14432d6 100755 --- a/include/spinnaker_sdk_camera_driver/std_include.h +++ b/include/spinnaker_sdk_camera_driver/std_include.h @@ -4,9 +4,14 @@ // Spinnaker SDK #include "Spinnaker.h" #include "SpinGenApi/SpinnakerGenApi.h" - +#include "spinnaker_configure.h" // OpenCV -#include +#if (OPENCV_VERSION < 4) + #include +#else + #include +#endif + // ROS #include diff --git a/src/capture.cpp b/src/capture.cpp index bc6d1b6..3c97f3b 100755 --- a/src/capture.cpp +++ b/src/capture.cpp @@ -45,6 +45,7 @@ acquisition::Capture::Capture() { } void acquisition::Capture::onInit() { + cout<getNodeHandle(); nh_pvt_ = this->getPrivateNodeHandle(); @@ -996,8 +997,11 @@ void acquisition::Capture::run_soft_trig() { start_acquisition(); // Camera directories created at first save - +#if (OPENCV_VERSION < 4) + if (LIVE_)namedWindow("Acquisition", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); +#else if (LIVE_)namedWindow("Acquisition", WINDOW_NORMAL | WINDOW_KEEPRATIO); +#endif int count = 0; @@ -1045,8 +1049,11 @@ void acquisition::Capture::run_soft_trig() { displayOverlay("Acquisition", title); } } - +#if (OPENCV_VERSION < 4) + int key = cvWaitKey(1); +#else int key = waitKey(1); +#endif ROS_DEBUG_STREAM("Key press: "<<(key & 255)< nframes_) { ROS_INFO_STREAM(nframes_ << " frames recorded. Terminating..."); +#if (OPENCV_VERSION < 4) + cvDestroyAllWindows(); +#else destroyAllWindows(); +#endif break; } } From 657a22ce164c2d299caffeca6f77ebb4bf527309 Mon Sep 17 00:00:00 2001 From: vik748 Date: Sun, 19 Jun 2022 01:04:16 -0400 Subject: [PATCH 3/4] Fixes build issue for older versions of OpenCV and removes warning for non-void function. (#152) * Debug error on older versions * Add aliases * Add aliases 2 * Add aliases 3 * Add aliases 4 * Add alises 5 * Add aliases 7 * Add aliases 8 * ADD aliases 9 --- .../spinnaker_sdk_camera_driver/std_include.h | 5 +- src/camera.cpp | 10 +-- src/capture.cpp | 65 +++++++++---------- 3 files changed, 33 insertions(+), 47 deletions(-) diff --git a/include/spinnaker_sdk_camera_driver/std_include.h b/include/spinnaker_sdk_camera_driver/std_include.h index 14432d6..00eb2a1 100755 --- a/include/spinnaker_sdk_camera_driver/std_include.h +++ b/include/spinnaker_sdk_camera_driver/std_include.h @@ -8,10 +8,8 @@ // OpenCV #if (OPENCV_VERSION < 4) #include -#else - #include #endif - +#include // ROS #include @@ -48,7 +46,6 @@ #include - // gflags //#include diff --git a/src/camera.cpp b/src/camera.cpp index 9b7010c..31c7b3e 100755 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -88,14 +88,8 @@ int acquisition::Camera::get_frame_id() { Mat acquisition::Camera::grab_mat_frame() { - try{ - ImagePtr pResultImage = grab_frame(); - return convert_to_mat(pResultImage); - } - catch(Spinnaker::Exception &e){ - ros::shutdown(); - } - + ImagePtr pResultImage = grab_frame(); + return convert_to_mat(pResultImage); } diff --git a/src/capture.cpp b/src/capture.cpp index 3c97f3b..aff64fd 100755 --- a/src/capture.cpp +++ b/src/capture.cpp @@ -45,7 +45,7 @@ acquisition::Capture::Capture() { } void acquisition::Capture::onInit() { - cout<getNodeHandle(); nh_pvt_ = this->getPrivateNodeHandle(); @@ -958,25 +958,29 @@ void acquisition::Capture::get_mat_images() { int frameID; int fid_mismatch = 0; - - for (int i=0; i nframes_) { ROS_INFO_STREAM(nframes_ << " frames recorded. Terminating..."); -#if (OPENCV_VERSION < 4) - cvDestroyAllWindows(); -#else destroyAllWindows(); -#endif break; } } From 2708b541450d43251e6b47eac1bbdfa7e835c970 Mon Sep 17 00:00:00 2001 From: vik748 Date: Sat, 18 Jun 2022 22:19:22 -0700 Subject: [PATCH 4/4] Add Focal Noetic amd64 to travis --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6cc6b35..8ff3b06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ services: matrix: include: + - arch: amd64 + env : DOCKER_IMAGE=ros:noetic-perception-focal SPINNAKER_VERSION=2.6.0.160 - arch: amd64 env : DOCKER_IMAGE=ros:melodic-perception-bionic SPINNAKER_VERSION=2.0.0.147 - arch: amd64 @@ -18,7 +20,7 @@ matrix: - arch: arm64 env : DOCKER_IMAGE=arm64v8/ros:kinetic-perception-xenial SPINNAKER_VERSION=2.0.0.147 - arch: arm64 - env : DOCKER_IMAGE=arm64v8/ros:melodic-perception-bionic SPINNAKER_VERSION=2.0.0.147 + env : DOCKER_IMAGE=arm64v8/ros:melodic-perception-bionic SPINNAKER_VERSION=2.0.0.147 before_install: - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin