opencv - cmake error : No such file or directory on Ubuntu

This seems really silly in retrospect but the cmake command has a path option for -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \. This path was incorrect on my system. I changed it to the correct path and it worked. Thanks for all the help guys!


For your problem, you have to run following command

sudo apt-get install libv4l-dev

for install OpenCV on Ubuntu, I always following some step that always works.

I install OpenCV with opencv_contrib ( some extra module for OpenCV)

Open terminal and run following command

To install opencv dependency

sudo apt-get install build-essential

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

sudo apt-get install libxvidcore-dev libx264-dev

To install opencv

  1. cd /opt/

  2. sudo git clone https://github.com/opencv/opencv.git

  3. sudo git clone https://github.com/opencv/opencv_contrib.git

  4. cd opencv

  5. sudo mkdir release

  6. cd release

  7. sudo cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules -D WITH_LIBV4L=ON -D WITH_V4L=OFF -D BUILD_EXAMPLES=ON /opt/opencv/

  8. sudo make

  9. sudo make install

  10. pkg-config --modversion opencv # check version installed

If you don't want to install opencv_contrib you can skip 3rd step and change 7 step to

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D 
CMAKE_INSTALL_PREFIX=/usr/local -D /opt/opencv/