opencv

opencvApplicantion::opencvApplicantion(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    connect(ui.ImportButton,SIGNAL(clicked()),this,SLOT(slotImportPicture()));
    connect(ui.ExportButton,SIGNAL(clicked()),this,SLOT(slotExportPicture()));
    //对表格进行设置
    ui.tableView->setModel(content);
    content->setItem(0,0,new QStandardItem(" "));
    content->setItem(0,1,new QStandardItem("detect time"));
    content->setItem(0,2,new QStandardItem("Extractor time"));
    content->setItem(0,3,new QStandardItem("match time"));
    content->setItem(0,4,new QStandardItem("choose time"));
    content->setItem(0,5,new QStandardItem("RANSAC time"));
    content->setItem(0,6,new QStandardItem("location judging time"));
    content->setItem(0,7,new QStandardItem(" montage time"));
    //QTableView *table=ui.tableView;
    //table->setItem("1","1","1");
}

opencvApplicantion::~opencvApplicantion()
{

}
void opencvApplicantion::slotImportPicture()
{
    //选择导入的图片
    QStringList files = QFileDialog::getOpenFileNames(
        this,
        "Select one or more files to open",
        "/home",
        "Images ( *.jpg)");
    if (files.size()<2)
    {
        cout<<"图片少于两张无法拼接"<<endl;
    }
    else
    {
        Mat img1 = imread("Img0.jpg");//namepath.toStdString().c_str())
        clock_t start, finish;
        double totaltime;
        start = clock();
        cv::resize(img1, img1, Size(img1.cols / 4, img1.rows / 4));
        for (int k = 1; k <files.size(); k++) {
            stringstream stream;  
            string str;  
            stream << k;  
            stream >> str;  
            string filename = "Img"+str + ".jpg"; 
            Mat img = imread(filename);
            cv::resize(img, img, Size(img.cols / 4, img.rows / 4));
            stitchedImage = Stitched(img1, img,k);
            img1 = stitchedImage;
        }
        finish = clock();
        totaltime = (double)(finish - start) / CLOCKS_PER_SEC;
        cout << "拼接成功" << endl;
        cout << "拼接花费总时间为:" << totaltime << "秒!" << endl;
        imshow("ResultImage", stitchedImage);   
        waitKey(0);
    }
}
void opencvApplicantion::slotExportPicture()
{
    imwrite("ResultImage.jpg", stitchedImage);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值