EihiS

May 16, 2017

3D photogrammetry on Linux with CUDA + COLMAP

Filed under: linux — Tags: , , , , , — admin @ 6:45 am

Ce post regroupe des notes concernant l’installation de CUDA et du logiciel COLMAP pour photogrammetrie
( Reconstruction de modele 3D en utilisant des photos multiples d’un même élément depuis plusieurs points de vues )

Target config : portable x86_64, 8Go,NVIDIA GT540M , Linux Ubuntu 16.04

Part I : CUDA drivers

  • Nvidia-CUDA drivers,téléchargement (1.8 Go) : http://developer.nvidia.com/cuda-downloads
  • >> choix des OPTIONS du download :  Linux, x86-64, ubuntu, 16.04, deb(local)
  • Installation (depuis le dossier : ‘Downloads’ )

  • sudo dpkg -i ./Downloads/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
  • sudo apt-get update
  • sudo apt-get install cuda
    • Note : des warnings “ldconfig.real,   **warnings** sur egl.so ‘not a symbolic link’ ” apparaissent (more on this later )
    • Redémarrer…

    Quick starting guide, PDF : http://developer.download.nvidia.com/compute/DevZone/docs/html/C/doc/CUDA_C_Getting_Started_Linux.pdf

    • Ajouts à PATH & LD_LIBRARY_PATH des librairies CUDA :
    1. $ export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    2. $ export PATH=/usr/local/cuda/bin:$PATH
    3. (pour ajout permanent, ajouter ces lignes en fin du fichier “.profile” du dossier “home” utilisateur )
    Tester , compiler un exemple :
    • les examples sont localisés dans /usr/local/cuda/samples
    Pour compiler dans un dossir autre ( droits d’accès.. ) , exemple ‘test_cuda’ :
    • recopier le dossier complet ’samples’ de /usr/local/cuda/samples dans l’endroit de votre choix de votre ‘home’
    • Puis, ‘make’ depuis le sous-dossier d’exemple
    • le dossier ./test_cuda/bin/ est créé
    • dans ./test_cuda/bin/x86_64/linux/release/ se trouve l’executable du nom de l’exemple compilé

    Part II : COLMAP software

    • git clone https://github.com/colmap/colmap
    apt-get , dependances :
    sudo apt-get install \
        cmake \
        build-essential \
        libboost-all-dev \
        libeigen3-dev \
        libsuitesparse-dev \
        libfreeimage-dev \
        libgoogle-glog-dev \
        libgflags-dev \
        libglew-dev \
        freeglut3-dev \
        qt5-default \
        libxmu-dev \
        libxi-dev
    executer : $ dpkg -l | grep libeigen
    Si la version n'est pas 3.2.10, voir footnote , réinstaller la version 3.2.10 avant de continuer
    Installer "Ceres Solver" :
    sudo apt-get install libatlas-base-dev libsuitesparse-dev
    git clone https://ceres-solver.googlesource.com/ceres-solver
    cd ceres-solver
    mkdir build
    cd build
    cmake ..
    make -j1 ( <- your taste..)
    sudo make install
    Le cache de ma machine reste plein apres la manip, si c'est votre cas, essayez (flush du cache linux) :
    • sudo sh -c ‘echo 1 >/proc/sys/vm/drop_caches’
    Ensuite, compilation+installation COLMAP :
    • cd repertoire de download colmap
    • mkdir build
    • cd build
    • cmake ..
    • make -j2
    • sudo make install

    FOOTNOTE :

    si problemes de crashes COLMAP en lancant ‘reconstruction’ (SEGFAULTS, EIGEN visible dans le crash resume):
    Vérifier la version de eigen , avec : dpkg -l | grep libeigen
    Il faut la 3.2.10 et non la 3.3(beta) comme c’etait le cas sur ma machine..
    Donc, en résumé :
    • Télécharger Eigen 3.2.10 https://bitbucket.org/eigen/eigen/downloads?tab=tags
    • mkdir build,cd build,cmake ..,make install
    • ->uninstall Eigen 3.3 depuis synaptic package manager
    • Recompiler Ceres ( il FAUT specifier les chemins modifiés pour votre lib EIGEN version 3.2.10 fraichement recompilée )
        dans ceres-solver/ -> cd build, make clean, cmake -D EIGEN_INCLUDE_DIR=/usr/local/include/eigen3 ..
    • make -j2
    • Recompiler Colmap ( il FAUT specifier les chemins modifiés pour votre lib EIGEN version 3.2.10 fraichement recompilée )
    • dans colmap/ -> cd build,make clean,cmake -D EIGEN3_VERSION=3.2.10 -D EIGEN3_INCLUDE_DIRS=/usr/local/include/eigen3 -D EIGEN_INCLUDE_DIR=/usr/local/include/eigen3/ ..
    • make -j2
    314159265358979323846264338327950288
    419716939937510582097494459230781640
    628620899862803482534211706798214808
    

    August 27, 2014

    August news

    Filed under: Raspberry 3.14, linux — Tags: , , , , — admin @ 9:49 am

    Pi slave board for model B is under built and test.
    some pictures of the prototype PCB, routed for model B :

    The mainboard bare PCB

    The optional 20x4 LCD display module

    The optional 20x4 LCD display module

    In the same time, a real time 3D user interface’s library is under development ( early stage picture of 3 surfaces acting like console’s char displays on the raspberry pi :

    small window at back: 80x20 chars, wide window : 80x20 chars, a 3D object at top, and finally a rotating cube composed of 4 faces (12x8 chars) : about 6500 openGL polygons drawn and update in 13ms

    August 28 : first assembly tests:
    The assembly is ok , and the first tests to the development GUI are all ok also.

    Some pictures of the device follows..

    the LCD module stacked onto for the I/O mainboard.The LCD module is used for debugging purposes when code for the mainboard needs to be tested

    the LCD module stacked onto for the I/O mainboard.The LCD module is used for debugging purposes when code for the mainboard needs to be tested

    The back side of the mainboard. the PI is plugged there using the GPIO port connector.The mainboard powers the PI. the mainboard's internal regulator generates 5V @1amp max from a DC source in the range 7 to 35V

    The back side of the mainboard. the PI is plugged there using the GPIO port connector.The mainboard powers the PI. the mainboard's internal regulator generates 5V @1amp max from a DC source in the range 7 to 35V

    For now, the application used to develop and test programs on the mainboard is using the SDL layer ( but a 3D gui is under development ).The upper window is the mainboard's program editor. the middle 2 window are dumps of the the 'compiled' code of the program on the upper window. finally, 4 little windows on the bottom are dumps of the mainboard's RAM datas, wich include 4 blocs : _PROG, _BLOCA ,_BLOCB, and _PARAM.

    For now, the application used to develop and test programs on the mainboard is using the SDL layer ( but a 3D gui is under development ).The upper window is the mainboard's program editor. the middle 2 window are dumps of the the 'compiled' code of the program on the upper window. finally, 4 little windows on the bottom are dumps of the mainboard's RAM datas, wich include 4 blocs : _PROG, _BLOCA ,_BLOCB, and _PARAM.

    314159265358979323846264338327950288
    419716939937510582097494459230781640
    628620899862803482534211706798214808
    

    June 26, 2014

    Blender 2.69 python script for vertex,normals, and UV coords export

    Filed under: Raspberry 3.14, linux — Tags: , , , , , , — admin @ 11:36 am

    A simple script that can be run from a ‘text’ window in blender 2.69.
    This a raw script,up to you to get what’s useful from it.

    Obviously ,the script assumes the mesh is called ‘Cube’.
    It writes to the file each vertices composing a face of the mesh, with each vertice’s normal and each face’s normal plus the face’s vertices group number + the face’s material number.
    a face’s description is 3 lines, with the start char beein ‘A’,'B’ or ‘C’, corresponding to the 3 vertices of the face.

    If a vertex is in multiple groups, the script takes the first group’s number for that vertex.
    Groups and Materials output are Numbers, from 0…n , directly linked to the Material or Group’s blender - SLOT , whatever the name is.
    Vertices are treated as individual (the real vertices coords are used , assuming the user’s program wich will use this output file will make it’s own ‘indexing’ of vertices wich have same coords  in common )
    Finally, faces have to be triangulated :the script outputs only the 3 first vertices of a meshe’s face .

    Hope this helps!

    #!BPY
    
    import bpy
    
    cubedata = bpy.data.meshes['Cube']
    v=cubedata.vertices
    f=cubedata.polygons
    print("\n\n-------------------------------------\n\n")
    out = open("/home/path_to_your_dir/custom_output.txt", "w")
    idx=0
    for f in cubedata.polygons :
        # FACES MUST BE TRIANGULATED
        g=cubedata.vertices[f.vertices[0]]
        uvx=0
        uvy=0
        if cubedata.uv_layers.active!=None:
            uvx=cubedata.uv_layers.active.data[idx].uv.x
            uvy=cubedata.uv_layers.active.data[idx].uv.y
        else:
            print("UV error,face vertex[0]\n")
        out.write("A=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        print("A=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        g=cubedata.vertices[f.vertices[1]]
        uvx=0
        uvy=0
        if cubedata.uv_layers.active!=None:
            uvx=cubedata.uv_layers.active.data[idx+1].uv.x
            uvy=cubedata.uv_layers.active.data[idx+1].uv.y
        else:
            print("UV error,face vertex[1]\n")  
        out.write("B=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        print("B=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        g=cubedata.vertices[f.vertices[2]]
        uvx=0
        uvy=0
        if cubedata.uv_layers.active!=None:
            uvx=cubedata.uv_layers.active.data[idx+2].uv.x
            uvy=cubedata.uv_layers.active.data[idx+2].uv.y
        else:
            print("UV error,face vertex[2]\n")
        out.write("C=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        print("C=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
        #
        idx=idx+3
        #   
    out.close()

    The output file (ascii) will look like :

    A=0.351 -0.679 0.733 VN=0.93976 -0.23081 0.25208 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.25781
    B=0.349 -0.221 0.975 VN=0.93954 -0.07318 0.33445 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.50000
    C=0.249 -0.311 1.144 VN=0.41011 0.22208 0.88455 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.50000
    A=0.245 1.119 -0.397 VN=0.41014 0.89917 0.15235 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.50781 V=0.49219
    B=0.246 0.843 -0.835 VN=0.41194 0.25422 -0.87500 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.50781 V=0.74219
    C=-0.251 1.116 -0.397 VN=-0.41353 0.89776 0.15146 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.25781 V=0.49219
    A=-0.345 -0.957 0.295 VN=-0.93915 -0.32841 0.10056 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.00000 V=1.00000
    B=-0.245 -1.148 0.302 VN=-0.41090 -0.65740 0.63161 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.00000 V=1.00000
    C=0.251 -1.146 0.302 VN=0.41246 -0.65545 0.63262 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.25781 V=1.00000
    A=0.352 -0.954 0.295 VN=0.93982 -0.32621 0.10154 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=1.00000
    B=0.251 -1.146 0.302 VN=0.41246 -0.65545 0.63262 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=1.00000
    C=0.251 -1.165 -0.215 VN=0.41252 -0.70116 -0.58150 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=0.75000
    A=0.247 0.216 -1.166 VN=0.41008 0.58296 -0.70138 FN=0.00010 -0.03762 -0.99929 G=0 M=0 U=1.00781 V=0.75781
    314159265358979323846264338327950288
    419716939937510582097494459230781640
    628620899862803482534211706798214808
    

    cat{ } { post_578 } { } 2009-2015 EIhIS Powered by WordPress