标签:
所用头文件
#include <opencv2/opencv.hpp> #include <iostream> #include <fstream>
void DrawImage() { string filepath = "/home/yang/Datasets/lfpw/testset/Path_Images.txt"; ifstream fin; fin.open(filepath.c_str()); //string类型转为字符串类型 string name; while (getline(fin, name)) { name.erase(0, name.find_first_not_of(" ")); name.erase(name.find_last_not_of(" ")); cv::Mat image = cv::imread(name, 1);//读取图片 cv::Mat img_gray; cvtColor(image, img_gray, CV_BGR2GRAY); cv::imshow("result", image);//显示 cv::waitKey(0); } fin.close(); }
void ShowAVI() { string filepath = "768x576.avi"; CvCapture* capture = 0; IplImage* iplImg; cv::Mat frame, frameCopy; capture = cvCaptureFromAVI(filepath.c_str()); if (!capture) cout << "Capture from AVI didn‘t work" << endl; while (1) { iplImg = cvQueryFrame(capture); frame = iplImg; if (frame.empty()) break; cv::imshow("result", frame); if (cv::waitKey(33) >= 0)//按任意键推出waitKey返回所按键盘的ASCII码 goto _cleanup_; } cv::waitKey(0); _cleanup_: cvReleaseCapture(&capture); }
标签:
原文地址:http://www.cnblogs.com/xuanyuyt/p/5597129.html