opencv

来源:互联网 发布:建表外键sql 编辑:程序博客网 时间:2024/06/05 00:51
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