OpenCV 3 错误"CV_FOURCC":找不到标识符
OpenCV 3 error 'CV_FOURCC': identifier not found
刚刚用Visual Studio 2013在PC上构建了OpenCV 3,现在我正在尝试代码,但遗憾的是,我不知道出了什么问题?
#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"。
编辑:
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的后续版本中,这一点似乎已经更改为cv::VideoWriter::fourcc(...)
,其中...
是四个字符的逗号分隔列表。
有关OpenCV 3.4的更多信息,请点击此处:https://docs.opencv.org/3.4/dd/d9e/classcv_1_1VideoWriter.html#afec93f94dc6c0b3e28f4dd153bc5a7f0
我使用了糟糕的OpenCV源代码来构建我的库。
相关文章:
- 设置 Visual Studio for MPI: 找不到标识符错误
- 找不到标识符合并
- 从子类访问模板类成员时出现"找不到标识符"错误
- OpenCV 3 错误"CV_FOURCC":找不到标识符
- im调用函数时找不到标识符?
- clock_gettime:在 Windows 10 的 Visual Studio 中找不到标识符
- 英特尔 TBB - "初始化关键部分 Ex":找不到标识符编译器错误
- 找不到标识符.C3861
- 在void tryagain()上找不到标识符
- 在C 类中找不到标识符
- 找不到标识符,尝试在 C++ 中显示数组值
- 我遇到:错误2错误C3861:"fx":找不到标识符
- OpenGL - 'glTexSubImage3D':找不到标识符
- "GetProcessIdOfThread":找不到标识符
- 错误 C3861:"strcpy_y":找不到标识符
- "printf":找不到标识符
- 错误 C3861:"initNode":找不到标识符
- 在抽象类中找不到C++标识符
- 错误 C3861:"getGaborKernel":找不到标识符
- 错误 C3861:"对齐":找不到标识符