Cursor opencv读取gif图片

360影视 2025-01-13 19:37 2

摘要:#include #include void displayGifUsingVideoCapture { const std::string filename = "C:\\Users\\Admini

opencv默认情况下是不支持读取Gif图片的,不过借助Cursor的ai功能,我们可以实现在opencv功能中实现对gif图片的读取

实现代码如下:

#include #include void displayGifUsingVideoCapture { const std::string filename = "C:\\Users\\Administrator\\Desktop\\CursorVs2022\\emotion_d0018.gif"; cv::VideoCapture cap(filename); if (!cap.isOpened) { std::cout > frame; if (frame.empty) { cap.set(cv::CAP_PROP_POS_frameS, 0); // 循环播放 continue; } cv::imshow("GIF Animation", frame); // 等待33ms,约30fps,如果按下ESC键则退出 if (cv::waitKey(33) == 27) { break; } } cap.release; cv::destroyAllWindows;}int main { displayGifUsingVideoCapture; return 0;}

来源:新手村养牛

相关推荐