Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos OpenCV编译过程失败_Macos_Opencv_Ffmpeg - Fatal编程技术网

Macos OpenCV编译过程失败

Macos OpenCV编译过程失败,macos,opencv,ffmpeg,Macos,Opencv,Ffmpeg,因此,我将在下面介绍如何为Python3安装openCV。我在编译过程中遇到了一些问题。运行make-j4命令会一直正常运行,直到我收到此错误消息时28%通过:错误:使用未声明的标识符“avcodec_free_frame”;你是说“avcodec\u get\u name”吗? 我甚至不知道从哪里开始解决这个问题。我已经通过brew安装了ffmpeg 完整的命令列表: cd ~ git clone https://github.com/Itseez/opencv.git cd opencv g

因此,我将在下面介绍如何为Python3安装openCV。我在编译过程中遇到了一些问题。运行
make-j4
命令会一直正常运行,直到我收到此错误消息时28%通过:
错误:使用未声明的标识符“avcodec_free_frame”;你是说“avcodec\u get\u name”吗?

我甚至不知道从哪里开始解决这个问题。我已经通过brew安装了
ffmpeg

完整的命令列表:

cd ~
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 3.0.0
cd ~
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout 3.0.0
cd ~/opencv
mkdir build
cd build
cmake CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config-3.5m/libpython3.5.dylib \
    -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/include/python3.5m/ \
    -D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python \
    -D BUILD_opencv_python2=OFF \
    -D BUILD_opencv_python3=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=ON .. \
    -D FFMPEG_INCLUDE_DIR=/usr/local/Cellar/ffmpeg/3.3.4/include/
    -D FFMPEG_LIB_DIR=/usr/local/Cellar/ffmpeg/3.3.4/lib/
    -D WITH_FFMPEG=ON
cmake
make -j4
我从这篇文章中得到了
FFMPEG\u INCLUDE\u DIR
FFMPEG\u LIB\u DIR
,其中包含了\u FFMPEG

完整的错误日志:

[ 28%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_qtkit.mm.o
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:317:9: error: use of undeclared identifier
      'avcodec_free_frame'; did you mean 'avcodec_get_name'?
        avcodec_free_frame(&picture);
        ^~~~~~~~~~~~~~~~~~
        avcodec_get_name
/usr/local/Cellar/ffmpeg/3.3.4/include/libavcodec/avcodec.h:6289:13: note: 'avcodec_get_name' declared here
const char *avcodec_get_name(enum AVCodecID id);
            ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:317:28: error: cannot initialize a parameter of type
      'enum AVCodecID' with an rvalue of type 'AVFrame **'
        avcodec_free_frame(&picture);
                           ^~~~~~~~
/usr/local/Cellar/ffmpeg/3.3.4/include/libavcodec/avcodec.h:6289:45: note: passing argument to parameter 'id' here
const char *avcodec_get_name(enum AVCodecID id);
                                            ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:632:23: error: use of undeclared identifier
      'avcodec_alloc_frame'
            picture = avcodec_alloc_frame();
                      ^
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:635:41: error: use of undeclared identifier
      'PIX_FMT_BGR24'; did you mean 'AV_PIX_FMT_BGR24'?
                    avpicture_get_size( PIX_FMT_BGR24,
                                        ^~~~~~~~~~~~~
                                        AV_PIX_FMT_BGR24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5: note: 'AV_PIX_FMT_BGR24' declared here
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:638:29: error: use of undeclared identifier
      'PIX_FMT_BGR24'; did you mean 'AV_PIX_FMT_BGR24'?
                            PIX_FMT_BGR24, enc->width, enc->height );
                            ^~~~~~~~~~~~~
                            AV_PIX_FMT_BGR24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5: note: 'AV_PIX_FMT_BGR24' declared here
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:738:67: error: use of undeclared identifier
      'PIX_FMT_RGB24'; did you mean 'AV_PIX_FMT_RGB24'?
    avpicture_fill((AVPicture*)&rgb_picture, rgb_picture.data[0], PIX_FMT_RGB24,
                                                                  ^~~~~~~~~~~~~
                                                                  AV_PIX_FMT_RGB24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:64:5: note: 'AV_PIX_FMT_RGB24' declared here
    AV_PIX_FMT_RGB24,     ///< packed RGB 8:8:8, 24bpp, RGBRGB...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:756:17: error: use of undeclared identifier
      'PIX_FMT_BGR24'; did you mean 'AV_PIX_FMT_BGR24'?
                PIX_FMT_BGR24,
                ^~~~~~~~~~~~~
                AV_PIX_FMT_BGR24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5: note: 'AV_PIX_FMT_BGR24' declared here
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1110:15: error: use of undeclared identifier
      'avcodec_alloc_frame'
    picture = avcodec_alloc_frame();
              ^
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1113:33: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
    size = avpicture_get_size( (PixelFormat) pix_fmt, width, height);
                                ^~~~~~~~~~~
                                AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1122:25: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
                       (PixelFormat) pix_fmt, width, height);
                        ^~~~~~~~~~~
                        AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1230:19: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
    c->pix_fmt = (PixelFormat) pixel_format;
                  ^~~~~~~~~~~
                  AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1405:26: error: use of undeclared identifier
      'PIX_FMT_BGR24'; did you mean 'AV_PIX_FMT_BGR24'?
    if (input_pix_fmt == PIX_FMT_BGR24) {
                         ^~~~~~~~~~~~~
                         AV_PIX_FMT_BGR24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5: note: 'AV_PIX_FMT_BGR24' declared here
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1410:31: error: use of undeclared identifier
      'PIX_FMT_GRAY8'; did you mean 'AV_PIX_FMT_GRAY8'?
    else if (input_pix_fmt == PIX_FMT_GRAY8) {
                              ^~~~~~~~~~~~~
                              AV_PIX_FMT_GRAY8
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
    AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1423:25: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
                       (PixelFormat)input_pix_fmt, width, height);
                        ^~~~~~~~~~~
                        AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1429:47: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
                                             (PixelFormat)input_pix_fmt,
                                              ^~~~~~~~~~~
                                              AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1447:25: error: unknown type name 'PixelFormat'; did you
      mean 'AVPixelFormat'?
                       (PixelFormat)input_pix_fmt, width, height);
                        ^~~~~~~~~~~
                        AVPixelFormat
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
enum AVPixelFormat {
     ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1604:25: error: use of undeclared identifier
      'PIX_FMT_BGR24'; did you mean 'AV_PIX_FMT_BGR24'?
        input_pix_fmt = PIX_FMT_BGR24;
                        ^~~~~~~~~~~~~
                        AV_PIX_FMT_BGR24
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5: note: 'AV_PIX_FMT_BGR24' declared here
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1607:25: error: use of undeclared identifier
      'PIX_FMT_GRAY8'; did you mean 'AV_PIX_FMT_GRAY8'?
        input_pix_fmt = PIX_FMT_GRAY8;
                        ^~~~~~~~~~~~~
                        AV_PIX_FMT_GRAY8
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
    AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
    ^
In file included from /Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1683:25: error: use of undeclared identifier
      'PIX_FMT_YUV422P'; did you mean 'AV_PIX_FMT_YUV422P'?
        codec_pix_fmt = PIX_FMT_YUV422P;
                        ^~~~~~~~~~~~~~~
                        AV_PIX_FMT_YUV422P
/usr/local/Cellar/ffmpeg/3.3.4/include/libavutil/pixfmt.h:66:5: note: 'AV_PIX_FMT_YUV422P' declared here
    AV_PIX_FMT_YUV422P,   ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/Users/myuser/opencv/modules/videoio/src/cap_qtkit.mm:46:9: fatal error: 'QTKit/QTKit.h' file not found
#import <QTKit/QTKit.h>
        ^
1 error generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_qtkit.mm.o] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
[28%]构建CXX对象模块/videoio/cmakfiles/opencv\u videoio.dir/src/cap\u qtkit.mm.o
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:317:9:错误:使用未声明的标识符
“avcodec_免费_帧”;你的意思是“avcodec获取名称”吗?
avcodec_免费_帧(&picture);
^~~~~~~~~~~~~~~~~~
avcodec_获取_名称
/usr/local/cillar/ffmpeg/3.3.4/include/libavcodec/avcodec.h:6289:13:注意:此处声明了“avcodec\u get\u name”
const char*avcodec_get_name(枚举AVCodecID id);
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:317:28:错误:无法初始化类型为的参数
“enum AVCodecID”的右值类型为“AVFrame**”
avcodec_免费_帧(&picture);
^~~~~~~~
/usr/local/ceral/ffmpeg/3.3.4/include/libavcodec/avcodec.h:6289:45:注意:在此处将参数传递给参数“id”
const char*avcodec_get_name(枚举AVCodecID id);
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:632:23:错误:使用未声明的标识符
“avcodec\u alloc\u帧”
picture=avcodec_alloc_frame();
^
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:635:41:错误:使用未声明的标识符
“PIX_FMT_BGR24”;你是说“AV_PIX_FMT_BGR24”吗?
avpicture_get_尺寸(像素点FMT_BGR24,
^~~~~~~~~~~~~
AV_PIX_FMT_BGR24
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5:注意:此处声明了“AV_PIX_FMT_BGR24”
AV_PIX_FMT_BGR24,//<压缩RGB 8:8:8,24bpp,BGRBGR。。。
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:638:29:错误:使用未声明的标识符
“PIX_FMT_BGR24”;你是指“AV_PIX_FMT_BGR24”吗?
PIX_FMT_BGR24,附件->宽度,附件->高度);
^~~~~~~~~~~~~
AV_PIX_FMT_BGR24
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5:注意:此处声明了“AV_PIX_FMT_BGR24”
AV_PIX_FMT_BGR24,//<压缩RGB 8:8:8,24bpp,BGRBGR。。。
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:738:67:错误:使用未声明的标识符
‘PIX_FMT_RGB24’;你是说“AV_PIX_FMT_RGB24”吗?
avpicture_fill((avpicture*)和rgb_图片,rgb_图片。数据[0],PIX_FMT_RGB24,
^~~~~~~~~~~~~
AV_PIX_FMT_RGB24
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:64:5:注意:此处声明了“AV_PIX_FMT_RGB24”
AV_PIX_FMT_RGB24,//<压缩RGB 8:8:8,24bpp,RGBRGB。。。
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:756:17:错误:使用未声明的标识符
“PIX_FMT_BGR24”;你是指“AV_PIX_FMT_BGR24”吗?
PIX_FMT_BGR24,
^~~~~~~~~~~~~
AV_PIX_FMT_BGR24
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:65:5:注意:此处声明了“AV_PIX_FMT_BGR24”
AV_PIX_FMT_BGR24,//<压缩RGB 8:8:8,24bpp,BGRBGR。。。
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1110:15:错误:使用未声明的标识符
“avcodec\u alloc\u帧”
picture=avcodec_alloc_frame();
^
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1113:33:错误:未知类型名称“PixelFormat”;您知道吗
是指“AVPixelFormat”?
大小=avpicture\u get\u大小((像素格式)pix\u fmt、宽度、高度);
^~~~~~~~~~~
像素格式
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6:注意:此处声明了“AVPixelFormat”
枚举像素格式{
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1122:25:错误:未知类型名称“PixelFormat”;您知道吗
是指“AVPixelFormat”?
(像素格式)像素、宽度、高度);
^~~~~~~~~~~
像素格式
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6:注意:此处声明了“AVPixelFormat”
枚举像素格式{
^
在/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg.cpp:45中包含的文件中:
/Users/myuser/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1230:19:错误:未知类型名称“PixelFormat”;您知道吗
是指“AVPixelFormat”?
c->pix_fmt=(PixelFormat)pixel_格式;
^~~~~~~~~~~
像素格式
/usr/local/ceral/ffmpeg/3.3.4/include/libavutil/pixfmt.h:60:6:注意:此处声明了“AVPixelFormat”
枚举像素格式{