void image2video()
{
// ¹¹ÔìÒ»žöVideoWriter
VideoWriter video("test.avi", CV_FOURCC('M', 'J', 'P', 'G'), 501, Size(1920, 1080));
String pattern = "G:\\ºœÅÄÊýŸÝ\\tozfb\\*.jpg";
vector<String> fn;
glob(pattern, fn, false);
size_t count = fn.size();
for (size_t i = 0; i < count; i++)
{
Mat image = imread(fn[i]);
video << image;
}
cout << "ŽŠÀíÍê±Ï£¡" << endl;
}
void jpg2png()
{
string imgFloder = "G:\\DataSet\\ºœÅÄÊýŸÝ\\basketball_court";
string path2png = "G:\\DataSet\\ºœÅÄÊýŸÝ\\basketball_png\\";
std::vector<cv::String> img_names;
cv::glob(imgFloder, img_names); //read images from floder
int num_images = img_names.size();
cout << "number of stitch image : " << img_names.size() << endl;
int i = 0;
for (cv::String name : img_names)
{
cv::Mat image = cv::imread(name);
char ss[10];
sprintf(ss, "%04d", i++);
string path = path2png + string(ss) + ".png";
std::cout << "ori name£º" << name << std::endl;
std::cout << " mod name:" << path << std::endl;
cv::imwrite(path, image);
}
std::cout << "ŽŠÀíÍê±Ï" << std::endl;
}
void toFrame()
{
string videoPath = "/home/frank804/Documents/python/tool/DJI_0001.MP4";
string imagesPath = "/home/frank804/Documents/python/tool/png/";
VideoCapture cap;
cap.open(videoPath);
if (cap.isOpened())
{
Mat frame;
int n = 0;
while (cap.read(frame))
{
imshow("frame", frame);
waitKey(10);
char imgPath[256];
sprintf(imgPath, "%s%04d.png", imagesPath.c_str(), n++);
imwrite(imgPath, frame);
}
cap.release();
}
else
{
cout << "Can't open the video file!" << endl;
return ;
}
std::cout<<"successfully getting frame sequences !!!!"<<std::endl;
return ;
}