lagadic / visp

Open Source Visual Servoing Platform
https://visp.inria.fr/
GNU General Public License v2.0
707 stars 287 forks source link

I had some exception Error while using a loadmodel function of vpMbEdgeTracker for *.wrl in Visp 3.2.1 #678

Closed DavidLeeDoosan closed 3 years ago

DavidLeeDoosan commented 4 years ago

Hello, I have a problem for a tracker.

I had some exception Error while using a loadmodel function of vpMbEdgeTracker for *.wrl in Visp 3.2.1

What happen to me? I did not have any idea for the problem. Could you help me? Thanks.

#include <opencv2/opencv.hpp>
#include <iostream>
#include <opencv2/imgproc/imgproc.hpp>
#include <visp3/core/vpImageConvert.h>
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpImageConvert.h>
#include <visp/vpMbEdgeTracker.h>
#include <visp/vpImageSimulator.h>
#include <visp/vpOpenCVGrabber.h>
#include <visp/vpDisplayOpenCV.h>
#include <visp/vpDisplayGDI.h>
#include <visp/vpDisplayX.h>

using namespace cv;
using namespace std;

int main()
{
    Mat img_color;
    cv::Mat gray;
    vpImage<unsigned char> Ig; // A grayscale image

    VideoCapture cap(0);
    cap.read(img_color);

    cv::cvtColor(img_color, gray, cv::COLOR_BGR2GRAY);

    vpImageConvert::convert(gray, Ig);

    //Display initialisation
#if defined VISP_HAVE_X11
    vpDisplayX d;
#elif defined VISP_HAVE_GDI
    vpDisplayGDI d;
#elif defined VISP_HAVE_OPEN_CV
    vpDisplayOpenCV d;
#endif

    d.init(Ig, 0, 0, "");

    vpDisplay::display(Ig);
    vpDisplay::flush(Ig);

    //Model-based tracker initialisation
    vpMbEdgeTracker tracker;
    tracker.setDisplayFeatures(true);
    vpHomogeneousMatrix cMo;

    tracker.loadConfigFile("cadre.xml");

    vpCameraParameters cam;
    tracker.getCameraParameters(cam);

    tracker.loadModel("cadre.wrl");   // Here is my exception error!!

    tracker.initClick(Ig, "cadre", true);
    vpDisplay::flush(Ig);
    vpDisplay::getClick(Ig);
    tracker.track(Ig);

    //Pose computation
    tracker.getPose(cMo);

    while (1)
    {
        cap.read(img_color);        
        cv::cvtColor(img_color, gray, cv::COLOR_BGR2GRAY);

        vpImageConvert::convert(gray, Ig);

        vpDisplay::display(Ig);
        vpDisplay::flush(Ig);

    }

    return 0;
}

////////////////////////////////////// cadre.wrl

#VRML V2.0 utf8

DEF fst_0 Group {
children [

Shape {
appearance Appearance { 
 material Material {
  diffuseColor 1 1 1
  specularColor 0.5 0.5 0.5
  emissiveColor 0 0 0
  shininess 10.000000
  transparency 0.000000
 }
}
geometry IndexedFaceSet {
solid FALSE
creaseAngle 0.5
coord Coordinate { 
point [
-2, -2,  0.0
 2, -2,  0.0
 2,  2,  0.0 
 -2,  2,  0.0 
-2.5, -2.5,  0.0
 2.5, -2.5,  0.0
 2.5,  2.5,  0.0 
 -2.5,  2.5,  0.0 ]
}

coordIndex [
 0, 3,2,1,-1
 4, 7,6,5,-1]}
}

]
}
fspindle commented 4 years ago

Sorry for the delay.

You didn't add the exception message you got.

I see multiple reasons: