diff --git a/README.md b/README.md index f7301fe3..779bcbdd 100644 --- a/README.md +++ b/README.md @@ -1,10 +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](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. @@ -121,16 +127,21 @@ 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) - [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) +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): @@ -142,13 +153,16 @@ 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_opencv4.git cd iai_kinect2 rosdep install -r --from-paths . cd ~/catkin_ws 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.* 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..90fca3b4 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); @@ -743,7 +743,7 @@ 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 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor, rotation, translation, essential, fundamental, cv::CALIB_FIX_INTRINSIC, termCriteria); #endif @@ -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); 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); }