Add option for using different models

This commit is contained in:
Epicalert 2021-02-06 12:12:37 +08:00
parent 4770c96d92
commit 25f97e5f90
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
3 changed files with 12 additions and 3 deletions

View file

@ -9,7 +9,8 @@ const char* argp_program_version =
const struct argp_option options[] = { const struct argp_option options[] = {
//name, key, arg, flags, doc, group //name, key, arg, flags, doc, group
{"haar-cascade", 0x00, 0, 0, "Use Haar Cascades for faster (but less accurate) face detection.", 0}, {"haar-cascade", 0x00, 0, 0, "Use Haar Cascades for faster (but less accurate) face detection.", 0},
{"model", 'm', "model", 0, "Name of the model file to use. (not including '.fma')", 0},
{0} {0}
}; };
@ -21,7 +22,8 @@ struct argp argp = {
}; };
struct optData optData = { struct optData optData = {
false false,
"test",
}; };
error_t parseOptions(int key, char* arg, struct argp_state* state) { error_t parseOptions(int key, char* arg, struct argp_state* state) {
@ -30,6 +32,10 @@ error_t parseOptions(int key, char* arg, struct argp_state* state) {
optData.useHaar = true; optData.useHaar = true;
break; break;
case 'm':
optData.model = std::string(arg);
break;
default: default:
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
} }

View file

@ -1,12 +1,14 @@
#ifndef ARGS_HPP #ifndef ARGS_HPP
#define ARGS_HPP #define ARGS_HPP
#include <string>
#include <argp.h> #include <argp.h>
error_t parseOptions(int key, char* arg, struct argp_state* state); error_t parseOptions(int key, char* arg, struct argp_state* state);
struct optData { struct optData {
bool useHaar; //use haar cascades (0x00) bool useHaar; //use haar cascades (0x00)
std::string model; //model to open (0x6d "m")
}; };
extern const char* argp_program_version; extern const char* argp_program_version;

View file

@ -16,6 +16,7 @@
#include <paths.hpp> #include <paths.hpp>
#include <config.hpp> #include <config.hpp>
#include <cv.hpp> #include <cv.hpp>
#include <args.hpp>
GLuint shader; //standard shader program used for all elements GLuint shader; //standard shader program used for all elements
GLuint transUniform; //location of the "transMatrix" transformation matrix uniform in the shader GLuint transUniform; //location of the "transMatrix" transformation matrix uniform in the shader
@ -82,7 +83,7 @@ void initGraphics () {
initShader(); initShader();
model = new Model(resolvePath("models/test.fma").c_str()); model = new Model(resolvePath(("models/"+optData.model+".fma").c_str()).c_str());
//enable blending for alpha textures //enable blending for alpha textures
glEnable(GL_BLEND); glEnable(GL_BLEND);