Ask Your Question

Revision history [back]

Visual Studio 2017 Viz.hpp not working

Dear all,

I try to compile the following example Code (Source 1), but I Always get the LNK2019 error (Source 2). I used the OpenCV Version 3.4.3 and the Viz.hpp and Viz Folder is originally not in the include Folder of build/include/ opencv2. I added it from the source Folder in Sources/modules/viz/include/opencv2. Has anybody a hint, what I can do?

Thanks in Advance and Kind Regards

Ron

Source 1 // OpenCV_Test.cpp : Diese Datei enthält die Funktion "main". Hier beginnt und endet die Ausführung des Programms. //

include "pch.h"

include <opencv2 viz.hpp="">

include <opencv2 calib3d.hpp="">

include <iostream>

using namespace cv; using namespace std;

/** * @function help * @brief Display instructions to use this tutorial program */ static void help() { cout << "--------------------------------------------------------------------------" << endl << "This program shows how to visualize a cube rotated around (1,1,1) and shifted " << "using Rodrigues vector." << endl << "Usage:" << endl << "./widget_pose" << endl << endl; }

/** * @function main */ int main() { help();

/// Create a window
viz::Viz3d myWindow("Coordinate Frame");

/// Add coordinate axes
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());

/// Add line to represent (1,1,1) axis
viz::WLine axis(Point3f(-1.0f, -1.0f, -1.0f), Point3f(1.0f, 1.0f, 1.0f));
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
myWindow.showWidget("Line Widget", axis);

/// Construct a cube widget
viz::WCube cube_widget(Point3f(0.5, 0.5, 0.0), Point3f(0.0, 0.0, -0.5), true, viz::Color::blue());
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
myWindow.showWidget("Cube Widget", cube_widget);

/// Rodrigues vector
Mat rot_vec = Mat::zeros(1, 3, CV_32F);
float translation_phase = 0.0, translation = 0.0;
while (!myWindow.wasStopped())
{
    /* Rotation using rodrigues */
    /// Rotate around (1,1,1)
    rot_vec.at<float>(0, 0) += (float)CV_PI * 0.01f;
    rot_vec.at<float>(0, 1) += (float)CV_PI * 0.01f;
    rot_vec.at<float>(0, 2) += (float)CV_PI * 0.01f;

    /// Shift on (1,1,1)
    translation_phase += (float)CV_PI * 0.01f;
    translation = sin(translation_phase);

    Mat rot_mat;
    Rodrigues(rot_vec, rot_mat);

    /// Construct pose
    Affine3f pose(rot_mat, Vec3f(translation, translation, translation));

    myWindow.setWidgetPose("Cube Widget", pose);

    myWindow.spinOnce(1, true);
}

return 0;

}

Source 2

1>------ Erstellen gestartet: Projekt: OpenCV_Test, Konfiguration: Debug x64 ------ 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Widget::~Widget(void)" (??1Widget@viz@cv@@QEAA@XZ)" in Funktion ""public: __cdecl cv::viz::Widget3D::~Widget3D(void)" (??1Widget3D@viz@cv@@QEAA@XZ)". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Widget::setRenderingProperty(int,double)" (?setRenderingProperty@Widget@viz@cv@@QEAAXHN@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WLine::WLine(class cv::Point3_<double> const &,class cv::Point3_<double> const &,class cv::viz::Color const &)" (??0WLine@viz@cv@@QEAA@AEBV?$Point3_@N@2@0AEBVColor@12@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WCube::WCube(class cv::Point3_<double> const &,class cv::Point3_<double> const &,bool,class cv::viz::Color const &)" (??0WCube@viz@cv@@QEAA@AEBV?$Point3_@N@2@0_NAEBVColor@12@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WCoordinateSystem::WCoordinateSystem(double)" (??0WCoordinateSystem@viz@cv@@QEAA@N@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Viz3d::Viz3d(class cv::String const &)" (??0Viz3d@viz@cv@@QEAA@AEBVString@2@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Viz3d::~Viz3d(void)" (??1Viz3d@viz@cv@@QEAA@XZ)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::showWidget(class cv::String const &,class cv::viz::Widget const &,class cv::Affine3<double> const &)" (?showWidget@Viz3d@viz@cv@@QEAAXAEBVString@3@AEBVWidget@23@AEBV?$Affine3@N@3@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::setWidgetPose(class cv::String const &,class cv::Affine3<double> const &)" (?setWidgetPose@Viz3d@viz@cv@@QEAAXAEBVString@3@AEBV?$Affine3@N@3@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::spinOnce(int,bool)" (?spinOnce@Viz3d@viz@cv@@QEAAXH_N@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: bool __cdecl cv::viz::Viz3d::wasStopped(void)const " (?wasStopped@Viz3d@viz@cv@@QEBA_NXZ)" in Funktion "main". 1>C:\Users\Ron\source\repos\Test_2\x64\Debug\OpenCV_Test.exe : fatal error LNK1120: 11 nicht aufgelöste Externe 1>Die Erstellung des Projekts "OpenCV_Test.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

Visual Studio 2017 Viz.hpp not working

Dear all,

I try to compile the following example Code (Source 1), but I Always get the LNK2019 error (Source 2). I used the OpenCV Version 3.4.3 and the Viz.hpp and Viz Folder is originally not in the include Folder of build/include/ opencv2. I added it from the source Folder in Sources/modules/viz/include/opencv2. Has anybody a hint, what I can do?

Thanks in Advance and Kind Regards

Ron

Source 1

**Source 1**
// OpenCV_Test.cpp : Diese Datei enthält die Funktion "main". Hier beginnt und endet die Ausführung des Programms.
//

include "pch.h"

include <opencv2 viz.hpp="">

include <opencv2 calib3d.hpp="">

include <iostream>

// #include "pch.h" #include <opencv2/viz.hpp> #include <opencv2/calib3d.hpp> #include <iostream> using namespace cv; using namespace std;

std; /** * @function help * @brief Display instructions to use this tutorial program */ static void help() { cout << "--------------------------------------------------------------------------" << endl << "This program shows how to visualize a cube rotated around (1,1,1) and shifted " << "using Rodrigues vector." << endl << "Usage:" << endl << "./widget_pose" << endl << endl; }

} /** * @function main */ int main() { help();

help();
/// Create a window
 viz::Viz3d myWindow("Coordinate Frame");
 /// Add coordinate axes
 myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
 /// Add line to represent (1,1,1) axis
 viz::WLine axis(Point3f(-1.0f, -1.0f, -1.0f), Point3f(1.0f, 1.0f, 1.0f));
 axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
 myWindow.showWidget("Line Widget", axis);
 /// Construct a cube widget
 viz::WCube cube_widget(Point3f(0.5, 0.5, 0.0), Point3f(0.0, 0.0, -0.5), true, viz::Color::blue());
 cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
 myWindow.showWidget("Cube Widget", cube_widget);
 /// Rodrigues vector
 Mat rot_vec = Mat::zeros(1, 3, CV_32F);
 float translation_phase = 0.0, translation = 0.0;
 while (!myWindow.wasStopped())
 {
  /* Rotation using rodrigues */
 /// Rotate around (1,1,1)
  rot_vec.at<float>(0, 0) += (float)CV_PI * 0.01f;
 rot_vec.at<float>(0, 1) += (float)CV_PI * 0.01f;
 rot_vec.at<float>(0, 2) += (float)CV_PI * 0.01f;
 /// Shift on (1,1,1)
  translation_phase += (float)CV_PI * 0.01f;
 translation = sin(translation_phase);
 Mat rot_mat;
 Rodrigues(rot_vec, rot_mat);
  /// Construct pose
  Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
 myWindow.setWidgetPose("Cube Widget", pose);
 myWindow.spinOnce(1, true);
 }
 return 0;
}

}

Source 2

1>------ Erstellen gestartet: Projekt: OpenCV_Test, Konfiguration: Debug x64 ------ 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Widget::~Widget(void)" (??1Widget@viz@cv@@QEAA@XZ)" in Funktion ""public: __cdecl cv::viz::Widget3D::~Widget3D(void)" (??1Widget3D@viz@cv@@QEAA@XZ)". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Widget::setRenderingProperty(int,double)" (?setRenderingProperty@Widget@viz@cv@@QEAAXHN@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WLine::WLine(class cv::Point3_<double> const &,class cv::Point3_<double> const &,class cv::viz::Color const &)" (??0WLine@viz@cv@@QEAA@AEBV?$Point3_@N@2@0AEBVColor@12@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WCube::WCube(class cv::Point3_<double> const &,class cv::Point3_<double> const &,bool,class cv::viz::Color const &)" (??0WCube@viz@cv@@QEAA@AEBV?$Point3_@N@2@0_NAEBVColor@12@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::WCoordinateSystem::WCoordinateSystem(double)" (??0WCoordinateSystem@viz@cv@@QEAA@N@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Viz3d::Viz3d(class cv::String const &)" (??0Viz3d@viz@cv@@QEAA@AEBVString@2@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl cv::viz::Viz3d::~Viz3d(void)" (??1Viz3d@viz@cv@@QEAA@XZ)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::showWidget(class cv::String const &,class cv::viz::Widget const &,class cv::Affine3<double> const &)" (?showWidget@Viz3d@viz@cv@@QEAAXAEBVString@3@AEBVWidget@23@AEBV?$Affine3@N@3@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::setWidgetPose(class cv::String const &,class cv::Affine3<double> const &)" (?setWidgetPose@Viz3d@viz@cv@@QEAAXAEBVString@3@AEBV?$Affine3@N@3@@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl cv::viz::Viz3d::spinOnce(int,bool)" (?spinOnce@Viz3d@viz@cv@@QEAAXH_N@Z)" in Funktion "main". 1>OpenCV_Test.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: bool __cdecl cv::viz::Viz3d::wasStopped(void)const " (?wasStopped@Viz3d@viz@cv@@QEBA_NXZ)" in Funktion "main". 1>C:\Users\Ron\source\repos\Test_2\x64\Debug\OpenCV_Test.exe : fatal error LNK1120: 11 nicht aufgelöste Externe 1>Die Erstellung des Projekts "OpenCV_Test.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========