ubuntu18.04安装kinect驱动

https://github.com/OpenKinect/libfreenect2

 opencv4.5

首先安装依赖

安装工具
sudo apt-get install build-essential cmake pkg-config 
安装libusb
sudo apt-get install libusb-1.0-0-dev
安装TurboJPEG
sudo apt-get install libturbojpeg0-dev 
sudo apt-get intsall libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev
安装OpenGL
sudo apt-get install libglfw3-dev
安装OpenNI2
sudo apt-get install libopenni2-dev

 

安装
sudo apt-get install beignet-dev

 

 

 

 

git clone https://github.com/OpenKinect/libfreenect2.git

 

cd libfreenect2
mkdir build 
cd build
cmake ..
make
sudo make install

 

sudo cp libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

 

进入build目录

./bin/Protonect

查看测试

 

 

安装 iai_kinect2

cd ~/catkin_ws/src/
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .

如果这里出错则

rosdep install --from-paths . --ignore-src -r

然后编译

 

该类错误之需要将 CV_IMWRITE_PNG_COMPRESSION  改为cv::IMWRITE_PNG_COMPRESSION  即可

/home/miao/catkin_ws/src/iai_kinect2/kinect2_calibration/src/kinect2_calibration.cpp: In constructor ‘Recorder::Recorder(const string&, const string&, const string&, const string&, Source, bool, bool, const Size&, float)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_calibration/src/kinect2_calibration.cpp:113:22: error: ‘CV_IMWRITE_PNG_COMPRESSION’ was not declared in this scope
     params.push_back(CV_IMWRITE_PNG_COMPRESSION);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::initCompression(int32_t, int32_t, bool)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:464:28: error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope
     compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:466:28: error: ‘CV_IMWRITE_PNG_COMPRESSION’ was not declared in this scope
     compressionParams[2] = CV_IMWRITE_PNG_COMPRESSION;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:468:28: error: ‘CV_IMWRITE_PNG_STRATEGY’ was not declared in this scope
     compressionParams[4] = CV_IMWRITE_PNG_STRATEGY;
                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:469:28: error: ‘CV_IMWRITE_PNG_STRATEGY_RLE’ was not declared in this scope
     compressionParams[5] = CV_IMWRITE_PNG_STRATEGY_RLE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::initCompression(int32_t, int32_t, bool)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:464:28: error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope
     compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:466:28: error: ‘CV_IMWRITE_PNG_COMPRESSION’ was not declared in this scope
     compressionParams[2] = CV_IMWRITE_PNG_COMPRESSION;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:468:28: error: ‘CV_IMWRITE_PNG_STRATEGY’ was not declared in this scope
     compressionParams[4] = CV_IMWRITE_PNG_STRATEGY;
                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:469:28: error: ‘CV_IMWRITE_PNG_STRATEGY_RLE’ was not declared in this scope
     compressionParams[5] = CV_IMWRITE_PNG_STRATEGY_RLE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

这个错误需要添加头文件#include <opencv2/imgproc/imgproc.hpp>   #include <opencv2/imgproc/types_c.h>

/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::receiveColor()’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1103:45: error: ‘CV_BGRA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_HD], CV_BGRA2BGR);
                                             ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1107:45: error: ‘CV_RGBA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_HD], CV_RGBA2BGR);
                                             ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1107:45: note: suggested alternative: ‘CV_RGB’
         cv::cvtColor(tmp, images[COLOR_HD], CV_RGBA2BGR);
                                             ^~~~~~~~~~~
                                             CV_RGB
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::processIrDepth(const cv::Mat&, std::vector<cv::Mat>&, const std::vector<Kinect2Bridge::Status>&)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1183:50: error: ‘CV_BGRA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_BGRA2BGR);
                                                  ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1187:50: error: ‘CV_RGBA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_RGBA2BGR);
                                                  ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1187:50: note: suggested alternative: ‘CV_RGB’
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_RGBA2BGR);
                                                  ^~~~~~~~~~~
                                                  CV_RGB
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::processColor(std::vector<cv::Mat>&, const std::vector<Kinect2Bridge::Status>&)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1250:55: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_HD], images[MONO_HD], CV_BGR2GRAY);
                                                       ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1254:65: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_HD_RECT], images[MONO_HD_RECT], CV_BGR2GRAY);
                                                                 ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1258:57: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_QHD], images[MONO_QHD], CV_BGR2GRAY);
                                                         ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1262:67: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_QHD_RECT], images[MONO_QHD_RECT], CV_BGR2GRAY);
                                                                   ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::receiveColor()’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1103:45: error: ‘CV_BGRA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_HD], CV_BGRA2BGR);
                                             ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1107:45: error: ‘CV_RGBA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_HD], CV_RGBA2BGR);
                                             ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1107:45: note: suggested alternative: ‘CV_RGB’
         cv::cvtColor(tmp, images[COLOR_HD], CV_RGBA2BGR);
                                             ^~~~~~~~~~~
                                             CV_RGB
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::processIrDepth(const cv::Mat&, std::vector<cv::Mat>&, const std::vector<Kinect2Bridge::Status>&)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1183:50: error: ‘CV_BGRA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_BGRA2BGR);
                                                  ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1187:50: error: ‘CV_RGBA2BGR’ was not declared in this scope
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_RGBA2BGR);
                                                  ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1187:50: note: suggested alternative: ‘CV_RGB’
         cv::cvtColor(tmp, images[COLOR_SD_RECT], CV_RGBA2BGR);
                                                  ^~~~~~~~~~~
                                                  CV_RGB
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::processColor(std::vector<cv::Mat>&, const std::vector<Kinect2Bridge::Status>&)’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1250:55: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_HD], images[MONO_HD], CV_BGR2GRAY);
                                                       ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1254:65: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_HD_RECT], images[MONO_HD_RECT], CV_BGR2GRAY);
                                                                 ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1258:57: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_QHD], images[MONO_QHD], CV_BGR2GRAY);
                                                         ^~~~~~~~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:1262:67: error: ‘CV_BGR2GRAY’ was not declared in this scope
       cv::cvtColor(images[COLOR_QHD_RECT], images[MONO_QHD_RECT], CV_BGR2GRAY);

 

在改文件添加#include <opencv2/imgproc/imgproc_c.h>

home/miao/catkin_ws/src/iai_kinect2/kinect2_viewer/src/viewer.cpp: In member function ‘void Receiver::imageViewer()’:
/home/miao/catkin_ws/src/iai_kinect2/kinect2_viewer/src/viewer.cpp:279:84: error: ‘CV_AA’ was not declared in this scope
         cv::putText(combined, oss.str(), pos, font, sizeText, colorText, lineText, CV_AA);
                                                                                    ^~~~~
/home/miao/catkin_ws/src/iai_kinect2/kinect2_viewer/src/viewer.cpp:279:84: note: suggested alternative: ‘CV_MSA’

 

posted @ 2021-01-01 15:30  miaorn  阅读(1227)  评论(0编辑  收藏  举报