首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenCV 3错误'CV_FOURCC':找不到标识符

OpenCV 3错误'CV_FOURCC':找不到标识符
EN

Stack Overflow用户
提问于 2018-08-01 10:08:17
回答 2查看 9.6K关注 0票数 5

刚刚用Visual Studio2013在PC上构建了OpenCV 3,现在我正在尝试编写代码,但遗憾的是,我找不到哪里出了问题?

代码语言:javascript
复制
#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main() {

    VideoCapture vcap(0);
    if (!vcap.isOpened()) {
        cout << "Error opening video stream or file" << endl;
        return -1;
    }

    int frame_width = vcap.get(cv::CAP_PROP_FRAME_WIDTH);
    int frame_height = vcap.get(cv::CAP_PROP_FRAME_HEIGHT);
    VideoWriter video("out.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(frame_width, frame_height), true);

    for (;;) {

        Mat frame;
        vcap >> frame;
        video.write(frame);
        imshow("Frame", frame);
        char c = (char)waitKey(33);
        if (c == 27) break;
    }
    return 0;


1>------ Build started: Project: ConsoleApplication12, Configuration: Release x64 ------
1>  Source.cpp
1>Source.cpp(21): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>Source.cpp(22): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>Source.cpp(23): error C3861: 'CV_FOURCC': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我想不出用什么来代替"CV_FOURCC“。

编辑:

代码语言:javascript
复制
int frame_width = vcap.get(cv::CAP_PROP_FRAME_WIDTH);
    int frame_height = vcap.get(cv::CAP_PROP_FRAME_HEIGHT);
    int codec = cv::VideoWriter::fourcc('M', 'J', 'P', 'G');
    VideoWriter video("out.avi", codec, 10, Size(frame_width, frame_height), true);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-08-01 23:40:37

我使用了糟糕的OpenCV源代码来构建我的库。

票数 -2
EN

Stack Overflow用户

发布于 2019-03-24 07:00:55

在更高版本的OpenCV中,这似乎已经更改为cv::VideoWriter::fourcc(...),其中...是由四个字符逗号分隔的列表。

有关OpenCV 3.4的更多信息,请访问:https://docs.opencv.org/3.4/dd/d9e/classcv_1_1VideoWriter.html#afec93f94dc6c0b3e28f4dd153bc5a7f0

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51624448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档