对于opencv已经比较熟悉了,这里记录使用过程中的问题
2 opencv4.0.0里面CV_FOURCC找不到标识符
在opencv4.0.0中已经对CV_FOURCC进行了改变,如下图所示,CV_FOURCC(‘P’, ‘I’, ‘M’, ‘1’)CV_FOURCC(‘M’,‘J’,‘P’,‘G’),已经改为CAP_OPENCV_MJPEG
fourcc 4-character code of codec used to compress the frames. For example, VideoWriter::fourcc(‘P’,‘I’,‘M’,‘1’) is a MPEG-1 codec, VideoWriter::fourcc(‘M’,‘J’,‘P’,‘G’) is a motion-jpeg codec etc. List of codes can be obtained at Video Codecs by FOURCC page. FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.
3 opencv4 里面CV_LOAD_IMAGE_ANYDEPTH和CV_LOAD_IMAGE_ANYCOLOR
1.opencv4以上版本报错:CV_LOAD_IMAGE_COLOR和CV_BGR2HSV和CV_CAP_PROP_FRAME_WIDTH
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
4 OpenCV4未定义标识符CV_RGB2GRAY
enum cv::ColorConversionCodes {
cv::COLOR_BGR2BGRA = 0,
cv::COLOR_RGB2RGBA = COLOR_BGR2BGRA,
cv::COLOR_BGRA2BGR = 1,
cv::COLOR_RGBA2RGB = COLOR_BGRA2BGR,
cv::COLOR_BGR2RGBA = 2,
cv::COLOR_RGB2BGRA = COLOR_BGR2RGBA,
cv::COLOR_RGBA2BGR = 3,
cv::COLOR_BGRA2RGB = COLOR_RGBA2BGR,
cv::COLOR_BGR2RGB = 4,