gpt4 book ai didi

OpenCV 加载和显示视频产生不准确的颜色

转载 作者:太空宇宙 更新时间:2023-11-03 21:54:53 25 4
gpt4 key购买 nike

我按照 OpenCV 中给出的示例进行视频显示,只是去掉了一些对我来说不必要的转换。我现在的代码加载视频文件然后显示它,问题是复制的视频有错误的颜色。

代码如下:

using namespace std;
using namespace cv;

// The main function

int main (int argc, char *argv[])
{

VideoCapture cap ("ETMI 002.mpg"); // Open the file

if (!cap.isOpened ()) // Check if opening was successful
cerr << "I have failed!" << endl;

else
{
Mat edges;
Mat frame;
namedWindow("edges",1);
while (cap.read (frame))
{
cvtColor(frame, edges, CV_BGR2RGB);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
}

return 0;

最佳答案

避免在转载的视频中发生变形
imshow("edges", edges)
imshow("边", frame)

while (cap.read (frame))
{
cvtColor(frame, edges, CV_BGR2RGB);

// here is the change you are showing the converted image
// just simply add the original read frame

imshow("edges", frame); // here
if(waitKey(30) >= 0) break;
}

关于OpenCV 加载和显示视频产生不准确的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11224410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com