ros-perception / vision_opencv

Apache License 2.0
557 stars 601 forks source link

Problem with the Cmake issue Involving cv_bridge #329

Open henryfhq-drone opened 4 years ago

henryfhq-drone commented 4 years ago

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.

isokar commented 4 years ago

same here

debackerj93 commented 4 years ago

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

henryfhq-drone commented 4 years ago

@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.

cafgiu commented 4 years ago

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.

henryfhq-drone commented 4 years ago

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.

cafgiu commented 4 years ago

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.

henryfhq-drone commented 4 years ago

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

If yes then that seems weird

cafgiu commented 4 years ago

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

https://pastebin.com/M1yp1Fj6

BenArtes commented 4 years ago

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.

cafgiu commented 4 years ago

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

jeffav commented 4 years ago

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

tamisalex commented 4 years ago

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
jebasamuel commented 4 years ago

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

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

cafgiu commented 4 years ago

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

jebasamuel commented 4 years ago

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

IhsanFikri commented 4 years ago

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)

stevenlee090 commented 4 years ago

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.

GilenTell commented 4 years ago

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

siddharthcb commented 3 years ago

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

henryfhq-drone commented 3 years ago

@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

freesolo92 commented 3 years ago

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)

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