static int StaticVideo_test(std::string videodir) { { VideoCapture capture; capture.open(videodir); double rate = capture.get(CAP_PROP_FPS); int delay = cvRound(1000.000 / rate); vector<Mat> src_res_images; vector<Mat> res_images; cv::Mat img, src_res_img; int num = 0; while (true) { capture >> img; if (img.empty()) { break; } else { 处理img,得到result_im cv::Mat result_im; hconcat(suitable_img, result_im, src_res_img); res_images.push_back(result_im); src_res_images.push_back(src_res_img); if (&src_asvl != NULL) { free(src_asvl.ppu8Plane[0]); } if (&dst_asvl != NULL) { free(dst_asvl.ppu8Plane[0]); } imshow("result", src_res_img); char c = waitKey(1); if (c == 27) { break; } } } if (res_images.size() > 0) { cv::Mat frame = res_images[0]; int ht = frame.rows; int wt = frame.cols; VideoWriter writer("result.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), rate, Size(wt, ht)); for (size_t i = 0; i < res_images.size(); i++) { frame = res_images[i].clone(); if (!frame.empty()) { writer.write(frame); } } writer.release(); } } return 0; }