#include #include #include #include "/usr/local/include/opencv/cv.h" #include "/usr/local/include/opencv/highgui.h" #include "/usr/local/include/opencv/cvaux.h" #include "/usr/local/include/opencv/cxcore.h" using namespace std; using namespace cv; int main (int argc, char *argv[]) { cv::Mat source_image; char input_filename[1280]; // 1280 = 1024 bytes for file path + 256 bytes for filename. char output_filename[1280]; char text_to_display[50]; CvPoint point_P1, point_P2, point_origin; int bounding_box_left_eye_x, bounding_box_left_eye_y, bounding_box_left_eye_width, bounding_box_left_eye_height; int bounding_box_right_eye_x, bounding_box_right_eye_y, bounding_box_right_eye_width, bounding_box_right_eye_height; int text_box_x, text_box_y, center_point_x, center_point_y; int frame, radius; frame = 1; snprintf (&input_filename[0], sizeof(input_filename) - 1, "test_image.%d.png", frame); source_image = imread (&input_filename[0], 1); if (!source_image.empty()) { text_box_x = 50; text_box_y = 50; center_point_x = 490; center_point_y = 690; radius = 350; bounding_box_left_eye_x = 527; bounding_box_left_eye_y = 498; bounding_box_left_eye_width = 177; bounding_box_left_eye_height = 118; bounding_box_right_eye_x = 274; bounding_box_right_eye_y = 503; bounding_box_right_eye_width = 173; bounding_box_right_eye_height = 115; snprintf (&text_to_display[0], sizeof(text_to_display) - 1, "Frame: %d", frame); point_origin = cvPoint (text_box_x, text_box_y); putText (source_image, &text_to_display[0], point_origin, FONT_HERSHEY_SIMPLEX, 1, CV_RGB(0, 0, 0), 2, 8, false); point_P1 = cvPoint (center_point_x, center_point_y); circle (source_image, point_P1, radius, CV_RGB (0, 255, 255), 2, 8, 0); point_P1 = cvPoint (bounding_box_left_eye_x, bounding_box_left_eye_y); point_P2 = cvPoint (bounding_box_left_eye_x + bounding_box_left_eye_width, bounding_box_left_eye_y + bounding_box_left_eye_height); rectangle (source_image, point_P1, point_P2, CV_RGB (0, 0, 255), 2, 8, 0); point_P1 = cvPoint (bounding_box_right_eye_x, bounding_box_right_eye_y); point_P2 = cvPoint (bounding_box_right_eye_x + bounding_box_right_eye_width, bounding_box_right_eye_y + bounding_box_right_eye_height); rectangle (source_image, point_P1, point_P2, CV_RGB (255, 255, 0), 2, 8, 0); snprintf (&output_filename[0], sizeof(output_filename) - 1, "OUTPUT-%s", &input_filename[0]); imwrite (output_filename, source_image); printf ("DONE: %s\n", output_filename); } }