vision_opencv icon indicating copy to clipboard operation
vision_opencv copied to clipboard

Problem with the Cmake issue Involving cv_bridge

Open henryfhq-drone opened this issue 5 years ago • 21 comments

Hi @vrabaud I have Installed the cv_bridge thing to my catkin_ws and I tried to do catkin_make for a github code that I have to download as part of my project.

However, I ran into a cmake issue that says that the usr/include/opencv is not found. The error is in the picture below:

Screenshot from 2020-05-13 19-26-30

I have tried download the opencv file but it is to no avail. and I have also tried to change a cmake file but I cannot edit.

I don't know is there an issue on the cv_bridge or is there something else that is missing?

I'm running on Jetson Nano which comes with opencv version 4.1.1. OS version is Ubuntu 18.04 and my ROS version is melodic.

Thank you very much.

henryfhq-drone avatar May 13 '20 15:05 henryfhq-drone

same here

isokar avatar May 21 '20 13:05 isokar

I've had the same problem.. anyone have an idea of what's going on?

debackerj93 avatar May 21 '20 17:05 debackerj93

@isokar @debackerj93 I would like to know if you guys using the same specification as me? If yes, then the following information might help you guys with solving the problem.

Jetson Nano has changed the file name from opencv to opencv4. However, in the cv_bridgeConfig.cmake file, at line 100+ to 113 (forgot which line). The code still says to include opencv file. There is also no way to change it since it is a root file on the Jetson Nano.

For my case, Firstly, I source build opencv 3.4.0. (If cannot download, I change the errant line to include Eigen 3). Next, I download the vision opencv (this one), extract it to the home directory and then I clone the cv_bridge to the source file of the catkin workspace then catkin make.

It is important to know that you need to install the following by running the following codes in the terminal: sudo apt-get install ros-< Your ROS version > - vision-opencv (for my case, melodic) sudo apt-get install ros - < Your ROS version > - cv-bridge. (for my case, melodic)

Thanks, everyone who has indicated that you shared the same problem as me. I really hope the above information helps. I know that it is very frustrating as well because you cannot implement the new codes.

henryfhq-drone avatar May 22 '20 12:05 henryfhq-drone

Hi @henryfhq-drone. I had the same problem. I have installed ros-melodic-vision-opencv and ros-melodic-cv-bridge with apt. I'm running on Jetson Nano. What do you mean by

Firstly, I source build opencv 3.4.0. (If cannot download, I change the errant line to include Eigen 3).

Can you explain me? Sorry, but I'm a newbie.

Thank you.

cafgiu avatar May 22 '20 14:05 cafgiu

Hi @cafgiu

Thanks for your message. Regarding the statement on source building the opencv 3.4.0. What I mean is you download the opencv using the link here:

https://github.com/kyamagu/mexopencv/wiki/Installation-%28Linux%2C-MATLAB%2C-OpenCV-3%29#1-opencv

Note that you only follow the first point

However, if you encounter errors, with the code as shown below:

WhatsApp Image 2020-05-14 at 16 57 37

Try to change the errant line to include < eigen3/ > at the front after the #include.

Don't worry, I am also a newbie to it as well.

henryfhq-drone avatar May 22 '20 15:05 henryfhq-drone

Hi @henryfhq-drone

Thanks for your answer. I have followed your steps but I have the below error

error_build_lego_loam2

Can you help me? Thank you.

cafgiu avatar May 25 '20 09:05 cafgiu

@cafgiu Do you have python 3 installed? (version at least 3.6 if I am not wrong)

If yes then that seems weird

henryfhq-drone avatar May 25 '20 13:05 henryfhq-drone

The command apt list --installed python* show me the below packages installed

https://pastebin.com/M1yp1Fj6

cafgiu avatar May 25 '20 14:05 cafgiu

I had this same issue. I tracked it down to using Nvidia SDKManager to Flash an Nvidia Jetson / Xavier. I was trying to use Jetpack 4.3 or 4.4, and in the process it replaced OpenCV 2 with OpenCV 4; this caused the cv-bridge not found issue.

Not knowing what had installed opencv4, I removed all ros-packages / opencv and reinstalled and was able to build but I was left without CUDA; upon using SDKManager to reinstall the cuda toolchain I ran into the same issue.

I found that if I installed Jetpack 4.2 using SDKManager it would remove opencv4 and resolve the issue.

BenArtes avatar May 28 '20 03:05 BenArtes

I have resolved commenting the row 11 12 in the CMakeLists.txt in the package cv_bridge

if(PYTHONLIBS_VERSION_STRING VERSION_LESS "3.8")
    # Debian Buster
    #find_package(Boost REQUIRED python37)
    #else()
    # Ubuntu Focal
    find_package(Boost REQUIRED python)
  endif()

and adding 0 at the #define NUMPY_IMPORT_ARRAY_RETVAL in the file /usr/include/python2.7/numpy/__multiarray_api.h

Cattura

cafgiu avatar May 28 '20 08:05 cafgiu

Same issue here on a Xavier NX with Jetpack 4.4 DP. I was able to resolve it by downgrading opencv-dev. Find what versions are available to you

$ apt list -a libopencv-dev
Listing... Done
libopencv-dev/stable 4.1.1-2-gd5a58aa75 arm64 [upgradable from: 3.2.0+dfsg-4ubuntu0.1]
libopencv-dev/bionic-updates,bionic-security,now 3.2.0+dfsg-4ubuntu0.1 arm64 [installed,upgradable to: 4.1.1-2-gd5a58aa75]
libopencv-dev/bionic 3.2.0+dfsg-4build2 arm64

Install the latest one before 4.0. For me it was: $ sudo apt install libopencv-dev=3.2.0+dfsg-4ubuntu0.1

jeffav avatar May 30 '20 03:05 jeffav

I solved this by installing libopencv as @jeffav described and then with the changes that @cafgiu describes so.

  1. Downgrade to opencv 3
  2. Changed CMakeLists.txt and __multiarray_api.h as in cafgiu post

tamisalex avatar Jun 01 '20 21:06 tamisalex

For opencv issue, i tried different method. It resolves the errors.

$sudo ln -s /usr/include/opencv4/ /usr/include/opencv

jebasamuel avatar Jun 04 '20 11:06 jebasamuel

Hi @jebasamuel. I tried this method but it not resolve the errors for me.

For opencv issue, i tried different method. It resolves the errors.

$sudo ln -s /usr/include/opencv4/ /usr/include/opencv

cafgiu avatar Jun 04 '20 13:06 cafgiu

@cafgiu Do you still have cv_bridge.cmake error saying unable to find opencv? Could you please post the catkin build log?

jebasamuel avatar Jun 04 '20 16:06 jebasamuel

Hi @henryfhq-drone

Thanks for your answer. I have followed your steps but I have the below error

error_build_lego_loam2

Can you help me? Thank you.

Hello, i have the same problem like you.

i solve that issue with change the boost requirement with python major

find_package(Boost REQUIRED python3)

IhsanFikri avatar Jun 30 '20 15:06 IhsanFikri

For opencv issue, i tried different method. It resolves the errors.

$sudo ln -s /usr/include/opencv4/ /usr/include/opencv

Can confirm that this works.

stevenlee090 avatar Jul 15 '20 09:07 stevenlee090

For opencv issue, i tried different method. It resolves the errors. $sudo ln -s /usr/include/opencv4/ /usr/include/opencv

Can confirm that this works.

I can confirm that this could resolve the issue in some situations with Nvidia Jetson TX2. But in my case, the ros packqage (LeGo-LOAM) that I am compiling needs the #include <opencv/cv.h> and this not exist in opencv4. The solution for my case is: Downgrade to opencv 3.2

GilenTell avatar Jul 16 '20 07:07 GilenTell

i am facing exact issues as @henryfhq-drone and @cafgiu . can someone please describe the solution for jetson nano 18.04(melodic)

siddharthcb avatar Jan 31 '21 15:01 siddharthcb

@isokar @debackerj93 I would like to know if you guys using the same specification as me? If yes, then the following information might help you guys with solving the problem.

Jetson Nano has changed the file name from opencv to opencv4. However, in the cv_bridgeConfig.cmake file, at line 100+ to 113 (forgot which line). The code still says to include opencv file. There is also no way to change it since it is a root file on the Jetson Nano.

For my case, Firstly, I source build opencv 3.4.0. (If cannot download, I change the errant line to include Eigen 3). Next, I download the vision opencv (this one), extract it to the home directory and then I clone the cv_bridge to the source file of the catkin workspace then catkin make.

It is important to know that you need to install the following by running the following codes in the terminal: sudo apt-get install ros-< Your ROS version > - vision-opencv (for my case, melodic) sudo apt-get install ros - < Your ROS version > - cv-bridge. (for my case, melodic)

Thanks, everyone who has indicated that you shared the same problem as me. I really hope the above information helps. I know that it is very frustrating as well because you cannot implement the new codes.

Solution I have written here for reference @siddharthcb

henryfhq-drone avatar Feb 01 '21 20:02 henryfhq-drone

Hello,

I had similar issues described above. With compiling cv_bridge with OpenCV Version 4.5.1 on a Jetson Nano (Ubuntu 18 and Melodic Distro). I just installed ROS base and not the whole distro.

First error while building was with libboos library for python3 Second error was about empty return value in: In function ‘void* do_numpy_import()’: /usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘void*’ [-fpermissive]

The way I solved this issues (This way is just for one workspace)

  • Create sympolic link for opencv: ln -s /usr/include/opencv4 /usr/include/opencv
  • Download vision_opencv noetic branche: git clone https://github.com/ros-perception/vision_opencv.git
  • Install libboost with package manager (If you have not already done this): sudo apt-get install libboost-dev libboost-all-dev
  • Comment line 10 till 13 https://github.com/ros-perception/vision_opencv/issues/329#issuecomment-635192230
  • Add number 0 in /usr/include/python2.7/numpy/__multiarray_api.h like @cafgiu mentioned above: https://github.com/ros-perception/vision_opencv/issues/329#issuecomment-635192230
  • Create a build directory in cv_bridge: mkdir build && cd build
  • cmake ..
  • make -j$(nproc) (for the Jetson Nano I used all 4 cores)
  • Optional: make install to install the binaries in the include directory of the cv_bridge package

I hope this may be helpfull for anyone who has problems, building cv_bridge with a newer version of OpenCV.

freesolo92 avatar Oct 13 '21 09:10 freesolo92