int TEST_catcierge_fsm_haar_matcher(int argc, char **argv) { char *e = NULL; int ret = 0; catcierge_test_HEADLINE("TEST_catcierge_fsm_haar_matcher"); catcierge_haar_matcher_usage(); CATCIERGE_RUN_TEST((e = run_success_tests()), "Run success tests. Without obstruct", "Success match without obstruct", &ret); CATCIERGE_RUN_TEST((e = run_failure_tests(PREY_METHOD_NORMAL)), "Run failure tests. Normal prey matching", "Failure tests with Normal prey matching", &ret); CATCIERGE_RUN_TEST((e = run_failure_tests(PREY_METHOD_ADAPTIVE)), "Run failure tests. Adaptive prey matching", "Failure tests with Adaptive prey matching", &ret); CATCIERGE_RUN_TEST((e = run_save_steps_test()), "Run save steps tests. Adaptive prey matching", "Save steps tests", &ret); if (ret) { catcierge_test_FAILURE("One or more tests failed"); } return ret; }
void catcierge_show_usage(catcierge_args_t *args, const char *prog) { fprintf(stderr, "Usage: %s [options]\n\n", prog); fprintf(stderr, " --config <path> Path to config file. Default is ./catcierge.cfg\n"); fprintf(stderr, " or /etc/catcierge.cfg\n"); fprintf(stderr, " This is parsed as an INI file. The keys/values are\n"); fprintf(stderr, " the same as these options.\n"); fprintf(stderr, "Lockout settings:\n"); fprintf(stderr, "-----------------\n"); fprintf(stderr, " --lockout_method <1|2|3>\n"); fprintf(stderr, " Defines the method used to decide when to unlock:\n"); fprintf(stderr, " [1: Wait for clear frame or that the timer has timed out.]\n"); fprintf(stderr, " 2: Wait for clear frame and then start unlock timer.\n"); fprintf(stderr, " 3: Only use the timer, don't care about clear frame.\n"); fprintf(stderr, " --lockout <seconds> The time in seconds a lockout takes. Default %d seconds.\n", DEFAULT_LOCKOUT_TIME); fprintf(stderr, " --lockout_error <n> Number of lockouts in a row that's allowed before we\n"); fprintf(stderr, " consider it an error and quit the program. \n"); fprintf(stderr, " Default is to never do this.\n"); fprintf(stderr, " --lockout_error_delay <seconds>\n"); fprintf(stderr, " The delay in seconds between lockouts that should be\n"); fprintf(stderr, " counted as a consecutive lockout. Default %0.1f\n", DEFAULT_CONSECUTIVE_LOCKOUT_DELAY); fprintf(stderr, " --lockout_dummy Do everything as normal, but don't actually\n"); fprintf(stderr, " lock the door. This is useful for testing.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Presentation settings:\n"); fprintf(stderr, "----------------------\n"); fprintf(stderr, " --show Show GUI of the camera feed (X11 only).\n"); fprintf(stderr, " --highlight Highlight the best match on saved images.\n"); fprintf(stderr, " --nocolor Turn off all color output.\n"); fprintf(stderr, " --noanim Turn off any animation.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Output settings:\n"); fprintf(stderr, "----------------\n"); fprintf(stderr, " --save Save match images (both ok and failed).\n"); fprintf(stderr, " --save_obstruct Save the image that triggered the \"frame obstructed\" event.\n"); fprintf(stderr, " --save_steps Save each step of the matching algorithm.\n"); fprintf(stderr, " (--save must also be turned on)\n"); fprintf(stderr, " --template <path> Path to one or more template files generated on specified events.\n"); fprintf(stderr, " (Not to be confused with the template matcher)\n"); fprintf(stderr, " --output_path <path> Path to where the match images and generated templates should be saved.\n"); fprintf(stderr, " Note that this path can contain variables of the format %%var%%\n"); fprintf(stderr, " when --new_execute is used. See --cmdhelp for available variables.\n"); fprintf(stderr, " --match_output_path <path>\n"); fprintf(stderr, " Override --output_path for match images and save them here instead.\n"); fprintf(stderr, " If --new_execute is used, this can be relative to --output_path\n"); fprintf(stderr, " by using %%output_path%% in the path.\n"); fprintf(stderr, " --steps_output_path <path>\n"); fprintf(stderr, " If --save_steps is enabled, save step images to this path.\n"); fprintf(stderr, " Same as for --match_output_path, overrides --output_path.\n"); fprintf(stderr, " --obstruct_output_path <path>\n"); fprintf(stderr, " Path for the obstruct images. Overrides --output_path.\n"); fprintf(stderr, " --template_output_path <path>\n"); fprintf(stderr, " Output path for templates. Overrides --output_path.\n"); fprintf(stderr, "\n"); fprintf(stderr, " --log <path> Log matches and rfid readings (if enabled).\n"); #ifdef WITH_ZMQ fprintf(stderr, " --zmq Publish generated output templates to a ZMQ socket.\n"); fprintf(stderr, " If a template contains the setting 'nozmq' it will not be published.\n"); fprintf(stderr, " --zmq_port The TCP port that the ZMQ publisher listens on. Default %d\n", DEFAULT_ZMQ_PORT); fprintf(stderr, " --zmq_iface The interface the ZMQ publisher listens on. Default %s\n", DEFAULT_ZMQ_IFACE); #endif // WITH_ZMQ fprintf(stderr, "\n"); fprintf(stderr, "Matcher settings:\n"); fprintf(stderr, "-----------------\n"); fprintf(stderr, " --ok_matches_needed <number>\n"); fprintf(stderr, " The number of matches out of %d matches\n", MATCH_MAX_COUNT); fprintf(stderr, " that need to be OK for the match to be considered\n"); fprintf(stderr, " an over all OK match.\n"); fprintf(stderr, " --matchtime <seconds> The time to wait after a match. Default %d seconds.\n", DEFAULT_MATCH_WAIT); fprintf(stderr, " --matcher <template|haar>\n"); fprintf(stderr, " The type of matcher to use. Haar cascade is more\n"); fprintf(stderr, " accurate if a well trained cascade exists for your cat.\n"); fprintf(stderr, " Template matcher is simpler, but doesn't require a trained cascade\n"); fprintf(stderr, " this is useful while gathering enough data to train the cascade.\n"); fprintf(stderr, " --no_final_decision Normally after all matches in a match group has been made\n"); fprintf(stderr, " the matcher algorithm gets to do a final decision based on\n"); fprintf(stderr, " the entire group of matches which overrides the \"--ok_matches_needed\"\n"); fprintf(stderr, " setting. This flag turns this behavior off.\n"); fprintf(stderr, "Haar cascade matcher:\n"); fprintf(stderr, "---------------------\n"); catcierge_haar_matcher_usage(); fprintf(stderr, "Template matcher:\n"); fprintf(stderr, "-----------------\n"); fprintf(stderr, "\nThe snout image refers to the image of the cat snout that is matched against.\n"); fprintf(stderr, "This image should be based on a 320x240 resolution image taken by the rpi camera.\n"); fprintf(stderr, "If no path is specified \"snout.png\" in the current directory is used.\n"); fprintf(stderr, "\n"); catcierge_template_matcher_usage(); #ifdef WITH_RFID fprintf(stderr, "\n"); fprintf(stderr, "RFID settings:\n"); fprintf(stderr, "-----\n"); fprintf(stderr, " --rfid_in <path> Path to inner RFID reader. Example: /dev/ttyUSB0\n"); fprintf(stderr, " --rfid_out <path> Path to the outter RFID reader.\n"); fprintf(stderr, " --rfid_lock Lock if no RFID tag present or invalid RFID tag. Default OFF.\n"); fprintf(stderr, " --rfid_time <seconds> Number of seconds to wait after a valid match before the\n"); fprintf(stderr, " RFID readers are checked.\n"); fprintf(stderr, " (This is so that there is enough time for the cat to be read by both readers)\n"); fprintf(stderr, " --rfid_allowed <list> A comma separated list of allowed RFID tags. Example: %s\n", EXAMPLE_RFID_STR); #endif // WITH_RFID fprintf(stderr, "\n"); #define EPRINT_CMD_HELP(fmt, ...) if (args->show_cmd_help) fprintf(stderr, fmt, ##__VA_ARGS__); fprintf(stderr, "Commands (new):\n"); fprintf(stderr, "---------------\n"); fprintf(stderr, "This is enabled using --new_execute. %%0, %%1... are deprecated, instead variable names are used.\n"); fprintf(stderr, "For example: %%state%%, %%match_success%% and so on.\n"); fprintf(stderr, "See --cmdhelp for a list of variables. Otherwise this uses the same\n"); fprintf(stderr, "command line arguments as the old commands section below.\n"); if (args->show_cmd_help) catcierge_output_print_usage(); if (args->show_cmd_help) catcierge_template_output_print_usage(); if (args->show_cmd_help) catcierge_haar_output_print_usage(); fprintf(stderr, "\n"); fprintf(stderr, "Commands (old):\n"); fprintf(stderr, "---------------\n"); fprintf(stderr, "(Note that %%0, %%1, ... will be replaced in the input, see --cmdhelp for details)\n"); EPRINT_CMD_HELP("\n"); EPRINT_CMD_HELP(" General: %%cwd will output the current working directory for this program.\n"); EPRINT_CMD_HELP(" Any paths returned are relative to this.\n"); EPRINT_CMD_HELP(" %%%% Produces a literal %% sign.\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --frame_obstructed_cmd <cmd>\n"); EPRINT_CMD_HELP(" Command to run when the frame becomes obstructed\n"); EPRINT_CMD_HELP(" and a new match is initiated. (--save_obstruct must be on).\n"); EPRINT_CMD_HELP(" %%0 = [path] Path to the image that obstructed the frame.\n"); fprintf(stderr, " --match_cmd <cmd> Command to run after a match is made.\n"); EPRINT_CMD_HELP(" %%0 = [float] Match result.\n"); EPRINT_CMD_HELP(" %%1 = [0/1] Success or failure.\n"); EPRINT_CMD_HELP(" %%2 = [path] Path to where image will be saved\n"); EPRINT_CMD_HELP(" (Not saved yet!)\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --save_img_cmd <cmd> Command to run at the moment a match image is saved.\n"); EPRINT_CMD_HELP(" %%0 = [float] Match result, 0.0-1.0\n"); EPRINT_CMD_HELP(" %%1 = [0/1] Match success.\n"); EPRINT_CMD_HELP(" %%2 = [string] Image path (Image is saved to disk).\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --match_group_done_cmd <cmd> Command that runs when all match images have been saved\n"); fprintf(stderr, " to disk.\n"); fprintf(stderr, " (This is most likely what you want to use in most cases)\n"); EPRINT_CMD_HELP(" %%0 = [0/1] Match success.\n"); EPRINT_CMD_HELP(" %%1 = [string] Image path for first match.\n"); EPRINT_CMD_HELP(" %%2 = [string] Image path for second match.\n"); EPRINT_CMD_HELP(" %%3 = [string] Image path for third match.\n"); EPRINT_CMD_HELP(" %%4 = [string] Image path for fourth match.\n"); EPRINT_CMD_HELP(" %%5 = [float] First image result.\n"); EPRINT_CMD_HELP(" %%6 = [float] Second image result.\n"); EPRINT_CMD_HELP(" %%7 = [float] Third image result.\n"); EPRINT_CMD_HELP(" %%8 = [float] Fourth image result.\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --match_done_cmd <cmd> Command to run when a match is done.\n"); EPRINT_CMD_HELP(" %%0 = [0/1] Match success.\n"); EPRINT_CMD_HELP(" %%1 = [int] Successful match count.\n"); EPRINT_CMD_HELP(" %%2 = [int] Max matches.\n"); EPRINT_CMD_HELP("\n"); #ifdef WITH_RFID fprintf(stderr, " --rfid_detect_cmd <cmd> Command to run when one of the RFID readers detects a tag.\n"); EPRINT_CMD_HELP(" %%0 = [string] RFID reader name.\n"); EPRINT_CMD_HELP(" %%1 = [string] RFID path.\n"); EPRINT_CMD_HELP(" %%2 = [0/1] Is allowed.\n"); EPRINT_CMD_HELP(" %%3 = [0/1] Is data incomplete.\n"); EPRINT_CMD_HELP(" %%4 = [string] Tag data.\n"); EPRINT_CMD_HELP(" %%5 = [0/1] Other reader triggered.\n"); EPRINT_CMD_HELP(" %%6 = [string] Direction (in, out or uknown).\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --rfid_match_cmd <cmd> Command that is run when a RFID match is made.\n"); EPRINT_CMD_HELP(" %%0 = Match success.\n"); EPRINT_CMD_HELP(" %%1 = RFID inner in use.\n"); EPRINT_CMD_HELP(" %%2 = RFID outer in use.\n"); EPRINT_CMD_HELP(" %%3 = RFID inner success.\n"); EPRINT_CMD_HELP(" %%4 = RFID outer success.\n"); EPRINT_CMD_HELP(" %%5 = RFID inner data.\n"); EPRINT_CMD_HELP(" %%6 = RFID outer data.\n"); EPRINT_CMD_HELP("\n"); fprintf(stderr, " --do_lockout_cmd <cmd> Command to run when the lockout should be performed.\n"); fprintf(stderr, " This will override the normal lockout method.\n"); fprintf(stderr, " --do_unlock_cmd <cmd> Command that is run when we should unlock.\n"); fprintf(stderr, " This will override the normal unlock method.\n"); fprintf(stderr, " --state_change_cmd <cmd>\n"); fprintf(stderr, " Command to run when the state machine changes state.\n"); fprintf(stderr, " %%0 = Previous state.\n"); fprintf(stderr, " %%1 = New state.\n"); fprintf(stderr, "\n"); #endif // WITH_RFID fprintf(stderr, " --help Show this help.\n"); fprintf(stderr, " --cmdhelp Show extra command help.\n"); #ifdef RPI fprintf(stderr, " --camhelp Show extra Raspberry pi camera settings help.\n"); fprintf(stderr, " Note that all these settings must be prepended\n"); fprintf(stderr, " with \"rpi-\"\n"); #endif #ifndef _WIN32 fprintf(stderr, "Signals:\n"); fprintf(stderr, "The program can receive signals that can be sent using the kill command.\n"); fprintf(stderr, " SIGUSR1 = Force the cat door to unlock\n"); fprintf(stderr, " SIGUSR2 = Force the cat door to lock (for lock timeout)\n"); fprintf(stderr, "\n"); #endif // _WIN32 }