資源簡介
之前的改進,帶imagePoint 到 worldPoint的例子,圖中可以讀出來約-45mm,qDebug到控制臺為-44.8mm。(之前的刪不了只好再發了)
opencv3 + qt5-mingw32,在pro中配置好mingw32編譯的opencv庫路徑就可以運行了。識別二維碼定位符位置??梢杂脕順擞浧矫孢\動物體,然后相機拍攝跟蹤位置。抗干擾能力max,主要識別程序從zxing源碼中改編過來的,在FinderPattern finderPatternFinder倆個類中。使用方法很簡單,在Detector::centermeasure中:FinderPatternFinder finder(src); finder.find();
代碼片段和文件信息
#include?“Detector.h“
#include?
#include?
#include?
#include?
#include?“finderpatternfinder.h“
Detector::Detector()
{
????testParam?=?new?testparamset;
????initMat();
}
cv::Mat?Detector::testAction(cv::Mat&?src)
{
????cv::Mat?backg;
//????if(testParam->do1){
????cv::Mat?imagePoint?=?getImagePoint(src);
????//test?pointToWorld?here
????cv::Vec2f?worldPoint?=?calWorldPoint(imagePoint);
???qDebug()<<“worldPoint?is:“<
????????cv::Vec4i?rowLineAvecolLineAve;
????????std::vector?lines;
????????rowLineAve[1]=rowLineAve[3]=AveRow;
????????rowLineAve[0]=0;
????????rowLineAve[2]=src.cols-1;
????????colLineAve[0]=colLineAve[2]=AveCol;
????????colLineAve[1]=0;
????????colLineAve[3]=src.rows-1;
????????lines.clear();
????????lines.push_back(rowLineAve);
????????lines.push_back(colLineAve);
????????backg?=?drawLines(srclinescv::Scalar(00255));
//????}
????return?backg;
}
void?Detector::initMat()
{
????rotateMat?=?(cv::Mat_(3?3)?<0.9983-0.0447-0.0385
???????????????????????????????????????????-0.04320.9983-0.0399
?????????????????????????????????????????????0.04030.03820.9985);
????intricMat?=?(cv::Mat_(3?3)?<5126.600
???????????????????????????????????????????05127.20
??????????????????????????????????????????1017.7841.91581);
????transMat?=?(cv::Mat_(1?3)?<-8.4226-36.8412628.8406);
}
cv::Mat?Detector::getImagePoint(cv::Mat?&src)
{
????cv::Mat?graySrc;
????if(src.channels()>1){
???????cv::cvtColor(srcgraySrcCV_BGR2GRAY);?
????}else{
????????graySrc?=?src;
????}
????graySrc.convertTo(graySrcCV_8UC1);
????cv::Mat?binarySrc;
????int?blockSize?=?src.rows/8;
????if(blockSize%2==0){
????????blockSize++;
????}
????cv::adaptiveThreshold(graySrcbinarySrc255CV_ADAPTIVE_THRESH_MEAN_CCV_THRESH_BINARYblockSize10);
?//???cv::medianBlur(binarySrc?binarySrc?5);
????float?centerRow?=?centerRecognize(binarySrctrue);
????float?centerCol?=?centerRecognize(binarySrcfalse);
//????qDebug()<<“centerRow:?“< //????qDebug()<<“centerCol:?“<
//????int?count?=?cv::countNonZero(graySrc);
//????qDebug()< //????Q_ASSERT_X(centerRow?>?0?“error“?“no?remark?found“);
//????Q_ASSERT_X(centerCol?>?0?“error“?“no?remark?found“);
????cv::Mat?imPoint(13CV_32FC1);
????imPoint.at(00)=?centerCol;
????imPoint.at(01)=?centerRow;
????imPoint.at(02)=?1.0;
????if(src.channels()>1){
????????src?=?binarySrc;
????????cv::cvtColor(srcsrcCV_GRAY2BGR);
????}else{
????????src?=?binarySrc;
????}
????return?imPoint;
}
float?Detector::centerRecognize(cv::Mat?&src?bool?rowORcol)
{
????FinderPatternFinder?finder(src);
????finder.find();
????QList?pattern?=?finder.possibleCenters;
????int?centerCount=0;
????int?bestOne=0;
????int?centerRow=0;
????int?centerCol=0;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-18?02:03??cameraLoc\
?????目錄???????????0??2016-08-18?01:56??cameraLoc\.git\
?????文件?????????333??2016-08-17?18:29??cameraLoc\.git\config
?????文件??????????73??2016-08-17?18:23??cameraLoc\.git\desc
?????文件??????????63??2016-08-18?01:23??cameraLoc\.git\FETCH_HEAD
?????文件??????????23??2016-08-17?18:23??cameraLoc\.git\HEAD
?????目錄???????????0??2016-08-17?18:23??cameraLoc\.git\hooks\
?????文件?????????478??2016-08-17?18:23??cameraLoc\.git\hooks\applypatch-msg.sample
?????文件?????????896??2016-08-17?18:23??cameraLoc\.git\hooks\commit-msg.sample
?????文件?????????189??2016-08-17?18:23??cameraLoc\.git\hooks\post-update.sample
?????文件?????????424??2016-08-17?18:23??cameraLoc\.git\hooks\pre-applypatch.sample
?????文件????????1642??2016-08-17?18:23??cameraLoc\.git\hooks\pre-commit.sample
?????文件????????1348??2016-08-17?18:23??cameraLoc\.git\hooks\pre-push.sample
?????文件????????4951??2016-08-17?18:23??cameraLoc\.git\hooks\pre-reba
?????文件????????1239??2016-08-17?18:23??cameraLoc\.git\hooks\prepare-commit-msg.sample
?????文件????????3611??2016-08-17?18:23??cameraLoc\.git\hooks\update.sample
?????文件????????2897??2016-08-18?01:56??cameraLoc\.git\index
?????目錄???????????0??2016-08-17?18:23??cameraLoc\.git\info\
?????文件?????????240??2016-08-17?18:23??cameraLoc\.git\info\exclude
?????目錄???????????0??2016-08-17?18:25??cameraLoc\.git\logs\
?????文件?????????449??2016-08-18?01:56??cameraLoc\.git\logs\HEAD
?????目錄???????????0??2016-08-17?18:26??cameraLoc\.git\logs\refs\
?????目錄???????????0??2016-08-17?18:25??cameraLoc\.git\logs\refs\heads\
?????文件?????????449??2016-08-18?01:56??cameraLoc\.git\logs\refs\heads\master
?????目錄???????????0??2016-08-17?18:26??cameraLoc\.git\logs\refs\remotes\
?????目錄???????????0??2016-08-17?18:26??cameraLoc\.git\logs\refs\remotes\cameraLoc\
?????文件?????????575??2016-08-18?01:56??cameraLoc\.git\logs\refs\remotes\cameraLoc\master
?????目錄???????????0??2016-08-18?01:56??cameraLoc\.git\ob
?????目錄???????????0??2016-08-18?01:56??cameraLoc\.git\ob
?????文件????????3038??2016-08-18?01:56??cameraLoc\.git\ob
?????目錄???????????0??2016-08-18?01:22??cameraLoc\.git\ob
............此處省略237個文件信息
- 上一篇:概念格工具包
- 下一篇:楊福生《小波變換的工程分析與應用》
評論
共有 條評論