Visual Studio 2017 Viz.hpp not working [closed]

asked 2018-09-04 13:17:47 -0600

Ron88 gravatar image

updated 2018-09-04 13:31:43 -0600

LBerger gravatar image

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 ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-12-06 10:10:22.619219

Comments

" I used the OpenCV Version 3.4.3 and the Viz.hpp and Viz Folder is originally not in the include Folder" Have you got vtk installed?

LBerger gravatar imageLBerger ( 2018-09-04 13:34:31 -0600 )edit

Hello LBerger,

I installed it. Is there any Setting or path that Needs to be adjusted?

Kind Regards

Ron

Ron88 gravatar imageRon88 ( 2018-09-05 05:09:54 -0600 )edit

delete cmakecache.txt an run cmakegui after configure check VTK_DIR variables if it is set to NOT_FOUND then set it to something as .../vtk/lib/cmake/vtk-8.1 rerun configure and BUILD_opencv_viz must be set to true. Press generate and rebuild opencv

LBerger gravatar imageLBerger ( 2018-09-05 06:00:23 -0600 )edit

In CMAKE there is no possibility to choose the BUILD_opencv_viz, although it is in the modules Folder. I added the VTK path to VTK_DIR.

Ron88 gravatar imageRon88 ( 2018-09-05 08:39:30 -0600 )edit

can you post cmakeoutput?

can you check this in your vtk installed?

LBerger gravatar imageLBerger ( 2018-09-05 08:41:33 -0600 )edit

The CXX compiler identification is MSVC 19.15.26726.0 The C compiler identification is MSVC 19.15.26726.0 Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/

Ron88 gravatar imageRon88 ( 2018-09-05 08:44:20 -0600 )edit
Ron88 gravatar imageRon88 ( 2018-09-05 08:47:19 -0600 )edit

Where to build binaries c:/build/opencv Ok but not inside opencv github folder. Are you in 32 bits ? cmake genrator for 64 bits is Visual Studio 15 2017 Win64 and post cmake output in your post

you can use this too

LBerger gravatar imageLBerger ( 2018-09-05 08:51:09 -0600 )edit

I'm on a 64bit operating System and I try to compile it for Visual Studio 2017. The path where I try to build the binaries is: C:\Users\Ron\Documents\A_Working_Directory\Studium\Software\Bildverarbeitung\opencv-3.4.3

Ron88 gravatar imageRon88 ( 2018-09-05 09:00:33 -0600 )edit

Visual Studio 15 2017 is for a 32 bits system

LBerger gravatar imageLBerger ( 2018-09-05 09:03:00 -0600 )edit