C++ 在Raspberry Pi 2上编译OpenCV

C++ 在Raspberry Pi 2上编译OpenCV,c++,opencv,raspberry-pi,raspberry-pi2,C++,Opencv,Raspberry Pi,Raspberry Pi2,我正在树莓2上编译OpenCV 我被困在这个台阶上 [ 18%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o 由于返回了很多错误,我只取了两个开头,其他的看起来都一样 但是在{CODEC\u ID\u H264,MKTAG('h','2','6','4')}, In file included from /home/pi/opencv/modules/highgui

我正在树莓2上编译OpenCV 我被困在这个台阶上

[ 18%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o
由于返回了很多错误,我只取了两个开头,其他的看起来都一样 但是在
{CODEC\u ID\u H264,MKTAG('h','2','6','4')},

In file included from /home/pi/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:60:0,
                 from /home/pi/opencv/modules/highgui/src/cap_ffmpeg.cpp:45:
/home/pi/opencv/modules/highgui/src/ffmpeg_codecs.hpp:104:7: error: 'CODEC_ID_H264' was not     declared in this scope
     { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
       ^
/home/pi/opencv/modules/highgui/src/ffmpeg_codecs.hpp:105:7: error: 'CODEC_ID_H264' was not     declared in this scope
     { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
       ^
最后一部分是关于

/home/pi/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'double     CvCapture_FFMPEG::get_fps()':
/home/pi/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:821:49: error: 'AVStream' has no member named 'r_frame_rate'
     double fps = r2d(ic->streams[video_stream]->r_frame_rate);
                                             ^
In file included from /home/pi/opencv/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/pi/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp: In function 'int         icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)':
/home/pi/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:1237:72: error: 'avcodec_encode_video'     was not declared in this scope
         out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
                                                                    ^
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:215: recipe for target     'modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o' failed
make[2]: ** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1
CMakeFiles/Makefile2:1823: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all'     failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:137: recipe for target 'all' failed

请帮我解决这个问题,因为我在尝试了几次之后很长一段时间都被它绊住了,谢谢你

这个错误可能是因为你使用了存储库中的
ffmpeg
。从源代码构建OpenCV时,强烈建议也构建相应的
ffmpeg
版本。从Pi中删除
ffmpeg
x264
的任何安装,然后执行生成


查看更多信息。

或者,有没有办法为树莓皮制作一个已编译的垃圾桶?非常感谢,很高兴它成功了。:)也许把我的帖子标记为答案(因为它是:D)?这似乎对我不起作用。当运行
/configure--enable shared--disable static--cross prefix=arm xilinx linux gnueabi--arch=armv7l--target os=linux--prefix=
(在您共享的链接中指定)时,我收到了这样的错误:
BEGIN/tmp/ffconf.LHUE6snE.c1 intmain(void){return 0;}END/tmp/ffconf.LHUE6snE.c arm-xilinx-linux-gnueabi-gcc-mcpu=-c-o/tmp/ffconf.kpNuXlt1.o/tmp/ffconf.LHUE6snE.c./configure:884:./configure:arm-xilinx-linux-gnueabi-gcc:not found-c编译器测试失败。
知道什么可能有效吗?1)请不要在注释中发布属于单独线程的问题,2)可能有与您使用的奇怪编译器有关吗?Xilinx用于FPGA如果我没有弄错的话,它肯定不是Pi的默认编译器。您已经明确地将其设置为
前缀
参数,因此我假设您知道自己在做什么。对不起,我们在“本地路径”中放了什么?我想我们必须遵循树莓的手臂指南?