sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.32k stars 349 forks source link

building libsourcey with WITH_OPENCV enabled #251

Open mcajkovs opened 6 years ago

mcajkovs commented 6 years ago

Configuration: OS: Ubuntu 18.04.1 LTS Libsourcey: commit: ce311ff22, date: Sun Mar 25 12:32:55 2018, tag: 1.1.4 WebRTC: webrtc-22215-ab42706-linux-x64.tar.gz from OpenCV: 3.4.2 installed using this script

I'm unable to compile libsourcey with OpenCV examples and thus running some of OpenCV examples. Here is tutorial I've followed this but except installing WebRTC I've downloaded pre-build libraries.

The compilation is successfull (e.g. ~/libsourcey/build/webrtc/samples/webrtcstreamer/ is working) with following CMake variables (WITH_OPENCV = FALSE):

CMAKE_BUILD_TYPE = RELEASE
OPENCV_LINK_SHARED_LIBS = FALSE
WEBRTC_ROOT_DIR = /home/marek/webrtc
WITH_OPENSSL = FALSE
BUILD_SHARED_LIBS = FALSE
WITH_FFMPEG = TRUE
BUILD_SAMPLES = TRUE
WITH_OPENCV = FALSE

I guess that due to WITH_OPENCV = FALSE I got following error when I try to compile opencvanalyzer manually (using make from appropriate directory) which I assume is OK:

marek@lubuntu18-64:~/libsourcey/build/webrtc/samples/opencvanalyzer$ make
make[1]: *** No rule to make target 'webrtc/samples/opencvanalyzer/all'.  Stop.
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

What I've noticed is that mediaserver was compiled successfully (with cmake or make) even if it contains some opencv code and I have WITH_OPENCV = FALSE:

marek@lubuntu18-64:~/libsourcey/src/av/samples/mediaserver$ grep -r 'cv::'
snapshotresponder.h:        cv::Mat frame;
snapshotresponder.h:        cv::imencode(".jpg", frame, buffer, param);

marek@lubuntu18-64:~/libsourcey/build/av/samples/mediaserver$ rm mediaserver && make
[  1%] Built target http_parser
[ 19%] Built target libuv
[ 28%] Built target zlib
[ 31%] Built target minizip
[ 49%] Built target base
[ 52%] Built target json
[ 53%] Built target util
[ 68%] Built target av
[ 73%] Built target crypto
[ 80%] Built target net
[ 90%] Built target http
[ 92%] Built target stun
[ 98%] Built target turn
[ 98%] Linking CXX executable mediaserver
[100%] Built target mediaserver
marek@lubuntu18-64:~/libsourcey/build/av/samples/mediaserver$

Problem is when I try to compile libsourcey with WITH_OPENCV = TRUE option. As you can see mediaserver which previously compiled with WITH_OPENCV = FALSE does not compile with WITH_OPENCV = TRUE. Compilation of mediaserveralso fails when I try to compile it manually (using make). Bellow are errors what I get:

[ 71%] Building CXX object av/samples/mediaserver/CMakeFiles/mediaserver.dir/mediaserver.cpp.o
In file included from /home/marek/libsourcey/src/av/samples/mediaserver/mediaserver.cpp:3:0:
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h: In member function ‘virtual void scy::SnapshotRequestHandler::onRequest(scy::http::Request&, scy::http::Response&)’:
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:25:9: error: ‘cv’ has not been declared
         cv::Mat frame;
         ^~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:26:31: error: ‘using element_type = class scy::av::VideoCapture {aka class scy::av::VideoCapture}’ has no member named ‘getFrame’
         options.videoCapture->getFrame(frame, options.oformat.video.width,
                               ^~~~~~~~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:26:40: error: ‘frame’ was not declared in this scope
         options.videoCapture->getFrame(frame, options.oformat.video.width,
                                        ^~~~~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:26:40: note: suggested alternative: ‘free’
         options.videoCapture->getFrame(frame, options.oformat.video.width,
                                        ^~~~~
                                        free
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:31:20: error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope
         param[0] = CV_IMWRITE_JPEG_QUALITY;
                    ^~~~~~~~~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:33:9: error: ‘cv’ has not been declared
         cv::imencode(".jpg", frame, buffer, param);
         ^~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:38:66: error: ‘using element_type = class scy::av::VideoCapture {aka class scy::av::VideoCapture}’ has no member named ‘width’
                << "\n\tCapture Width: " << options.videoCapture->width()
                                                                  ^~~~~
/home/marek/libsourcey/src/av/samples/mediaserver/snapshotresponder.h:39:67: error: ‘using element_type = class scy::av::VideoCapture {aka class scy::av::VideoCapture}’ has no member named ‘height’
                << "\n\tCapture Height: " << options.videoCapture->height()
                                                                   ^~~~~~
av/samples/mediaserver/CMakeFiles/mediaserver.dir/build.make:86: recipe for target 'av/samples/mediaserver/CMakeFiles/mediaserver.dir/mediaserver.cpp.o' failed
make[2]: *** [av/samples/mediaserver/CMakeFiles/mediaserver.dir/mediaserver.cpp.o] Error 1
CMakeFiles/Makefile2:781: recipe for target 'av/samples/mediaserver/CMakeFiles/mediaserver.dir/all' failed
make[1]: *** [av/samples/mediaserver/CMakeFiles/mediaserver.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I guess that as a result of failed compilation I do not have binary inside ~/libsourcey/build/webrtc/samples/opencvanalyzer When I try to compile opencvanalyzer manually (with make) I get following error:

[ 97%] Building CXX object webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/objectdetector.cpp.o
/home/marek/libsourcey/src/webrtc/samples/opencvanalyzer/objectdetector.cpp: In member function ‘virtual void scy::wrtc::ObjectDetector::OnFrame(const webrtc::VideoFrame&)’:
/home/marek/libsourcey/src/webrtc/samples/opencvanalyzer/objectdetector.cpp:95:84: error: ‘class webrtc::VideoFrameBuffer’ has no member named ‘DataY’
                 uint8_t* brightnessData = (uint8_t*)yuvframe.video_frame_buffer()->DataY();
                                                                                    ^~~~~
webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/build.make:86: recipe for target 'webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/objectdetector.cpp.o' failed
make[2]: *** [webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/objectdetector.cpp.o] Error 1
CMakeFiles/Makefile2:2832: recipe for target 'webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/all' failed
make[1]: *** [webrtc/samples/opencvanalyzer/CMakeFiles/opencvanalyzer.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I have noticed (if it matters) that inside CmakeGUI I have those two lines with red color:

WEBRTC_INCLUDE_DIR: /home/marek/webrtc/include
WEBRTC_INCLUDE_DIRS: /home/marek/webrtc/include; /home/marek/webrtc/include/third_party/boringssl/src/include

What I'm doing wrong? Thanks.

snarb commented 5 years ago

the same problem