Ejemplo n.º 1
0
void draw_simulator(Simulator *sim, IplImage *debug, CvFont *font)
{
	float bright = 0.0;
	float dark = 1.0;
	median(sim->width, sim->white, sim->start, sim->stop,
		   NULL, &bright, NULL, NULL, NULL);
	median(sim->width, sim->black, sim->start, sim->stop,
		   NULL, NULL, NULL, &dark, NULL);
	bright -= (dark - bright) / 10;
	float scale = 1.0 / (dark - bright);
	float offset = -bright * scale;
	// printf("bright=%.3f dark=%.3f offset=%.3f scale=%.3f\n",
	//        bright, dark, offset, scale);
	cvSet(debug, cvScalarAll(255), NULL);
	draw_sections(96, sim->sections, sim->width,
				  debug, cvScalar(160, 160, 160, 255), 1);
	draw_curve(sim->width, sim->input, offset, scale,
			   debug, cvScalar(255, 0, 0, 255), 1);
	draw_curve(sim->width, sim->threshold, offset, scale,
			   debug, cvScalar(255, 160, 0, 255), 1);
	draw_curve(sim->width, sim->black, offset, scale,
			   debug, cvScalar(180, 180, 180, 255), 1);
	draw_curve(sim->width, sim->white, offset, scale,
			   debug, cvScalar(180, 180, 180, 255), 1);
	draw_curve(sim->width, sim->guess, offset, scale,
			   debug, cvScalar(160, 160, 255, 255), 1);
	draw_curve(sim->width, sim->blur, offset, scale,
			   debug, cvScalar(0, 0, 255, 255), 1);
	draw_digits(sim, sim->unchanged_digits, sim->digits, 34, debug, font);
	draw_digits(sim, sim->digits, NULL, 4, debug, font);
}
Ejemplo n.º 2
0
void reset_score () {
    set_color(BLACK);
    draw_digits(RESET_SCORE, X_COORDINATE_SCORE_PLAYER1, 2*SEGMENT_LENGTH);
    draw_digits(RESET_SCORE, X_COORDINATE_SCORE_PLAYER2, 2*SEGMENT_LENGTH);
}