//Playing a video with OpenCV
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
int main(int argc, char** argv) {
cv::namedWindow("Example3", cv::WINDOW_AUTOSIZE);
cv::VideoCapture cap;
cap.open(string(argv[1]));
cv::Mat frame;
while (1) {
cap >> frame;
if (!frame.data) break; // Ran out of film
cv::imshow("Example3", frame);
if (cv::waitKey(33) >= 0) break;
}
}
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
Mat img=imread("pic.jpg");//读入一张图片
namedWindow("Test"); //创建一个名为Test窗口
imshow("Test",img); //窗口中显示图像
waitKey(5000); //等待5000ms后窗口自动关闭
} */
/*
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main() {
Mat img = imread("pic.jpg");
if (img.empty()) return -1;
namedWindow("Example2", WINDOW_AUTOSIZE);
imshow("Example2", img);
waitKey(0);
destroyWindow("Example2");
}
opencv读入图像和avi
最新推荐文章于 2024-07-02 16:41:55 发布