void janus_close_video(janus_video video) { ppr_video_io_close((ppr_video_io_type)video); }
/* Overlays bounding boxes and landmarks from tracks onto copies of the frames in the video */ void sdk_draw_utils_overlay_track_list_on_video( const char *in_filename, ppr_track_list_type track_list, int min_confidence, int overlay_frame_numbers, const char *output_video_format) { int i; int frame_num; ppr_video_io_type input_video; ppr_video_io_type output_video; int frame_rate_numerator; int frame_rate_denominator; int *i_tracked_face_lists; ppr_face_attributes_type face_attributes; ppr_raw_image_type raw_image; char title[FILENAME_MAX]; char out_filename[FILENAME_MAX]; /* Open video */ TRY_VIDEO(ppr_video_io_open(&input_video, in_filename)); TRY_VIDEO(ppr_video_io_get_frame_rate(input_video, &frame_rate_numerator, &frame_rate_denominator)); /* Create output video */ sdk_utils_get_file_title(in_filename, title); sprintf(out_filename, "%s_track_overlay.%s", title, output_video_format); TRY_VIDEO(ppr_video_io_create(&output_video, out_filename, BIT_RATE, frame_rate_numerator, frame_rate_denominator)); /* Create array of indices into tracked face arrays */ i_tracked_face_lists = (int*)malloc(track_list.length * sizeof(int)); sdk_utils_check_allocation(i_tracked_face_lists, "i_tracked_face_lists", __FUNCTION__); for (i = 0; i < track_list.length; i++) i_tracked_face_lists[i] = 0; /* Loop through each frame of video */ frame_num = 0; while (ppr_video_io_is_frame_available(input_video)) { /* Read frame from video */ TRY_VIDEO(ppr_video_io_get_frame(input_video, &raw_image)); /* Overlay polygons on frame */ sdk_draw_utils_advance_indices_to_frame(track_list, i_tracked_face_lists, frame_num); for (i = 0; i < track_list.length; i++) { ppr_get_face_attributes(track_list.tracks[i].tracked_faces.faces[i_tracked_face_lists[i]], &face_attributes); if (face_attributes.tracking_info.frame_number == frame_num) { /* Overlay polygon for this face */ sdk_draw_utils_overlay_tracked_faces(&raw_image, 1, &track_list.tracks[i].tracked_faces.faces[i_tracked_face_lists[i]], min_confidence); } } /* Overlay frame number on frame */ if (overlay_frame_numbers) sdk_draw_utils_overlay_frame_number(&raw_image, frame_num); /* Write frame to output video */ TRY_VIDEO(ppr_video_io_add_frame(output_video, raw_image)); /* Free frame */ ppr_raw_image_free(raw_image); /* Advance to next frame */ TRY_VIDEO(ppr_video_io_step_forward(input_video)); frame_num++; } /* Close video */ TRY_VIDEO(ppr_video_io_close(input_video)); TRY_VIDEO(ppr_video_io_close(output_video)); /* Clean up */ free(i_tracked_face_lists); }