static char *run_failure_tests(catcierge_haar_prey_method_t prey_method)
{
	int i;
	int j;
	catcierge_grb_t grb;
	catcierge_args_t *args = &grb.args;

	catcierge_grabber_init(&grb);

	catcierge_haar_matcher_args_init(&args->haar);
	args->saveimg = 0;
	args->matcher = "haar"; 
	args->matcher_type = MATCHER_HAAR;
	args->ok_matches_needed = 3;

	args->haar.prey_method = prey_method;
	args->haar.prey_steps = 2;
	args->haar.cascade = CATCIERGE_CASCADE;

	#ifdef CATCIERGE_GUI_TESTS
	args->show = 1;
	#endif
	//args->save_steps = 1;
	//args->saveimg = 1;

	if (catcierge_matcher_init(&grb.matcher, (catcierge_matcher_args_t *)&args->haar))
	{
		return "Failed to init catcierge lib!\n";
	}

	catcierge_haar_matcher_print_settings(&args->haar);

	catcierge_set_state(&grb, catcierge_state_waiting);

	for (j = 10; j <= 14; j++)
	{
		catcierge_test_STATUS("Test series %d", j);

		// This is the initial image that obstructs the frame
		// and triggers the matching.
		load_test_image_and_run(&grb, j, 1);
		mu_assert("Expected MATCHING state", (grb.state == catcierge_state_matching));
	
		// Match against 4 pictures, and decide the lockout status.
		for (i = 1; i <= 4; i++)
		{
			load_test_image_and_run(&grb, j, i);
		}

		mu_assert("Expected LOCKOUT state", (grb.state == catcierge_state_lockout));

		load_test_image_and_run(&grb, 1, 5);
		mu_assert("Expected WAITING state", (grb.state == catcierge_state_waiting));
	}

	catcierge_matcher_destroy(&grb.matcher);
	catcierge_grabber_destroy(&grb);

	return NULL;
}
static char *run_success_tests()
{
	int i;
	int j;
	catcierge_grb_t grb;
	catcierge_args_t *args = &grb.args;

	catcierge_grabber_init(&grb);
	catcierge_args_init_vars(args);

	catcierge_haar_matcher_args_init(&args->haar);
	args->saveimg = 0;
	args->matcher_type = MATCHER_HAAR;
	args->haar.cascade = strdup(CATCIERGE_CASCADE);

	if (catcierge_matcher_init(&grb.matcher, (catcierge_matcher_args_t *)&args->haar))
	{
		return "Failed to init catcierge lib!\n";
	}

	catcierge_haar_matcher_print_settings(&args->haar);

	grb.running = 1;
	catcierge_set_state(&grb, catcierge_state_waiting);

	for (j = 6; j <= 9; j++)
	{
		catcierge_test_STATUS("Test series %d", j);

		// This is the initial image that obstructs the frame
		// and triggers the matching.
		load_test_image_and_run(&grb, j, 1);
		mu_assert("Expected MATCHING state", (grb.state == catcierge_state_matching));
	
		// Match against 4 pictures, and decide the lockout status.
		for (i = 1; i <= 4; i++)
		{
			load_test_image_and_run(&grb, j, i);
		}

		mu_assert("Expected KEEP OPEN state", (grb.state == catcierge_state_keepopen));

		load_test_image_and_run(&grb, 1, 5);
		mu_assert("Expected WAITING state", (grb.state == catcierge_state_waiting));
	}

	catcierge_matcher_destroy(&grb.matcher);
	catcierge_args_destroy_vars(args);
	catcierge_grabber_destroy(&grb);

	return NULL;
}
Exemplo n.º 3
0
void catcierge_print_settings(catcierge_args_t *args)
{
	#ifdef WITH_RFID
	size_t i;
	#endif

	printf("--------------------------------------------------------------------------------\n");
	printf("Settings:\n");
	printf("--------------------------------------------------------------------------------\n");
	printf("General:\n");
	printf("          Show video: %d\n", args->show);
	printf("        Save matches: %d\n", args->saveimg);
	printf("       Save obstruct: %d\n", args->save_obstruct_img);
	printf("          Save steps: %d\n", args->save_steps);
	printf("     Highlight match: %d\n", args->highlight_match);
	printf("       Lockout dummy: %d\n", args->lockout_dummy);
	printf("      Lockout method: %d\n", args->lockout_method);
	printf("           Lock time: %d seconds\n", args->lockout_time);
	printf("       Lockout error: %d %s\n", args->max_consecutive_lockout_count,
							(args->max_consecutive_lockout_count == 0) ? "(off)" : "");
	printf("   Lockout err delay: %0.1f\n", args->consecutive_lockout_delay);
	printf("       Match timeout: %d seconds\n", args->match_time);
	printf("            Log file: %s\n", args->log_path ? args->log_path : "-");
	printf("            No color: %d\n", args->nocolor);
	printf("        No animation: %d\n", args->noanim);
	printf("   Ok matches needed: %d\n", args->ok_matches_needed);
	printf("         Output path: %s\n", args->output_path);
	if (args->match_output_path && strcmp(args->output_path, args->match_output_path))
	printf("   Match output path: %s\n", args->match_output_path);
	if (args->steps_output_path && strcmp(args->output_path, args->steps_output_path))
	printf("   Steps output path: %s\n", args->steps_output_path);
	if (args->obstruct_output_path && strcmp(args->output_path, args->obstruct_output_path))
	printf("Obstruct output path: %s\n", args->obstruct_output_path);
	if (args->template_output_path && strcmp(args->output_path, args->template_output_path))
	printf("Template output path: %s\n", args->template_output_path);
	#ifdef WITH_ZMQ
	printf("       ZMQ publisher: %d\n", args->zmq);
	printf("            ZMQ port: %d\n", args->zmq_port);
	printf("       ZMQ interface: %s\n", args->zmq_iface);
	printf("       ZMQ transport: %s\n", args->zmq_transport);
	#endif // WITH_ZMQ
	printf("        Matcher type: %s\n", args->matcher);
	printf("\n"); 
	if (!args->matcher || !strcmp(args->matcher, "template"))
		catcierge_template_matcher_print_settings(&args->templ);
	else
		catcierge_haar_matcher_print_settings(&args->haar);
	#ifdef WITH_RFID
	printf("RFID:\n");
	printf("          Inner RFID: %s\n", args->rfid_inner_path ? args->rfid_inner_path : "-");
	printf("          Outer RFID: %s\n", args->rfid_outer_path ? args->rfid_outer_path : "-");
	printf("     Lock on no RFID: %d\n", args->lock_on_invalid_rfid);
	printf("      RFID lock time: %.2f seconds\n", args->rfid_lock_time);
	printf("        Allowed RFID: %s\n", (args->rfid_allowed_count <= 0) ? "-" : args->rfid_allowed[0]);
	for (i = 1; i < args->rfid_allowed_count; i++)
	{
		printf("                 %s\n", args->rfid_allowed[i]);
	}
	#endif // WITH_RFID
	printf("--------------------------------------------------------------------------------\n");

}