Compiling OpenCV 3 beta for Debian 8 Jessie

Need help with C, C++, perl, python, etc?

Compiling OpenCV 3 beta for Debian 8 Jessie

Postby Sehny » 2015-02-04 15:38

Hi,

I've been trying to compile OpenCV3 beta for Debian Jessie, but I can't figure out how to compile support for video I/O .

Tutorials that can be found on-line usually use ffmpeg library, but as I found out Debian 8 replace this library with libav (?).

Of course I found tutorials how to remove libav and install ffmpeg, but I would rather try to find some another way.

I use OpenCV3 beta from http://opencv.org/
When I use this switch
Code: Select all
-DWITH_FFMPEG=0
compilation succeed, but there is no support for video.
When I don't use that switch, then I get this error:
Code: Select all
In file included from /home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp:65:0,
                 from /home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg.cpp:45:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/ffmpeg_codecs.hpp:98:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
       ^
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/ffmpeg_codecs.hpp:99:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },

... a lot more codecs

In file included from /home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘double CvCapture_FFMPEG::getProperty(int)’:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp:782:33: error: ‘AVStream’ has no member named ‘r_frame_rate’
         return av_q2d(video_st->r_frame_rate);
                                 ^
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘double CvCapture_FFMPEG::get_fps()’:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp:829:49: error: ‘AVStream’ has no member named ‘r_frame_rate’
     double fps = r2d(ic->streams[video_stream]->r_frame_rate);
                                                 ^
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp: In function ‘AVStream* icv_add_video_stream_FFMPEG(AVFormatContext*, AVCodecID, int, int, int, double, int)’:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp:1218:24: error: ‘CODEC_ID_H264’ was not declared in this scope
     if (c->codec_id == CODEC_ID_H264) {
                        ^
In file included from /home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp: In function ‘int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)’:
/home/sehny/Dokumenty/opencv-3.0.0-beta/modules/videoio/src/cap_ffmpeg_impl.hpp:1267:72: error: ‘avcodec_encode_video’ was not declared in this scope
         out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
                                                                        ^
[ 45%] Built target opencv_photo
[ 45%] Building CXX object modules/shape/CMakeFiles/opencv_shape.dir/src/sc_dis.cpp.o
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:146: návod pro cíl „modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o“ selhal
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Chyba 1
make[2]: *** Čeká se na nedokončené úlohy…
[ 45%] Building CXX object modules/shape/CMakeFiles/opencv_shape.dir/src/precomp.cpp.o
CMakeFiles/Makefile2:2406: návod pro cíl „modules/videoio/CMakeFiles/opencv_videoio.dir/all“ selhal
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Chyba 2



Can anyone help me with this problem?
Sehny
 
Posts: 6
Joined: 2015-02-04 15:13

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby stevepusser » 2015-02-04 20:00

Do you have the libav -dev files installed, libavcodec-dev, libavformat-dev, libswscale-dev?

It's possible to have both a "real" ffmpeg set of packages installed in /opt and the standard libav packages, that what I have and it works great. I just have a an "ffmpeg" link in /usr/bin that I can switch between avconv or the true ffmpeg binary via the alternatives system.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: mvp 0.29.0, Pale Moon 28.0.0, wine-staging 3.13, qBittorrent 4.1.2, Linux kernel 4.17.14, virtualbox 5.2.18
User avatar
stevepusser
 
Posts: 9802
Joined: 2009-10-06 05:53

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby argorain » 2015-02-04 20:35

Vojtech "Rain" Vladyka
User avatar
argorain
 
Posts: 58
Joined: 2014-04-15 05:31
Location: CR

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby stevepusser » 2015-02-04 20:47



First bug report is for Blender, patch link is for xpra!
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: mvp 0.29.0, Pale Moon 28.0.0, wine-staging 3.13, qBittorrent 4.1.2, Linux kernel 4.17.14, virtualbox 5.2.18
User avatar
stevepusser
 
Posts: 9802
Joined: 2009-10-06 05:53

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby Sehny » 2015-02-04 23:00

stevepusser wrote:Do you have the libav -dev files installed, libavcodec-dev, libavformat-dev, libswscale-dev?

It's possible to have both a "real" ffmpeg set of packages installed in /opt and the standard libav packages, that what I have and it works great. I just have a an "ffmpeg" link in /usr/bin that I can switch between avconv or the true ffmpeg binary via the alternatives system.


Yes, all of them.

Well, it seems like there is no other way to solve this, but I'm not sure if I'm able install and create these alternatives. Can you help me with it?
I found this tutorial for installing FFmpeg: http://www.javieriparraguirre.net/installing-opencv-debian/
and this for creating alternatives: https://kapolika.wordpress.com/2014/03/25/configure-update-alternatives-for-switching-between-ffmpeg-libav/
Sehny
 
Posts: 6
Joined: 2015-02-04 15:13

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby stevepusser » 2015-02-04 23:31

You could port the packages over following this guide: https://wiki.debian.org/SimpleBackportCreation

Note that you'll either also have to port over x265 first, or just remove the build-depend from the debian/control file and remove the "--enable-x265" from debian/rules.

You need to download the orig.tar.xz and the debian.tar.gz files, extract both, and then place /debian into the extracted orig source. Files are here, current version is 2.5.3:

http://main.mepis-deb.org/mepiscr/testr ... /f/ffmpeg/

That will get you to the point in the guide where the source is downloaded and you are ready to edit files.

The alternatives ffmpeg package is here, you can just install the deb:
http://main.mepis-deb.org/mepiscr/testr ... ernatives/
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: mvp 0.29.0, Pale Moon 28.0.0, wine-staging 3.13, qBittorrent 4.1.2, Linux kernel 4.17.14, virtualbox 5.2.18
User avatar
stevepusser
 
Posts: 9802
Joined: 2009-10-06 05:53

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby Sehny » 2015-02-11 15:24

Would it be possible to use PPA repository for installing ffmpeg?

For example this one has compiled ffmpeg library in /opt :
https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media
Sehny
 
Posts: 6
Joined: 2015-02-04 15:13

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby stevepusser » 2015-02-11 18:25

Maybe--but results are very unpredictable and may break your system. The only guaranteed safe way is to rebuild the packages on your own system against the Debian system.

You could add the deb-multimedia repository to get the "real" ffmpeg, also. Those are built to be Debian compatible.

deb-multimedia.org
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: mvp 0.29.0, Pale Moon 28.0.0, wine-staging 3.13, qBittorrent 4.1.2, Linux kernel 4.17.14, virtualbox 5.2.18
User avatar
stevepusser
 
Posts: 9802
Joined: 2009-10-06 05:53

Compiling OpenCV 3 beta for Debian 8 Jessie

Postby Jeremynal » 2015-03-04 22:03

Team 3826 is trying to use the Jetson. We pulled the source code from the link "nVIDIA Jetson TK1 Code:". Weve tried to compile it and are getting the following errors:

make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mgb/900_opencv/frisbeelocating
Scanning dependencies of target testing
50 Building CXX object CMakeFiles/testing.dir/gpuTesting.cpp.o
c: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
c: error: unrecognized command line option ‘-mfpu=neon-vfpv4’
c: error: unrecognized command line option ‘-mvectorize-with-neon-quad’
make2: CMakeFiles/testing.dir/gpuTesting.cpp.o Error 1
make1: CMakeFiles/testing.dir/all Error 2
make: all Error 2
1- Done emacs Makefile.cmake wd: /900_opencv/frisbeelocating/CMakeFiles
wd now: /900_opencv/frisbeelocating
2 Done emacs CMakeCache.txt


Ive found the -mcpu can be changed to -mtune using the same parameter to remove the -mcpu error, however, we dont see a work around for the other two errors.

Were compiling on ubuntu on a VirtualBox VM running on Win7 with the Jetson TK1 installed. Have this been seen before? Any suggestions?

Thank you.
Jeremynal
 
Posts: 1
Joined: 2014-12-14 09:03

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

Postby stevepusser » 2015-03-04 22:35

Whatever compiler you are using does not recognize these arguments:

Code: Select all
c: error: unrecognized command line option ‘-mfpu=neon-vfpv4’
c: error: unrecognized command line option ‘-mvectorize-with-neon-quad’


Maybe it would work using clang as the compiler?

Usually I just google the error message to get an idea of what's going on.

If all else fails, delete those flags and see how much smoke comes out.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: mvp 0.29.0, Pale Moon 28.0.0, wine-staging 3.13, qBittorrent 4.1.2, Linux kernel 4.17.14, virtualbox 5.2.18
User avatar
stevepusser
 
Posts: 9802
Joined: 2009-10-06 05:53


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable