Commit 9f4ceede authored by Patrik Huber's avatar Patrik Huber

Added scm-to-cereal convert app

parent 7ac1b4a8
...@@ -13,11 +13,18 @@ else(Boost_FOUND) ...@@ -13,11 +13,18 @@ else(Boost_FOUND)
message(FATAL_ERROR "Boost not found") message(FATAL_ERROR "Boost not found")
endif() endif()
#include_directories(${eos_SOURCE_DIR})
# Model fitting (affine cam & shape to landmarks) example: # Model fitting (affine cam & shape to landmarks) example:
add_executable(fit_model fit_model.cpp) add_executable(fit_model fit_model.cpp)
target_link_libraries(fit_model ${OpenCV_LIBS} ${Boost_LIBRARIES}) target_link_libraries(fit_model ${OpenCV_LIBS} ${Boost_LIBRARIES})
# TODO Add dependency to library-target?? # TODO Add dependency to library-target??
# Converts a CVSSP .scm Morphable Model to a cereal binary file:
add_executable(scm-to-cereal scm-to-cereal.cpp)
target_link_libraries(scm-to-cereal ${OpenCV_LIBS} ${Boost_LIBRARIES})
# install target: # install target:
install(TARGETS fit_model DESTINATION bin) install(TARGETS fit_model DESTINATION bin)
install(TARGETS scm-to-cereal DESTINATION bin)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/examples/data DESTINATION bin) install(DIRECTORY ${CMAKE_SOURCE_DIR}/examples/data DESTINATION bin)
/*
* Eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
* File: examples/scm-to-cereal.cpp
*
* Copyright 2015 Patrik Huber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "eos/morphablemodel/MorphableModel.hpp"
#include "eos/morphablemodel/io/cvssp.hpp"
#include "opencv2/core/core.hpp"
#ifdef WIN32
#define BOOST_ALL_DYN_LINK // Link against the dynamic boost lib. Seems to be necessary because we use /MD, i.e. link to the dynamic CRT.
#define BOOST_ALL_NO_LIB // Don't use the automatic library linking by boost with VS2010 (#pragma ...). Instead, we specify everything in cmake.
#endif
#include "boost/program_options.hpp"
#include "boost/filesystem.hpp"
#include <vector>
#include <iostream>
#include <fstream>
using namespace eos;
namespace po = boost::program_options;
namespace fs = boost::filesystem;
using std::cout;
using std::endl;
/**
* Reads a CVSSP .scm Morphable Model file and converts it
* to a cereal binary file.
*/
int main(int argc, char *argv[])
{
fs::path scmmodelfile, isomapfile, outputfile;
try {
po::options_description desc("Allowed options");
desc.add_options()
("help,h",
"display the help message")
("model,m", po::value<fs::path>(&scmmodelfile)->required(),
"a CVSSP .scm Morphable Model file")
("isomap,t", po::value<fs::path>(&isomapfile),
"optional isomap containing the texture mapping coordinates")
("output,o", po::value<fs::path>(&outputfile)->required()->default_value("converted_model.bin"),
"output filename for the Morphable Model in cereal binary format")
;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
if (vm.count("help")) {
cout << "Usage: scm-to-cereal [options]" << endl;
cout << desc;
return EXIT_SUCCESS;
}
po::notify(vm);
}
catch (const po::error& e) {
cout << "Error while parsing command-line arguments: " << e.what() << endl;
cout << "Use --help to display a list of options." << endl;
return EXIT_SUCCESS;
}
// Load the .scm Morphable Model and save it as cereal model:
morphablemodel::MorphableModel morphable_model = morphablemodel::loadScmModel(scmmodelfile, isomapfile);
morphablemodel::save_model(morphable_model, outputfile.string());
// Save only the shape model - to generate the public sfm_shape_3448.bin
//morphablemodel::MorphableModel shape_only_model(morphable_model.get_shape_model(), morphablemodel::PcaModel(), morphable_model.gtc());
//morphablemodel::save_model(shape_only_model, outputfile.string());
return EXIT_SUCCESS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment