def draw_fake_balloon(self, frame, veh_pos, balloon_pos, vehicle_roll, vehicle_pitch, vehicle_yaw): # calculate bearing to balloon bearing_to_balloon = PositionVector.get_bearing(veh_pos, balloon_pos) yaw_to_balloon = balloon_utils.wrap_PI(bearing_to_balloon - vehicle_yaw) # calculate earth frame pitch angle from vehicle to balloon pitch_to_balloon = vehicle_pitch + PositionVector.get_elevation( veh_pos, balloon_pos) #print "Fake Balloon Bearing:%f Pitch:%f Dist:%f" % (math.degrees(bearing_to_balloon), math.degrees(pitch_to_balloon), dist_to_balloon_xy) # calculate pixel position of balloon balloon_x = balloon_video.angle_to_pixels_x( yaw_to_balloon) + balloon_video.img_center_x balloon_y = balloon_video.angle_to_pixels_y( pitch_to_balloon) + balloon_video.img_center_y # calculate size of balloon in pixels from distance and size dist_to_balloon_xyz = PositionVector.get_distance_xyz( veh_pos, balloon_pos) balloon_radius = balloon_utils.get_pixels_from_distance( dist_to_balloon_xyz, balloon_finder.balloon_radius_expected) # store balloon radius self.last_balloon_radius = balloon_radius # draw balloon cv2.circle(frame, (balloon_x, balloon_y), balloon_radius, self.fake_balloon_colour_bgr_scalar, -1)
def get_background(self, vehicle_roll, vehicle_pitch): # create sky coloured image image = numpy.zeros((balloon_video.img_height, balloon_video.img_width, 3),numpy.uint8) image[:] = self.background_sky_colour_bgr # create large rectangle which will become the ground top_left = balloon_utils.rotate_xy(balloon_video.img_center_x-1000, balloon_video.img_center_y, -vehicle_roll) top_right = balloon_utils.rotate_xy(balloon_video.img_center_x+1000, balloon_video.img_center_y, -vehicle_roll) bot_left = balloon_utils.rotate_xy(balloon_video.img_center_x-1000,balloon_video.img_center_y+1000, -vehicle_roll) bot_right = balloon_utils.rotate_xy(balloon_video.img_center_x+1000,balloon_video.img_center_y+1000, -vehicle_roll) # calculate vertical pixel shift pitch_pixel_shift = balloon_video.angle_to_pixels_y(vehicle_pitch) # add pitch adjustment top_left = balloon_utils.shift_pixels_down(top_left, pitch_pixel_shift) top_right = balloon_utils.shift_pixels_down(top_right, pitch_pixel_shift) bot_left = balloon_utils.shift_pixels_down(bot_left, pitch_pixel_shift) bot_right = balloon_utils.shift_pixels_down(bot_right, pitch_pixel_shift) # draw horizon box = numpy.array([top_left, top_right, bot_right, bot_left],numpy.int32) cv2.fillConvexPoly(image, box, self.background_ground_colour_bgr_scalar) return image
def draw_fake_balloon(self, frame, veh_pos, balloon_pos, vehicle_roll, vehicle_pitch, vehicle_yaw): # calculate bearing to balloon bearing_to_balloon = PositionVector.get_bearing(veh_pos, balloon_pos) yaw_to_balloon = balloon_utils.wrap_PI(bearing_to_balloon-vehicle_yaw) # calculate earth frame pitch angle from vehicle to balloon pitch_to_balloon = vehicle_pitch + PositionVector.get_elevation(veh_pos, balloon_pos) #print "Fake Balloon Bearing:%f Pitch:%f Dist:%f" % (math.degrees(bearing_to_balloon), math.degrees(pitch_to_balloon), dist_to_balloon_xy) # calculate pixel position of balloon balloon_x = balloon_video.angle_to_pixels_x(yaw_to_balloon) + balloon_video.img_center_x balloon_y = balloon_video.angle_to_pixels_y(pitch_to_balloon) + balloon_video.img_center_y # calculate size of balloon in pixels from distance and size dist_to_balloon_xyz = PositionVector.get_distance_xyz(veh_pos, balloon_pos) balloon_radius = balloon_utils.get_pixels_from_distance(dist_to_balloon_xyz, balloon_finder.balloon_radius_expected) # store balloon radius self.last_balloon_radius = balloon_radius # draw balloon cv2.circle(frame,(balloon_x,balloon_y), balloon_radius, self.fake_balloon_colour_bgr_scalar, -1)