#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
using namespace cv;
void gradient(cv::Mat& im1_src, cv::Mat& im2_src, VideoWriter writer, const char* save_pth_video) { cv::resize(im1_src, im1_src, cv::Size(im2_src.cols, im2_src.rows), 0, 0, cv::INTER_CUBIC);
cv::Mat im_src_blur1, im_src_blur2, im_src_blur3, im_src_blur4, im_src_blur5, im_src_blur6, im_src_blur7, im_src_blur8, im_src_blur9; cv::Mat im_src_blur10, im_src_blur0;
im_src_blur0 = 1 * im1_src + 0 * im2_src; im_src_blur1 = 0.9*im1_src + 0.1*im2_src; im_src_blur2 = 0.8*im1_src + 0.2*im2_src; im_src_blur3 = 0.7*im1_src + 0.3*im2_src; im_src_blur4 = 0.6*im1_src + 0.4*im2_src; im_src_blur5 = 0.5*im1_src + 0.5*im2_src; im_src_blur6 = 0.4*im1_src + 0.6*im2_src; im_src_blur7 = 0.3*im1_src + 0.7*im2_src; im_src_blur8 = 0.2*im1_src + 0.8*im2_src; im_src_blur9 = 0.1*im1_src + 0.9*im2_src; im_src_blur10 = 0 * im1_src + 1 * im2_src;
cv::Size size = im_src_blur10.size(); writer.open(save_pth_video, CV_FOURCC(‘M‘, ‘J‘, ‘P‘, ‘G‘), 2, size, true); writer.write(im_src_blur0); writer.write(im_src_blur1); writer.write(im_src_blur2); writer.write(im_src_blur3); writer.write(im_src_blur4); writer.write(im_src_blur5); writer.write(im_src_blur6); writer.write(im_src_blur7); writer.write(im_src_blur8); writer.write(im_src_blur9); writer.write(im_src_blur10); }
int main() { const char* save_pth_video = "a_result.avi"; const char* im1_pth = "./pic/1.png"; const char* im2_pth = "./pic/2.png";
cv::Mat im1_src = cv::imread(im1_pth); cv::Mat im2_src = cv::imread(im2_pth); VideoWriter writer; gradient(im1_src, im2_src, writer, save_pth_video);
return 0; }
|