Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Compiling OpenCV 3 beta for Debian 8 Jessie

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Sehny
Posts: 6
Joined: 2015-02-04 15:13

Compiling OpenCV 3 beta for Debian 8 Jessie

#1 Post by Sehny »

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?

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#2 Post by stevepusser »

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.
MX Linux packager and developer

User avatar
argorain
Posts: 58
Joined: 2014-04-15 05:31
Location: CR
Contact:

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#3 Post by argorain »

Vojtech "Rain" Vladyka

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#4 Post by stevepusser »

First bug report is for Blender, patch link is for xpra!
MX Linux packager and developer

Sehny
Posts: 6
Joined: 2015-02-04 15:13

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#5 Post by Sehny »

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/insta ... cv-debian/
and this for creating alternatives: https://kapolika.wordpress.com/2014/03/ ... peg-libav/

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#6 Post by stevepusser »

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/
MX Linux packager and developer

Sehny
Posts: 6
Joined: 2015-02-04 15:13

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#7 Post by Sehny »

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/ ... usty-media

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#8 Post by stevepusser »

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
MX Linux packager and developer

Jeremynal
Posts: 1
Joined: 2014-12-14 09:03

Compiling OpenCV 3 beta for Debian 8 Jessie

#9 Post by Jeremynal »

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.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling OpenCV 3 beta for Debian 8 Jessie

#10 Post by stevepusser »

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.
MX Linux packager and developer

Post Reply