econsystems / opencv

Easy way to communicate with the camera using this OpenCV patch in c++
38 stars 18 forks source link

Code error when installing openCV on Ubuntu 18.04 #4

Open Dehde opened 4 years ago

Dehde commented 4 years ago

Hi, I have troubles when trying to follow your install instructions here:

https://github.com/econsystems/opencv/blob/master/Documents/OpenCV_Installation_Linux_Manual_v1.3.pdf

I followed the instructions along every step. I checked that all prerequisites are installed. I installed every module that was asked for.

Specifically, when running the command

  1. To build and install the OpenCV libraries in the location /usr/local/lib/, you must run the following commands. $ sudo make -j4 && make install

The error I get is:

[ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/hist_cost.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/sc_dis.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/tps_trans.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//videoio/src/cap.cpp.o

/home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/cap.cpp: In member function ‘bool cv::VideoWriter::open(const cv::String&, int, int, double, cv::Size, bool)’: /home/rob/PycharmProjects/opencvorig/sources/modules/videoio/src/cap.cpp:972:117: error: could not convert ‘frameSize’ from ‘cv::Size {aka cv::Size}’ to ‘CvSize’ writer.reset(cvCreateVideoWriterWithPreference(filename.c_str(), apiPreference, _fourcc, fps, frameSize, isColor)); ^ /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/cap.cpp: In member function ‘virtual void cv::VideoWriter::write(const cv::Mat&)’: /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/cap.cpp:1004:25: error: conversion from ‘const cv::Mat’ to non-scalar type ‘IplImage {aka _IplImage}’ requested IplImage _img = image;

modules/world/CMakeFiles/opencv_world.dir/build.make:7503: recipe for target 'modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap.cpp.o' failed make[2]: [modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... CMakeFiles/Makefile2:1458: recipe for target 'modules/world/CMakeFiles/opencv_world.dir/all' failed make[1]: [modules/world/CMakeFiles/opencv_world.dir/all] Error 2 Makefile:162: recipe for target 'all' failed make: [all] Error 2

The above was run with the current branch "3.4" from opencv.

I ran the code again after checking out the tag "3.4.10". The error then changes to:

[ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/emdL1.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/haus_dis.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//shape/src/hist_cost.cpp.o [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/shape/src/sc_dis.cpp.o make[2]: *** No rule to make target '../modules/videoio/src/videoio_registry.cpp', needed by 'modules/world/CMakeFiles/opencv_world.dir//videoio/src/videoio_registry.cpp.o'. Stop. make[2]: Waiting for unfinished jobs.... [ 78%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/shape/src/tps_trans.cpp.o CMakeFiles/Makefile2:1458: recipe for target 'modules/world/CMakeFiles/opencv_world.dir/all' failed make[1]: [modules/world/CMakeFiles/opencv_world.dir/all] Error 2 Makefile:162: recipe for target 'all' failed make: *** [all] Error 2

If I checkout the tag "3.4.1" I get the following error during compilation:

[ 80%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//videoio/src/cap_gphoto2.cpp.o [ 80%] Building CXX object modules/world/CMakeFiles/opencv_world.dir//highgui/src/window.cpp.o In file included from /home/rob/PycharmProjects/opencv_orig/sources/modules/core/include/opencv2/core/cvstd.hpp:1038:0, from /home/rob/PycharmProjects/opencv_orig/sources/modules/core/include/opencv2/core/base.hpp:58, from /home/rob/PycharmProjects/opencv_orig/sources/modules/core/include/opencv2/core.hpp:54, from /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/include/opencv2/videoio.hpp:46, from /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/precomp.hpp:45, from /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/cap_gphoto2.cpp:28: /home/rob/PycharmProjects/opencv_orig/sources/modules/core/include/opencv2/core/ptr.inl.hpp: In instantiation of ‘cv::Ptr cv::makePtr(const A1&) [with T = cv::gphoto2::DigitalCameraCapture; A1 = int]’: /home/rob/PycharmProjects/opencv_orig/sources/modules/videoio/src/cap_gphoto2.cpp:1200:78: required from here /home/rob/PycharmProjects/opencv_orig/sources/modules/core/include/opencv2/core/ptr.inl.hpp:307:19: error: invalid new-expression of abstract class type ‘cv::gphoto2::DigitalCameraCapture’ return Ptr(new T(a1)); ^~~~~

Could you possibly help me with that?

EDIT: Now I tried compiling with the tag "3.3.1" and it finally worked!

So maybe it would be enough if you address this in the .pdf file: It cannot be 3.4.1 OR 3.3.1, it must be 3.3.1.

Also another issue I confronted during installation: On ubuntu 18.04, instead of running sudo apt-get install libavcodec-ffmpeg-extra56 libavformat-ffmpeg56 libavutil-ffmpeg54 libswscale-ffmpeg3 you have to run sudo apt-get install libavcodec-extra57 libavformat57 libavutil55

as the former is not available for Ubuntu 18.04.

--> Please treat this issue together with the following issue!!: https://github.com/econsystems/opencv/issues/5

M-VishnuMurali commented 4 years ago

Hi, the opencv build should work for both 3.4.1 and 3.3.1 tags .Please try compiling 3.4.1 again by adding compiler flag "-D WITH_GSTREAMER=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF" .As for the dependencies for 18.04 thanks for bringing it to our attention we will be updating it in next release.