视觉SLAM十四讲 Ubuntu20.04 Pangolin 环境配置

视觉SLAM十四讲 Ubuntu20.04 Pangolin 环境配置

一. github下载源代码

选择0.5版本的,要不然版本装高了编译ORB-SLAM2会遇到问题

二. 报错及处理

  1. error: ‘AV_PIX_FMT_XVMC_MPEG2_MC’ was not declared in this scope
    详细报错信息

/home/andy/Downloads/Pangolin/src/video/drivers/ffmpeg.cpp: In function ‘std::__cxx11::string pangolin::FfmpegFmtToString(AVPixelFormat)’:
/home/andy/Downloads/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_XVMC_MPEG2_MC’ was not declared in this scope

参考:https://github.com/stevenlovegrove/Pangolin/pull/318/files?diff=split&w=0
解决办法:在/Pangolin/CMakeModules/FindFFMPEG.cmake中63,64行

        sizeof(AVFormatContext::max_analyze_duration2);
      }" HAVE_FFMPEG_MAX_ANALYZE_DURATION2

换成

        sizeof(AVFormatContext::max_analyze_duration);
      }" HAVE_FFMPEG_MAX_ANALYZE_DURATION

/Pangolin/src/video/drivers/ffmpeg.cpp中第37行 namespace pangolin上面加上

#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER

第78,79行

TEST_PIX_FMT_RETURN(XVMC_MPEG2_MC); 
TEST_PIX_FMT_RETURN(XVMC_MPEG2_IDCT);

改为

#ifdef FF_API_XVMC
    TEST_PIX_FMT_RETURN(XVMC_MPEG2_MC);
    TEST_PIX_FMT_RETURN(XVMC_MPEG2_IDCT);
#endif

101-105行

    TEST_PIX_FMT_RETURN(VDPAU_H264);
    TEST_PIX_FMT_RETURN(VDPAU_MPEG1);
    TEST_PIX_FMT_RETURN(VDPAU_MPEG2);
    TEST_PIX_FMT_RETURN(VDPAU_WMV3);
    TEST_PIX_FMT_RETURN(VDPAU_VC1);

改为

#ifdef FF_API_VDPAU
    TEST_PIX_FMT_RETURN(VDPAU_H264);
    TEST_PIX_FMT_RETURN(VDPAU_MPEG1);
    TEST_PIX_FMT_RETURN(VDPAU_MPEG2);
    TEST_PIX_FMT_RETURN(VDPAU_WMV3);
    TEST_PIX_FMT_RETURN(VDPAU_VC1);
#endif

127行

	TEST_PIX_FMT_RETURN(VDPAU_MPEG4);

改为

#ifdef FF_API_VDPAU
    TEST_PIX_FMT_RETURN(VDPAU_MPEG4);
#endif
  1. error: ‘AVFMT_RAWPICTURE’ was not declared in this scope

#define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt; /home/andy/Downloads/Pangolin/src/video/drivers/ffmpeg.cpp: In member
function ‘void
pangolin::FfmpegVideoOutputStream::WriteFrame(AVFrame*)’:
/home/andy/Downloads/Pangolin/src/video/drivers/ffmpeg.cpp:572:39:
error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if (recorder.oc->oformat->flags & AVFMT_RAWPICTURE) {

解决办法,在Pangolin/include/pangolin/video/drivers/ffmpeg.h开头加上

#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

参考: https://www.jianshu.com/p/da49a712410f

你可能感兴趣的:(Computer,Vision,c++,slam)