#include <iostream>
#include <fstream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cout << "usage: <FILE_1> <FILE_2> ... <FILE_N>" << std::endl;
return 1;
}
std::shared_ptr<face_sdk::serializer> serializer;
try {
for (int i = 1; i < argc; i++) {
std::string file_path;
file_path.assign(argv[i]);
std::ifstream stream;
stream.open(file_path, std::ios::binary);
stream.seekg(0, std::ifstream::end);
size_t file_size = stream.tellg();
stream.seekg(0, std::ifstream::beg);
std::vector<uint8_t> file_data;
file_data.resize(file_size);
stream.read((char*)file_data.data(), file_size);
std::cout << "file: " << file_path << std::endl;
auto pos = file_path.rfind('.', 0);
auto ext = file_path.substr(pos);
if (ext == ".fir") {
auto fir = serializer->deserialize_fir(file_data);
std::cout <<" fir_version: " << fir->version() << std::endl;
} else if (ext == ".fac") {
auto face = serializer->deserialize_face(file_data);
std::cout << " face:" << std::endl;
std::cout << " x:" << face->x() << std::endl;
std::cout << " y:" << face->y() << std::endl;
std::cout << " width:" << face->width() << std::endl;
std::cout << " height:" << face->height() << std::endl;
} else if (ext == ".alg") {
auto alg = serializer->deserialize_alignment_info(file_data);
std::cout << " version: " << alg->version() << std::endl;
std::cout << " aligned_image:" << std::endl;
std::cout << " width:" << alg->aligned_image()->width() << std::endl;
std::cout << " height:" << alg->aligned_image()->height() << std::endl;
std::cout << " raw_size:" << alg->aligned_image()->data_size() << std::endl;
std::cout << " face:" << std::endl;
std::cout << " x:" << alg->face()->x() << std::endl;
std::cout << " y:" << alg->face()->y() << std::endl;
std::cout << " width:" << alg->face()->width() << std::endl;
std::cout << " height:" << alg->face()->height() << std::endl;
std::cout << " face_image:" << std::endl;
std::cout << " width:" << alg->face()->img()->width() << std::endl;
std::cout << " height:" << alg->face()->img()->height() << std::endl;
std::cout << " raw_size:" << alg->face()->img()->data_size() << std::endl;
}
}
}
std::cerr << face_sdk::format_exception(exp) << std::endl;
try {
std::rethrow_if_nested(exp);
}
catch (const face_sdk::version_not_available_exception &nested) {
std::cerr << nested.what() << std::endl;
}
catch (const face_sdk::license_exception &nested) {
std::cerr << nested.what() << std::endl;
}
catch (const std::exception &nested) {
std::cerr << nested.what() << std::endl;
}
return 2;
}
return 0;
}