OpenCV 3错误"CV_FOURCC":找不到标识符 [英] OpenCV 3 error 'CV_FOURCC': identifier not found

查看:1205
本文介绍了OpenCV 3错误"CV_FOURCC":找不到标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在使用Visual Studio 2013的PC上构建了OpenCV 3,现在我正在尝试代码,但可悲的是我不知道出了什么问题?

Just built OpenCV 3 on PC with Visual Studio 2013 and now I'm trying code but sadly I can't figure out what's wrong?

#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".

Couldn't figure out with what I have to replace "CV_FOURCC".

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);

推荐答案

我使用了错误的OpenCV源来构建我的库.

I used bad OpenCV source to build my libraries.

这篇关于OpenCV 3错误"CV_FOURCC":找不到标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆