Showing posts with label VOSM. Show all posts
Showing posts with label VOSM. Show all posts

08 May 2013

Notes of VOSM shape model building framework

The information saved for fitting:

\ShapeModel\
ShapeModel.txt:
m_iNbOfSamples
m_iNbOfShapeDim
m_iNbOfPoints
m_iNbOfShapes
m_iNbOfEigenShapesAtMost
m_iNbOfShapeEigens
m_iNbOfEdges
m_iNbOfTriangles
m_fAverageShapeSize
m_fTruncatedPercent_Shape
m_PCAAlignedShapeMean.txt
m_PCAAlignedShapeEigenValues.txt
m_PCAAlignedShapeEigenVectors.txt
m_VOAlignedMeanShape.txt
m_VOReferenceShape.txt // Reference shape which is scaled back to the original size and translated to origin
m_vShapes.txt // All loaded shapes in a vector format
m_vAlignedShapes.txt // All aligned shapes in a vector format
m_vShape2DInfo.txt // shape information and face parts information
m_vEdge.txt
m_vTemplateTriangle2D.txt // Unnormalised triangles in the template shape
m_vNormalizedTriangle2D.txt // Normalised triangles in the template shape

.\Point2DDistributionModel\
Point2DDistributionModel.txt // number of points
m_VONormalizedEllipses.txt 

07 May 2013

VOSM 2D model building and fitting for face data

After successful compilation of VOSM we got "test_smbuilding.exe" and "test_smfitting.exe" which are responsible for model building and fitting respectively.
Preparation of database:
From the VOSM website we can download several database: link. For this post, I will use JIAPEI database. Within JIAPEI directory, there are two directories: .\annotations and .\images. The former one contains annotation of landmarks for both training and testing images. The later one contains the corresponding images. For each database there should be a ShapeInfo.txt which describes how the landmarks are connected as shape (with several parts).

Config of VOSM under Win7-32bit with VS2010 using CMake

VOSM is an open source 2D ASM/AAM C++ implementation which can be downloaded from here. Extract the file to a convenient directory, say .\vosm-0.3.3. If use CMake to compile the project we need to copy .\vosm-0.3.3\doc folder from other repository (say Linux) which contains a licience.txt that is required for CMake. We may need to modify the given CMakeLists.txt since the viriable OPENCV_INCLUDE_PATH was not set correctly. To solve this problem, change these lines (starting from line:248):
find_path(OPENCV_INCLUDE_PATH "cv.h"
        PATHS "/usr/include/opencv" "/usr/local/include/opencv"
        DOC "The path to OPENCV headers")
to:
 set(OPENCV_INCLUDE_PATH "DIRECTORY/TO/OPENCV/INCLUDE_FOLDER")
Then set both source and build directory in CMake to .\vosm-0.3.3 and Configure and Generate.
In .\vosm-0.3.3, open vosm.sln and Solution Explorer looks like:
For all projects whose names are all capital (such as ALL_BUILD), we don't need to configure them.
For all projects' name not start with (EXAMPLE) (such as smbuilding), change project (debug and release) property Configuration Type to Static library (.lib) and set Output Directory as .\vosm-0.3.3\lib\Debug\ or  .\vosm-0.3.3\lib\Release\. Set Target Extension to .lib. Here is a snapshot of property pages after this step:
For all projects except the one with capital name, configure OpenCV and Boost include and library directory (if they are not there) since they are VOSM's dependent libraries.
For all projects' name start with (EXAMPLE), configure correct OpenCV and Boost .lib file for each for both debug and release. The name of the .lib files are (OpenCV-2.4.4 Boost-1.4.9):