From 3c8e92e4f8398c6bffc525329418311eddc16e60 Mon Sep 17 00:00:00 2001 From: paul-shuvo Date: Wed, 28 Oct 2020 11:39:00 -0700 Subject: [PATCH 1/9] updated with appropriate opencv4 method names --- kinect2_bridge/src/kinect2_bridge.cpp | 24 +++++++++---------- .../src/kinect2_calibration.cpp | 2 +- kinect2_viewer/src/viewer.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kinect2_bridge/src/kinect2_bridge.cpp b/kinect2_bridge/src/kinect2_bridge.cpp index e5f43071..c3f1f483 100644 --- a/kinect2_bridge/src/kinect2_bridge.cpp +++ b/kinect2_bridge/src/kinect2_bridge.cpp @@ -461,12 +461,12 @@ class Kinect2Bridge void initCompression(const int32_t jpegQuality, const int32_t pngLevel, const bool use_png) { compressionParams.resize(7, 0); - compressionParams[0] = CV_IMWRITE_JPEG_QUALITY; + compressionParams[0] = cv::IMWRITE_JPEG_QUALITY; compressionParams[1] = jpegQuality; - compressionParams[2] = CV_IMWRITE_PNG_COMPRESSION; + compressionParams[2] = cv::IMWRITE_PNG_COMPRESSION; compressionParams[3] = pngLevel; - compressionParams[4] = CV_IMWRITE_PNG_STRATEGY; - compressionParams[5] = CV_IMWRITE_PNG_STRATEGY_RLE; + compressionParams[4] = cv::IMWRITE_PNG_STRATEGY; + compressionParams[5] = cv::IMWRITE_PNG_STRATEGY_RLE; compressionParams[6] = 0; if(use_png) @@ -1100,11 +1100,11 @@ class Kinect2Bridge cv::flip(color, tmp, 1); if(colorFrame->format == libfreenect2::Frame::BGRX) { - cv::cvtColor(tmp, images[COLOR_HD], CV_BGRA2BGR); + cv::cvtColor(tmp, images[COLOR_HD], cv::COLOR_BGRA2BGR); } else { - cv::cvtColor(tmp, images[COLOR_HD], CV_RGBA2BGR); + cv::cvtColor(tmp, images[COLOR_HD], cv::COLOR_RGBA2BGR); } } @@ -1180,11 +1180,11 @@ class Kinect2Bridge cv::flip(cv::Mat(sizeIr, CV_8UC4, registered.data), tmp, 1); if(color.format == libfreenect2::Frame::BGRX) { - cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_BGRA2BGR); + cv::cvtColor(tmp, images[COLOR_SD_RECT], cv::COLOR_BGRA2BGR); } else { - cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_RGBA2BGR); + cv::cvtColor(tmp, images[COLOR_SD_RECT], cv::COLOR_RGBA2BGR); } } @@ -1247,19 +1247,19 @@ class Kinect2Bridge // MONO if(status[MONO_HD]) { - cv::cvtColor(images[COLOR_HD], images[MONO_HD], CV_BGR2GRAY); + cv::cvtColor(images[COLOR_HD], images[MONO_HD], cv::COLOR_BGR2GRAY); } if(status[MONO_HD_RECT]) { - cv::cvtColor(images[COLOR_HD_RECT], images[MONO_HD_RECT], CV_BGR2GRAY); + cv::cvtColor(images[COLOR_HD_RECT], images[MONO_HD_RECT], cv::COLOR_BGR2GRAY); } if(status[MONO_QHD]) { - cv::cvtColor(images[COLOR_QHD], images[MONO_QHD], CV_BGR2GRAY); + cv::cvtColor(images[COLOR_QHD], images[MONO_QHD], cv::COLOR_BGR2GRAY); } if(status[MONO_QHD_RECT]) { - cv::cvtColor(images[COLOR_QHD_RECT], images[MONO_QHD_RECT], CV_BGR2GRAY); + cv::cvtColor(images[COLOR_QHD_RECT], images[MONO_QHD_RECT], cv::COLOR_BGR2GRAY); } } diff --git a/kinect2_calibration/src/kinect2_calibration.cpp b/kinect2_calibration/src/kinect2_calibration.cpp index 73d79576..39347e94 100644 --- a/kinect2_calibration/src/kinect2_calibration.cpp +++ b/kinect2_calibration/src/kinect2_calibration.cpp @@ -110,7 +110,7 @@ class Recorder circleFlags = cv::CALIB_CB_ASYMMETRIC_GRID + cv::CALIB_CB_CLUSTERING; } - params.push_back(CV_IMWRITE_PNG_COMPRESSION); + params.push_back(cv::IMWRITE_PNG_COMPRESSION); params.push_back(9); board.resize(boardDims.width * boardDims.height); diff --git a/kinect2_viewer/src/viewer.cpp b/kinect2_viewer/src/viewer.cpp index 26c170be..1eb0e0da 100644 --- a/kinect2_viewer/src/viewer.cpp +++ b/kinect2_viewer/src/viewer.cpp @@ -276,7 +276,7 @@ class Receiver combine(color, depthDisp, combined); //combined = color; - cv::putText(combined, oss.str(), pos, font, sizeText, colorText, lineText, CV_AA); + cv::putText(combined, oss.str(), pos, font, sizeText, colorText, lineText, cv::LINE_AA); cv::imshow("Image Viewer", combined); } From 31dc1c40535a79005710faa72bd7e6c1d07b9660 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 28 Oct 2020 12:09:20 -0700 Subject: [PATCH 2/9] added instructions for troubleshooting build errors --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7301fe3..62fad594 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # IAI Kinect2 -## Maintainer +### Maintainer - [Thiemo Wiedemeyer](https://ai.uni-bremen.de/team/thiemo_wiedemeyer) <>, [Institute for Artificial Intelligence](http://ai.uni-bremen.de/), University of Bremen ## Read this first +

__This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.__

+ Please read this README and the ones of the individual components throughly before asking questions. We get a lot of repeated questions, so when you have a problem, we urge everyone to check the [github issues (including closed ones)](https://github.com/code-iai/iai_kinect2/issues?utf8=%E2%9C%93&q=is%3Aissue). Your issue is very likely discussed there already. The goal of this project is to give you a driver and the tools needed to receive data from the Kinect-2 sensor, in a way useful for robotics. You will still need to know how to use ROS to make use of it. Please follow the [ROS tutorials](http://wiki.ros.org/ROS/Tutorials). You will also need to learn how to work with point-clouds, or depth-clouds, or images (computer vision) to do useful things with the data. @@ -128,6 +130,7 @@ If you found no solution in the issues, feel free to open a new issue for your p - OpenCL (optional, but recommended) - [libfreenect2](https://github.com/OpenKinect/libfreenect2) (>= v0.2.0, for stability checkout the latest stable release) + ## Install 1. Install the ROS. [Instructions for Ubuntu 14.04](http://wiki.ros.org/indigo/Installation/Ubuntu) @@ -149,6 +152,9 @@ If you found no solution in the issues, feel free to open a new issue for your p catkin_make -DCMAKE_BUILD_TYPE="Release" ``` +If you get the following error `pcl_conversions build error: PCL requires C++14 or above`, go to your `CMakeLists.txt` in the `src` folder and add the line `set( CMAKE_CXX_STANDARD 14)` +on the very top and rebuild. + *Note: `rosdep` will output errors on not being able to locate `[kinect2_bridge]` and `[depth_registration]`. That is fine because they are all part of the iai_kinect2 package and `rosdep` does not know these packages.* From 26a3437da879e90baa66068c97810ec2d6ee0992 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 28 Oct 2020 12:10:00 -0700 Subject: [PATCH 3/9] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62fad594..c9e5a7b9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Read this first -

__This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.__

+

This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.

Please read this README and the ones of the individual components throughly before asking questions. We get a lot of repeated questions, so when you have a problem, we urge everyone to check the [github issues (including closed ones)](https://github.com/code-iai/iai_kinect2/issues?utf8=%E2%9C%93&q=is%3Aissue). Your issue is very likely discussed there already. From b2d75989ae1de8e599938bdff59a05205c86d23c Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 28 Oct 2020 12:10:56 -0700 Subject: [PATCH 4/9] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9e5a7b9..410f11ed 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Read this first -

This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.

+__This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.__ Please read this README and the ones of the individual components throughly before asking questions. We get a lot of repeated questions, so when you have a problem, we urge everyone to check the [github issues (including closed ones)](https://github.com/code-iai/iai_kinect2/issues?utf8=%E2%9C%93&q=is%3Aissue). Your issue is very likely discussed there already. From 2c97efbf96986544e9c8ceb1594f21c4a1e81ca9 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 1 Feb 2021 18:05:49 -0800 Subject: [PATCH 5/9] updated readme --- README.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 410f11ed..a5eacd3c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ -# IAI Kinect2 +# IAI Kinect2 for OpenCV 4 -### Maintainer +### Maintainer of this fork +- [Shuvo Kumar Paul](https://github.com/paul-shuvo) + Email: shuvo.k.paul@gmail.com + +### Maintainer of IAI Kinect2 - [Thiemo Wiedemeyer](https://ai.uni-bremen.de/team/thiemo_wiedemeyer) <>, [Institute for Artificial Intelligence](http://ai.uni-bremen.de/), University of Bremen -## Read this first +## :warning: Read this first -__This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original repo.__ + > __This repository contains some minor changes from the original [iai_kinect2](https://github.com/code-iai/iai_kinect2) repo. Building from the original repo throws errors if you are using opencv4. This repo fixes those issues; also, if you're using any opencv version other than 4, please build from the original [repo](https://github.com/code-iai/iai_kinect2). For any difficulties open an [issue](https://github.com/paul-shuvo/iai_kinect2_opencv4/issues).__ Please read this README and the ones of the individual components throughly before asking questions. We get a lot of repeated questions, so when you have a problem, we urge everyone to check the [github issues (including closed ones)](https://github.com/code-iai/iai_kinect2/issues?utf8=%E2%9C%93&q=is%3Aissue). Your issue is very likely discussed there already. @@ -123,8 +127,8 @@ If you found no solution in the issues, feel free to open a new issue for your p ## Dependencies -- ROS Hydro/Indigo -- OpenCV (2.4.x, using the one from the official Ubuntu repositories is recommended) +- ROS Indigo/Jade/Melodic/Noetic +- OpenCV (4.x.x, using the one from the official Ubuntu repositories is recommended) - PCL (1.7.x, using the one from the official Ubuntu repositories is recommended) - Eigen (optional, but recommended) - OpenCL (optional, but recommended) @@ -133,7 +137,11 @@ If you found no solution in the issues, feel free to open a new issue for your p ## Install -1. Install the ROS. [Instructions for Ubuntu 14.04](http://wiki.ros.org/indigo/Installation/Ubuntu) +1. Install the ROS. + - [Instructions for Ubuntu 14.04](http://wiki.ros.org/indigo/Installation/Ubuntu) + - [Instructions for Ubuntu 16.04](http://wiki.ros.org/lunar/Installation/Ubuntu) + - [Instructions for Ubuntu 18.04](http://wiki.ros.org/melodic/Installation/Ubuntu) + - [Instructions for Ubuntu 20.04](http://wiki.ros.org/noetic/Installation/Ubuntu) 2. [Setup your ROS environment](http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment) 3. Install [libfreenect2](https://github.com/OpenKinect/libfreenect2): @@ -152,7 +160,7 @@ If you found no solution in the issues, feel free to open a new issue for your p catkin_make -DCMAKE_BUILD_TYPE="Release" ``` -If you get the following error `pcl_conversions build error: PCL requires C++14 or above`, go to your `CMakeLists.txt` in the `src` folder and add the line `set( CMAKE_CXX_STANDARD 14)` +> If you get the following error `pcl_conversions build error: PCL requires C++14 or above`, go to your `CMakeLists.txt` in the `src` folder and add the line `set( CMAKE_CXX_STANDARD 14)` on the very top and rebuild. *Note: `rosdep` will output errors on not being able to locate `[kinect2_bridge]` and `[depth_registration]`. From 6f1bccd4e02fffdb9fd88850f88174a29d83b9fb Mon Sep 17 00:00:00 2001 From: Martin Rudorfer Date: Tue, 18 Jan 2022 18:29:14 +0000 Subject: [PATCH 6/9] bugfix: checking for OpenCV4 version in calibration --- kinect2_calibration/src/kinect2_calibration.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kinect2_calibration/src/kinect2_calibration.cpp b/kinect2_calibration/src/kinect2_calibration.cpp index 39347e94..b68b2ee8 100644 --- a/kinect2_calibration/src/kinect2_calibration.cpp +++ b/kinect2_calibration/src/kinect2_calibration.cpp @@ -743,8 +743,8 @@ class CameraCalibration #if CV_MAJOR_VERSION == 2 error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, rotation, translation, essential, fundamental, termCriteria, cv::CALIB_FIX_INTRINSIC); -#elif CV_MAJOR_VERSION == 3 - error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 + error = cv::stereoCalibrate(poin tsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, rotation, translation, essential, fundamental, cv::CALIB_FIX_INTRINSIC, termCriteria); #endif OUT_INFO("re-projection error: " << error << std::endl); @@ -1091,7 +1091,7 @@ class DepthCalibration //cv::solvePnP(board, points[index], cameraMatrix, distortion, rvec, translation, false, cv::EPNP); #if CV_MAJOR_VERSION == 2 cv::solvePnPRansac(board, points[index], cameraMatrix, distortion, rvec, translation, false, 300, 0.05, board.size(), cv::noArray(), cv::ITERATIVE); -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 cv::solvePnPRansac(board, points[index], cameraMatrix, distortion, rvec, translation, false, 300, 0.05, 0.99, cv::noArray(), cv::SOLVEPNP_ITERATIVE); #endif cv::Rodrigues(rvec, rotation); From 226da180f0fed37219df6f05801d7d21c451f071 Mon Sep 17 00:00:00 2001 From: mrudorfer Date: Wed, 2 Mar 2022 11:37:39 +0000 Subject: [PATCH 7/9] bugfix: removed space in variable name --- kinect2_calibration/src/kinect2_calibration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kinect2_calibration/src/kinect2_calibration.cpp b/kinect2_calibration/src/kinect2_calibration.cpp index b68b2ee8..90fca3b4 100644 --- a/kinect2_calibration/src/kinect2_calibration.cpp +++ b/kinect2_calibration/src/kinect2_calibration.cpp @@ -744,7 +744,7 @@ class CameraCalibration error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, rotation, translation, essential, fundamental, termCriteria, cv::CALIB_FIX_INTRINSIC); #elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 - error = cv::stereoCalibrate(poin tsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, + error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, rotation, translation, essential, fundamental, cv::CALIB_FIX_INTRINSIC, termCriteria); #endif OUT_INFO("re-projection error: " << error << std::endl); From 8e50580eee0edde15ae64090bd1a2a84d0a28817 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 11 Apr 2023 09:14:09 -0700 Subject: [PATCH 8/9] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5eacd3c..ad0dc128 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ If you found no solution in the issues, feel free to open a new issue for your p ```bash cd ~/catkin_ws/src/ - git clone https://github.com/code-iai/iai_kinect2.git + git clone https://github.com/paul-shuvo/iai_kinect2.git cd iai_kinect2 rosdep install -r --from-paths . cd ~/catkin_ws From ccb76fa4d191c206719d21d03894ba84c2e09f8e Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 13 Apr 2023 14:51:54 -0700 Subject: [PATCH 9/9] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad0dc128..779bcbdd 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ If you found no solution in the issues, feel free to open a new issue for your p ```bash cd ~/catkin_ws/src/ - git clone https://github.com/paul-shuvo/iai_kinect2.git + git clone https://github.com/paul-shuvo/iai_kinect2_opencv4.git cd iai_kinect2 rosdep install -r --from-paths . cd ~/catkin_ws