User Tools

Site Tools


installing_opencv4_on_ubuntu_18

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
installing_opencv4_on_ubuntu_18 [2021/01/29 13:40] leogeorgescuinstalling_opencv4_on_ubuntu_18 [2021/07/02 23:17] (current) dongbinkim
Line 1: Line 1:
 <fs x-large>**Installing OpenCV4 on Ubuntu 18 and adding it to ROS**</fs>\\ <fs x-large>**Installing OpenCV4 on Ubuntu 18 and adding it to ROS**</fs>\\
 \\ \\
-**Author:** Leonardo Georgescu \\+**Author:** Leonardo Georgescu, Dongbin Kim \\
 **Email:** [email protected]\\ **Email:** [email protected]\\
-**Date:** Last Edited 01-29-2020\\+**Date:** Last Edited 07-02-2021 by Dongbin Kim\\
 **Keywords:** Dynamixel, Gantry, Ubuntu 18, OpenCV, ROS **Keywords:** Dynamixel, Gantry, Ubuntu 18, OpenCV, ROS
 \\ \\
Line 11: Line 11:
 <fs large>**Installation Guide** </fs> \\ <fs large>**Installation Guide** </fs> \\
  
-1. Check to see if Ubuntu is already installed:+1. Check to see if OpenCV is already installed:
   dasl@dasl-XPS-8900:</fc>~$ pkg-config --modversion opencv   dasl@dasl-XPS-8900:</fc>~$ pkg-config --modversion opencv
      
Line 18: Line 18:
   dasl@dasl-XPS-8900:~$ sudo apt-get autoremove   dasl@dasl-XPS-8900:~$ sudo apt-get autoremove
      
-3. Delete all the existing libraries:+3. Delete all the existing OpenCV libraries:
   dasl@dasl-XPS-8900:~$ sudo find /usr/local/ -name "*opencv*" -exec rm {} \;   dasl@dasl-XPS-8900:~$ sudo find /usr/local/ -name "*opencv*" -exec rm {} \;
  
-4. Update packages on Ubuntu:+4. Update and upgrade packages on Ubuntu:
   dasl@dasl-XPS-8900:~$ sudo apt-get update    dasl@dasl-XPS-8900:~$ sudo apt-get update 
-   +  dasl@dasl-XPS-8900:~$ sudo apt-get upgrade 
-5. Install build-essential packages:+     
 +5. Install build-essential and cmake packages:
   dasl@dasl-XPS-8900:~$ sudo apt-get install build-essential cmake   dasl@dasl-XPS-8900:~$ sudo apt-get install build-essential cmake
    
Line 43: Line 44:
   dasl@dasl-XPS-8900:~$ sudo apt-get install libgtk2.0-dev   dasl@dasl-XPS-8900:~$ sudo apt-get install libgtk2.0-dev
      
-11. Install OpenGL:+11. Install OpenGL libraries:
   dasl@dasl-XPS-8900:~$ sudo apt-get install mesa-utils libgl1-mesa-dri libgtkgl2.0-dev libgtkglext1-dev   dasl@dasl-XPS-8900:~$ sudo apt-get install mesa-utils libgl1-mesa-dri libgtkgl2.0-dev libgtkglext1-dev
      
-12. Install OpenCV: +12. Install libraries to optimize OpenCV: 
   dasl@dasl-XPS-8900:~$ sudo apt-get install libatlas-base-dev gfortran libeigen3-dev   dasl@dasl-XPS-8900:~$ sudo apt-get install libatlas-base-dev gfortran libeigen3-dev
      
Line 52: Line 53:
   dasl@dasl-XPS-8900:~$ sudo apt-get install python2.7-dev python3-dev python-numpy python3-numpy   dasl@dasl-XPS-8900:~$ sudo apt-get install python2.7-dev python3-dev python-numpy python3-numpy
      
-14. Create OpenCV directory:+14. Create OpenCV directory then move on:
   dasl@dasl-XPS-8900:~$ mkdir opencv   dasl@dasl-XPS-8900:~$ mkdir opencv
   dasl@dasl-XPS-8900:~$ cd opencv   dasl@dasl-XPS-8900:~$ cd opencv
Line 74: Line 75:
   dasl@dasl-XPS-8900:~/opencv/opencv-4.2.0/build$    dasl@dasl-XPS-8900:~/opencv/opencv-4.2.0/build$ 
      
-19. Produce pkg-config files in your build file. Could not upload the code here because daslhub would not accept it. To find the code go to the original page which is linked at the top and copy accordingly. If you can't find it, please email me.  +19. Utilize 'cmake' to configure OpenCV complie settings  
-  dasl@dasl-XPS-8900:~/opencv/opencv-4.2.0/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE.................... +  dasl@dasl-XPS-8900:~/opencv/opencv-4.2.0/build$  
-  +  cmake -D CMAKE_BUILD_TYPE=RELEASE 
 +  -D CMAKE_INSTALL_PREFIX=/usr/local \ 
 +  -D WITH_TBB=OFF \ 
 +  -D WITH_IPP=OFF \ 
 +  -D WITH_1394=OFF \ 
 +  -D BUILD_WITH_DEBUG_INFO=OFF \ 
 +  -D BUILD_DOCS=OFF \ 
 +  -D INSTALL_C_EXAMPLES=ON \ 
 +  -D INSTALL_PYTHON_EXAMPLES=ON \ 
 +  -D BUILD_EXAMPLES=OFF \ 
 +  -D BUILD_TESTS=OFF \ 
 +  -D BUILD_PERF_TESTS=OFF \ 
 +  -D WITH_QT=OFF \ 
 +  -D WITH_GTK=ON \ 
 +  -D WITH_OPENGL=ON \ 
 +  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.2.0/modules \ 
 +  -D WITH_V4L=ON 
 +  -D WITH_FFMPEG=ON \ 
 +  -D WITH_XINE=ON \ 
 +  -D BUILD_NEW_PYTHON_SUPPORT=ON \ 
 +  -D OPENCV_GENERATE_PKGCONFIG=ON ..
 + 
 +if you see the message like below, you successfully finished configuration 
 +  - Configuring done 
 +  - Generating done 
 +  - Build files have been written to: /home/webnautes/opencv/opencv-4.2.0/build 
 + 
 +You may have hard time doing the job here, if you are in trouble, please let us know, or look at the link the top of the tutorialEverything is explained in Korean, but you will understand if you run "Translate this page" in Google Chrome 
 20. Installation should be successful. Then, check how many cores you have available on the computer:  20. Installation should be successful. Then, check how many cores you have available on the computer: 
   dasl@dasl-XPS-8900:~$ lscpu   dasl@dasl-XPS-8900:~$ lscpu
Line 93: Line 122:
   dasl@dasl-XPS-8900:~$ sudo apt-get install ros-melodic-cv-bridge   dasl@dasl-XPS-8900:~$ sudo apt-get install ros-melodic-cv-bridge
      
-26. To view image on camera:+25. Install cheese to verity in ubuntu if your camera works. Running the commands below should allow you to view camera feedback. If it does not work, then it's an issue related to the drivers of your camera which need to be installed.  
 +  dasl@dasl-XPS-8900:~$ sudo apt-get install cheese 
 +  dasl@dasl-XPS-8900:~$ cheese 
 +  
 +   
 +26. To view image on camera in ros:
   dasl@dasl-XPS-8900:~$ sudo apt-get install ros-melodic-image-view   dasl@dasl-XPS-8900:~$ sudo apt-get install ros-melodic-image-view
 +  
 +27. This will be used to publish the camera feedback. To be able to subscribe we must be able to publish the data. Instill the video stream package first:
 +  dasl@dasl-XPS-8900:~$ sudo apt-get install ros-melodic-video-stream-opencv
 +  
 +28. Sometimes the camera feedback is too bright or if you want to change the values manually install the software below and run it.  
 +  dasl@dasl-XPS-8900:~$ sudo apt-get install guvcview
 +  dasl@dasl-XPS-8900:~$ guvcview
 +  
 +29. Once the camera is calibrated, you can check
      
 26.  26. 
 <fs large>**Adding OpenCV to ROS** </fs> \\ <fs large>**Adding OpenCV to ROS** </fs> \\
  
installing_opencv4_on_ubuntu_18.1611956419.txt.gz · Last modified: 2021/01/29 13:40 by leogeorgescu