Add option to enable/disable camera feed window
By default, camera feed will not be shown to the user.
This commit is contained in:
parent
160e9a02f2
commit
bb82a0ddd5
|
@ -12,7 +12,8 @@ const char* argp_program_version =
|
|||
const struct argp_option options[] = {
|
||||
//name, key, arg, flags, doc, group
|
||||
{"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},
|
||||
{"show-camera", 0x01, 0, 0, "Show the camera feed in another window", 0},
|
||||
{"model", 'm', "model", 0, "Name of the model file to use. (not including '.fma')", 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -25,6 +26,7 @@ struct argp argp = {
|
|||
#endif
|
||||
|
||||
struct optData optData = {
|
||||
false,
|
||||
false,
|
||||
"test",
|
||||
};
|
||||
|
@ -36,6 +38,10 @@ error_t parseOptions(int key, char* arg, struct argp_state* state) {
|
|||
optData.useHaar = true;
|
||||
break;
|
||||
|
||||
case 0x01: //--show-camera
|
||||
optData.showCamera = true;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
optData.model = std::string(arg);
|
||||
break;
|
||||
|
|
|
@ -10,8 +10,9 @@ error_t parseOptions(int key, char* arg, struct argp_state* state);
|
|||
#endif
|
||||
|
||||
struct optData {
|
||||
bool useHaar; //use haar cascades (0x00)
|
||||
std::string model; //model to open (0x6d "m")
|
||||
bool useHaar; // use haar cascades (0x00)
|
||||
bool showCamera; // show camera feed (0x01)
|
||||
std::string model; // model to open (0x6d 'm')
|
||||
};
|
||||
|
||||
extern const char* argp_program_version;
|
||||
|
|
|
@ -16,6 +16,10 @@ bool configFileOpen(struct optData* data) {
|
|||
if (useHaarResult.first) {
|
||||
data->useHaar = useHaarResult.second;
|
||||
}
|
||||
auto showCameraResult = configFile.table->getBool("show_camera");
|
||||
if (showCameraResult.first) {
|
||||
data->showCamera = showCameraResult.second;
|
||||
}
|
||||
auto modelNameResult = configFile.table->getString("model");
|
||||
if (modelNameResult.first) {
|
||||
data->model = modelNameResult.second;
|
||||
|
|
|
@ -209,7 +209,7 @@ void cvFrame() {
|
|||
}
|
||||
|
||||
void cvShowFrame() {
|
||||
if(frame.empty()) return;
|
||||
if(frame.empty() || !optData.showCamera) return;
|
||||
|
||||
cv::imshow("Video Input", frame);
|
||||
cv::waitKey(1);
|
||||
|
|
|
@ -22,6 +22,7 @@ class ConfigurationFrame : public wxFrame {
|
|||
private:
|
||||
std::vector<std::string> modelVec;
|
||||
wxCheckBox* useHaarCheckBox;
|
||||
wxCheckBox* showCameraCheckBox;
|
||||
wxChoice* modelNameChoice;
|
||||
void loadExistingConfig(); // loads existing config file and populates controls
|
||||
void OnApply(wxCommandEvent& event);
|
||||
|
@ -52,6 +53,7 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
|
|||
|
||||
// define all controls and labels
|
||||
useHaarCheckBox = new wxCheckBox(panel, wxID_ANY, "Disable DNN face detection");
|
||||
showCameraCheckBox = new wxCheckBox(panel, wxID_ANY, "Show camera feed");
|
||||
wxStaticText* modelNameText = new wxStaticText(panel, wxID_ANY, "Model name:");
|
||||
modelNameChoice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, modelVec.size(), modelArray);
|
||||
|
||||
|
@ -61,6 +63,7 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
|
|||
|
||||
wxStaticBoxSizer* generalBoxSizer = new wxStaticBoxSizer(new wxStaticBox(panel, wxID_ANY, "General"), wxVERTICAL);
|
||||
generalBoxSizer->Add(modelSizer, 0, wxALL, 5);
|
||||
generalBoxSizer->Add(showCameraCheckBox, 0, wxALL, 5);
|
||||
|
||||
wxStaticBoxSizer* performanceBoxSizer = new wxStaticBoxSizer(new wxStaticBox(panel, wxID_ANY, "Performance"), wxVERTICAL);
|
||||
performanceBoxSizer->Add(useHaarCheckBox, 0, wxALL, 5);
|
||||
|
@ -92,6 +95,7 @@ void ConfigurationFrame::loadExistingConfig() {
|
|||
configFileOpen(&configData);
|
||||
|
||||
useHaarCheckBox->SetValue(configData.useHaar);
|
||||
showCameraCheckBox->SetValue(configData.showCamera);
|
||||
for (int i = 0; i < modelVec.size(); i++) {
|
||||
if (modelVec[i] == configData.model) {
|
||||
modelNameChoice->SetSelection(i);
|
||||
|
@ -105,6 +109,7 @@ void ConfigurationFrame::OnApply(wxCommandEvent& event) {
|
|||
std::ofstream configFile;
|
||||
configFile.open(prefixConfig + "config.toml");
|
||||
configFile << "use_haar = " << (useHaarCheckBox->GetValue() ? "true" : "false") << std::endl;
|
||||
configFile << "show_camera = " << (showCameraCheckBox->GetValue() ? "true" : "false") << std::endl;
|
||||
// janky edge case lmao
|
||||
// if user did not select any model, don't write the line in the config file!
|
||||
if (modelNameChoice->GetSelection() != wxNOT_FOUND) {
|
||||
|
|
Loading…
Reference in a new issue