zoukankan      html  css  js  c++  java
  • opencv3.1 压缩并拼图

    必须有重叠才能拼,压缩越多,拼接越快


    #include <opencv2opencv.hpp>
    #include <opencv2stitching.hpp>
    using namespace cv;
    using namespace std;
    
    vector<Mat> imgs;
    string result_name = "result.jpg";
    double fScale = 0.1;
    const int LEN = 12;
    
    string str[LEN] = {
    	"F://1.jpg",
    	"F://2.jpg", 
    	"F://3.jpg",
    	"F://4.jpg",
    	"F://5.jpg",
    	"F://6.jpg",
    	"F://7.jpg",
    	"F://8.jpg",
    	"F://9.jpg",
    	"F://10.jpg",
    	"F://11.jpg",
    	"F://12.jpg"
    
    };
    
    void AddPic(string picURL)
    {
    	Mat pic = imread(picURL);
    	Size dsize = Size(pic.cols*fScale, pic.rows*fScale);
    	Mat pic2 = Mat(dsize, CV_32S);
    	resize(pic, pic2, dsize);
    	imgs.push_back(pic2);
    }
    
    int main()
    {
    	for (int i = 0; i < LEN; i++) 
    	{
    		AddPic(str[i]);
    	}
    
    	Mat pano;
    	
    	Stitcher stitcher = Stitcher::createDefault(true);
    	Stitcher::Status status = stitcher.stitch(imgs, pano);
    
    	if (status != Stitcher::OK)
    	{
    		cout << "Can't stitch images, error code = " << status << endl;
    		return -1;
    	}
    
    	imwrite(result_name, pano);
    
    	waitKey(0);
    
    }




  • 相关阅读:
    adb
    js百分比
    隐私策略
    JSON.parse&JSON.stringify
    MVC内容backgroundimage: url('')问题
    mvc笔记
    winform路径
    配置
    邮件发送的原理
    如何调试Windows服务
  • 原文地址:https://www.cnblogs.com/nafio/p/9137296.html
Copyright © 2011-2022 走看看