• 大小: 291KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: 其他
  • 标签: ViSP  

资源简介

在QT中使用visp库来抓取pylon相机的测试例程,具体查看文章 https://blog.csdn.net/iamqianrenzhan/article/details/79830579

资源截图

代码片段和文件信息

#include “mainwindow.h“
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

void computePose(std::vector &point const std::vector &dot const vpCameraParameters &cam bool init
                 vpHomogeneousMatrix &cMo)
{
    vpPose pose;
    double x = 0 y = 0;
    for (unsigned int i = 0; i < point.size(); i++) {
        vpPixelMeterConversion::convertPoint(cam dot[i].getCog() x y);
        point[i].set_x(x);
        point[i].set_y(y);
        pose.addPoint(point[i]);
    }

    if (init == true) {
        vpHomogeneousMatrix cMo_dem;
        vpHomogeneousMatrix cMo_lag;
        pose.computePose(vpPose::DEMENTHON cMo_dem);
        pose.computePose(vpPose::LAGRANGE cMo_lag);
        double residual_dem = pose.computeResidual(cMo_dem);
        double residual_lag = pose.computeResidual(cMo_lag);
        if (residual_dem < residual_lag)
            cMo = cMo_dem;
        else
            cMo = cMo_lag;
    }
    pose.computePose(vpPose::VIRTUAL_VS cMo);
}

int main(int argc char *argv[])
{
    QApplication a(argc argv);
    MainWindow w;
    //w.show();
    //======================================================
    unsigned int opt_camera = 0;
    std::string opt_device(“USB“);

    vpPylonFactory &factory = vpPylonFactory::instance();
    vpPylonGrabber *g;
    g = factory.createPylonGrabber(vpPylonFactory::BASLER_USB);


    vpImage I;
    vpImageIo::read(I “square.pgm“);

    g->open(I);
    try {
        g->setCameraIndex(opt_camera);

#if defined(VISP_HAVE_X110)
        vpDisplayX d(I);
#elif defined(VISP_HAVE_GDI)
        vpDisplayGDI d(I);
#elif defined(VISP_HAVE_OPENCV)
        vpDisplayOpenCV d(I);
#endif

        vpCameraParameters cam(840 840 I.getWidth() / 2 I.getHeight() / 2);

        std::vector dot(4);
        dot[0].initTracking(I vpImagePoint(193 157));
        dot[1].initTracking(I vpImagePoint(203 366));
        dot[2].initTracking(I vpImagePoint(313 402));
        dot[3].initTracking(I vpImagePoint(304 133));
        std::vector point;
        point.push_back(vpPoint(-0.06 -0.06 0));
        point.push_back(vpPoint(0.06 -0.06 0));
        point.push_back(vpPoint(0.06 0.06 0));
        point.push_back(vpPoint(-0.06 0.06 0));
        vpHomogeneousMatrix cMo;
        bool init = true;

        while (1)
        {
            std::cout << “A new pic: “;
            g->acquire(I);
            std::cout << I.getHeight() << I.getWidth() <            vpDisplay::display(I);

            if (vpDisplay::getClick(I false))
              break;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     307215  2018-04-04 23:31  ViSPdemo\bar-code.pgm

     文件        992  2018-04-04 23:35  ViSPdemo\CMakeLists.txt

     文件       3669  2018-04-05 23:23  ViSPdemo\main.cpp

     文件        219  2018-04-04 23:41  ViSPdemo\mainwindow.cpp

     文件        291  2018-04-04 23:41  ViSPdemo\mainwindow.h

     文件        630  2018-04-04 23:41  ViSPdemo\mainwindow.ui

     文件     307215  2018-04-04 23:31  ViSPdemo\square.pgm

     文件       1883  2018-04-06 00:32  ViSPdemo\ViSPdemo.pro

    ..AD...         0  2018-04-06 00:32  ViSPdemo

----------- ---------  ---------- -----  ----

               622114                    9


评论

共有 条评论