Nov 04

Moving to Qt on the SfM-Toy-Library project

Qt GUI for SfMToyLibFor those of you still interested, I've made the move to using Qt and QGLViewer in the SfM-Toy-Lib project. Getting rid of PCL dependency (I think it's a bloated library), and burying FLTK long in the past, I feel much better about it now.

Get it on github: https://github.com/royshil/SfM-Toy-Library

  • Soyeb

    After some struggle, I could compile this code successfully on Win7/VC2010/QT. I have disabled USE_SSBA in CMake. After running it for CrazyHorse, I obtained sparsed depth map. I got attracted to this code by looking at the dense depth map that was shown in your original post, "Structure from Motion and 3D reconstruction on the easy in OpenCV 2.3+ [w/ code]". Do you think the code downloaded from this page can obtain dense depth map?

  • http://www.morethantechnical.com Roy

    While you could extend the functionality to get a dense depth map, I'd refer you to using a more robust system like: http://www.di.ens.fr/cmvs/
    Although, after you recover the camera position in space you could do some dense feature matching like optical flow (which is what you see in the blog post) and get a dense reconstruction from that matching that could render a depth map.

  • Soyeb

    @Roy thanks for prompt reply.

    After your suggestion I looked at cmvs system. I took "crazyhorse" data set and ran through the package and generated point cloud in .ply format. Then I wrote MATLAB script to convert each X,Y,Z (real world coordinate) to camera frame 2d coordinate by doing x= X/Z, y = Y/Z, depth=Z. I normalized x,y such that spans whole image.(I ignored focal len as it will just change the scale and anyway generated point cloud is only unique up to scale). Now to get dense depth map, I need depth corresponding to each x,y coordinates of the input image. But unfortunately I am observing for lot of points depth info is not there. That to conversion did not span whole image.

    Any suggestion how can I compute dense depth map? Am I doing anything wrong?

  • Chris

    Hi Roy,

    when running the SfMToyUI target I get a runtime error "QWidget: Must construct a QApplication before a QWidget". I am on Mac OS 10.9 with Qt 5.2. Do you have any idea how to fix this?

    Best regards,

  • pawan

    when i build it in msvs after cmake....i gives me 2 error saying ...
    error D8021: invalid numeric argument '/wno-sign-compare' (in project SfmToyLibrary)
    error LNK1104: cannot open file 'SfmToyLib (in project SfmToyUi)

  • pawan

    After some struggle, I could compile this code successfully on Win8.1/VC2012/QT4.8.5
    now when i run it it says:
    Qwidget: Must construct a QApplication before a QPaintDevice
    i am not able to solve it so please help.

  • Ulises Aguirre


    I am trying to compile the project but I am having a lot of problems to be honest. I checked the previous version, couldn't make it run with FLTK but at least I managed to use the no-gui version and get some reconstructions.

    Right now I am trouble trying to compile the Qt-gui and No-gui configurations, when using Qt-QGL I get to the point where the SfmToyLibrary project compiles without errors but the SfMToyUi one tries to access a file called ui_sfmtoy.h but it isn't nowhere in the project, if I remember correctly that file should be generated from the Qt tools or something?, that might be a problem with my Pathing to Qt.

    When trying to compile a No-Gui version of the project, SfMToyUi has a problem with the definition of VisualizerListener class, in the original project (with FLTK) there is a definition of that class in main.cpp, but in this one it seems to have been moved or just totally dropped. Any help would be thankfully considered

  • Ulises Aguirre

    Just checked and it seems there are a couple of Qt files that don't exist in my project either, both referring to MOC (moc_sfmviewer.cxx, moc_Viewerinterface.cxx), and in sfmviewer.h the includes for QGLViewer and QFileDialog/QLineEdit are marked as errors (although QThreadPool is ok), now I am sure I am having troubles with my paths so I want to ask

    For the QGLViewer library I downloaded the source 2.5.1 and generated a solution with QtCreator, that gave me some dlls and a QGLViewer2.lib, the Cmake configuration for SfMToy project asks for QGLVIEWER_DIR_HINT, QGLVIEWER_INCLUDE and QGLVIEWER_LIB, where do I have to point them? (also qglcviewer_include says in the description says it is a Path to a file but when trying to fill it, it asks for a directory).

    Windows 7
    Visual Studio 2010
    Qt 4.8.5
    libQGLViewer 2.5.1

  • pawan

    HEAP[SfMToyUI.exe]: Invalid address specified to RtlFreeHeap( 00DC0000, 04F57AF8 ) how to fix it?

  • Mike Pelton

    A long time ago I know, but I've just been along this route too. VisualizerListener is something Roy built for the source code of his splendid book "Mastering OpenCV" - the code's still there on the book's web site. Let me add I never got either the command line or GUI variants to work in terms of displaying anything but this is almost certainly to do with my choice of Qt and OpenCV library versions. One final wrinkle - if you're seeing "GpuMat" compilation errors it's because Windows.h defines its own min and max - if you define NOMINMAX for the C++ PreProcessor in Visual Studio for the SfmToy core and GUI projects those errors will disappear.

  • zeeshan khan

    same error. did u solve it? Please help me