在 Raspberry Pi 上编译 OpenCV 2
Compiling OpenCV on Raspberry Pi 2
我正在 Raspberry 2 上编译 OpenCV
我卡在了这一步,
[ 18%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o
with返回了很多错误,我只取了开头的2个,其他看起来都一样
但在 { CODEC_ID_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
的任何安装,然后进行构建。
查看 this guide here 了解更多信息。
我正在 Raspberry 2 上编译 OpenCV 我卡在了这一步,
[ 18%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o
with返回了很多错误,我只取了开头的2个,其他看起来都一样
但在 { CODEC_ID_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
的任何安装,然后进行构建。
查看 this guide here 了解更多信息。