资源简介

之前的改进,带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\description
     文件          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-rebase.sample
     文件        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\objects\
     目录           0  2016-08-18 01:56  cameraLoc\.git\objects\04\
     文件        3038  2016-08-18 01:56  cameraLoc\.git\objects\04\4e0d9875a73975964170530b6ae12cdfb3bb69
     目录           0  2016-08-18 01:22  cameraLoc\.git\objects\05\
............此处省略237个文件信息

评论

共有 条评论