【維普】軟件工程-基于OpenCV和SSD深度學(xué)習(xí)模型的變電站壓板識別軟件設(shè)計(jì)_第1頁
【維普】軟件工程-基于OpenCV和SSD深度學(xué)習(xí)模型的變電站壓板識別軟件設(shè)計(jì)_第2頁
【維普】軟件工程-基于OpenCV和SSD深度學(xué)習(xí)模型的變電站壓板識別軟件設(shè)計(jì)_第3頁
【維普】軟件工程-基于OpenCV和SSD深度學(xué)習(xí)模型的變電站壓板識別軟件設(shè)計(jì)_第4頁
【維普】軟件工程-基于OpenCV和SSD深度學(xué)習(xí)模型的變電站壓板識別軟件設(shè)計(jì)_第5頁
已閱讀5頁,還剩40頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

目錄附錄附錄A:登錄注冊模塊核心代碼voidgui::loginButton_clicked(){username=this->usernameEdit->text();password=this->passwordEdit->text();db=QSqlDatabase::addDatabase("QSQLITE");db.setDatabaseName("users.db");if(!db.open()){//如果數(shù)據(jù)庫無法打開,則打印錯(cuò)誤信息并返回qWarning()<<"Failedtoopendatabase:";return;}QSqlQueryquery;query.prepare("SELECT*FROMinfoWHEREusername=?ANDpassword=?");query.bindValue(0,username);query.bindValue(1,password);if(query.exec()&&query.next()){qDebug()<<"Loginsuccessful";//accept();mainPage=newMainPage;this->hide();main>show();main>getUsername(username);//這個(gè)地方還得增加以下mainPage的初始化過程connect(mainPage,&MainPage::back,[=](){//監(jiān)聽發(fā)出關(guān)閉信號main>hide();this->show();});}else{qDebug()<<"Invalidusernameorpassword";QMessageBoxmessageBox;messageBox.setWindowTitle(QString::fromLocal8Bit("提示"));messageBox.setIcon(QMessageBox::Icon::Warning);messageBox.setText(QString::fromLocal8Bit("用戶名或密碼輸入有誤,不存在!"));messageBox.exec();//顯示彈窗}db.close();}附錄B:信息管理模塊核心代碼/*識別上傳*/QFileDialog*fileDialog=newQFileDialog(this);fileDialog->setFileMode(QFileDialog::Directory);//設(shè)置窗口的標(biāo)題fileDialog->setWindowTitle(QString::fromLocal8Bit("請選擇單張或多張圖片"));//也可以使用下面代碼設(shè)置多個(gè)過濾器QStringListfilters;filters<<"Imagefiles(*.png*.xpm*.jpg)";fileDialog->setNameFilters(filters);//這個(gè)函數(shù)名稱后面多了一個(gè)s,表示設(shè)置多個(gè)過濾器。要看清楚。//QFileDialog::ExistingFiles多個(gè)文件,還可以用來選擇文件夾QFileDialog::Directory。fileDialog->setFileMode(QFileDialog::ExistingFiles);//彈出對話框if(fileDialog->exec()==QDialog::Accepted){QStringListlistFiles=fileDialog->selectedFiles();for(autofileName:listFiles){//qDebug()<<"文件名稱:"<<fileName;//這里實(shí)際是完整路徑//(0,0,0)-(1,0,1)-(0,0,2)...std::stringdet_boxes=detect_algo(fileName.toStdString());//路徑不要有中文//先去查數(shù)據(jù)庫看有沒有,有的話就更新,沒有的話就插入updateInsertDet(fileName,det_boxes);}QMessageBoxmessageBox;messageBox.setWindowTitle(QString::fromLocal8Bit("提示"));//messageBox.setIcon(QMessageBox::Icon::Warning);messageBox.setText(QString::fromLocal8Bit("上傳成功!"));//QString::fromStdString(str)messageBox.exec();//顯示彈窗}else{QMessageBoxmessageBox;messageBox.setWindowTitle(QString::fromLocal8Bit("提示"));messageBox.setIcon(QMessageBox::Icon::Warning);messageBox.setText(QString::fromLocal8Bit("未選擇任何圖片,請重新上傳!"));//QString::fromStdString(str)messageBox.exec();//顯示彈窗return;/*查詢*/QSqlDatabasedb=QSqlDatabase::addDatabase("QSQLITE");db.setDatabaseName("users.db");//db.exec("PRAGMAencoding='UTF-8';");//必須加這個(gè),不然亂碼的if(!db.open()){//如果數(shù)據(jù)庫無法打開,則打印錯(cuò)誤信息并返回qWarning()<<"Failedtoopendatabase:";return;}QSqlQueryquery;query.prepare("SELECT*FROMdetect");if(!query.exec()){//Handleerror}//comboBox=newQComboBox(this);//comboBox->setGeometry(50,50,100,30);vec_file_path.erase(vec_file_path.begin(),vec_file_path.end());//清空vectorvec_det_res.erase(vec_det_res.begin(),vec_det_res.end());//清空vector//Processtheresultswhile(query.next()){QSqlRecordrecord=query.record();QStringfile_path=record.value("file_path").toString();//intid=record.value("id").toInt();QStringdet_res=record.value("det_res").toString();vec_file_path.push_back(file_path);//vec_det_res.push_back(det_res);}db.close();queryPkg->show();queryPkg->setComBox(vec_file_path);附錄C:圖片預(yù)處理核心代碼{Blob<float>*input_layer=net_->input_blobs()[0];input_layer->Reshape(1,num_channels_,input_geometry_.height,input_geometry_.width);/*前向維度更改到所有層Forwarddimensionchangetoalllayers.*/net_->Reshape();std::vector<cv::Mat>input_channels;WrapInputLayer(&input_channels);Preprocess(img,&input_channels);net_->Forward();/*將輸出層復(fù)制到std::vectorCopytheoutputlayertoastd::vector*/Blob<float>*result_blob=net_->output_blobs()[0];constfloat*result=result_blob->cpu_data();constintnum_det=result_blob->height();vector<vector<float>>detections;for(intk=0;k<num_det;++k){if(result[0]==-1){//跳過無效檢測Skipinvaliddetection.result+=7;continue;}vector<float>detection(result,result+7);detections.push_back(detection);result+=7;}returndetections;}voidDetector::Preprocess(constcv::Mat&img,std::vector<cv::Mat>*input_channels){/*將輸入圖像轉(zhuǎn)換為網(wǎng)絡(luò)的輸入圖像格式。*Converttheinputimagetotheinputimageformatofthenetwork.*/cv::Matsample;if(img.channels()==3&&num_channels_==1)cv::cvtColor(img,sample,cv::COLOR_BGR2GRAY);elseif(img.channels()==4&&num_channels_==1)cv::cvtColor(img,sample,cv::COLOR_BGRA2GRAY);elseif(img.channels()==4&&num_channels_==3)cv::cvtColor(img,sample,cv::COLOR_BGRA2BGR);elseif(img.channels()==1&&num_channels_==3)cv::cvtColor(img,sample,cv::COLOR_GRAY2BGR);elsesample=img;cv::Matsample_resized;if(sample.size()!=input_geometry_)cv::resize(sample,sample_resized,input_geometry_);elsesample_resized=sample;cv::Matsample_float;if(num_channels_==3)sample_resized.convertTo(sample_float,CV_32FC3);elsesample_resized.convertTo(sample_float,CV_32FC1);cv::Matsample_normalized;cv::subtract(sample_float,mean_,sample_normalized);/*該操作將把單獨(dú)的BGR平面直接寫入網(wǎng)絡(luò)的輸入層,因?yàn)樗籧v::Mat包裹input_channels中的對象*/cv::split(sample_normalized,*input_channels);CHECK(reinterpret_cast<float*>(input_channels->at(0).data)==net_->input_blobs()[0]->cpu_data())<<"Inputchannelsarenotwrappingtheinputlayerofthenetwork.";}附錄D:SSD深度學(xué)習(xí)模型訓(xùn)練核心代碼#Directorywhichstoresthemodel.prototxtfile.save_dir="models/VGGNet/yaban_voc/{}".format(job_name)#Directorywhichstoresthesnapshotofmodels.snapshot_dir="models/VGGNet/yaban_voc/{}".format(job_name)#Directorywhichstoresthejobscriptandlogfile.job_dir="models/VGGNet/yaban_job/{}".format(job_name)#Directorywhichstoresthedetectionresults.output_result_dir="{}/data/VOCdevkit/results/VOC2007/{}/Main".f

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論