def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images()
class hot_spot_scanning_images: def __init__(self): self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() # self.disp = Display((960, 720)) #((1024, 768)) # Create a display def scanning_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Hot spot detection", (260, img.height / 3), # (img.width, img.width), color=Color.WHITE, ) img.dl().text( "Press Enter", (340, img.height - 150), # (img.width, img.width), color=Color.WHITE, ) self.screen.show_till_press_enter(img) def show_final_result(self, img, max_temperature, x_location, y_location): img.dl().setFontSize(70) img.dl().text("Final result is:", (300, 50), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( ("Maximum detected temperature is: %s" % (max_temperature)), (125, 300), # (img.width, img.width), color=Color.WHITE, ) img.dl().text( ("Detected temperature coordinates: X - %s, Y - %s" % (x_location, y_location)), (125, 350), # (img.width, img.width), color=Color.WHITE, ) self.screen.show_till_press_enter(img)
class hot_spot_scanning_images(): def __init__(self): self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def scanning_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Hot spot detection", (260, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340, img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def show_final_result(self, img, max_temperature, x_location, y_location): img.dl().setFontSize(70) img.dl().text("Final result is:", (300, 50), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( ("Maximum detected temperature is: %s" % (max_temperature)), (125, 300), # (img.width, img.width), color=Color.WHITE) img.dl().text( ("Detected temperature coordinates: X - %s, Y - %s" % (x_location, y_location)), (125, 350), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img)
class LED_scanning_images(): def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def scanning_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "LED sequence detection", (205,img.height/3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340,img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def reading_from_file_image(self, m_led_coord_x, m_led_coord_y, dist_led, seq_time, avg_hue, avg_sat): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Reading calibration data", (160,50), color=Color.WHITE) img.dl().setFontSize(45) # img.dl().text("%f" % round(angle_average,2))[0:2] # "%04i" % found_object_x text_temp = "Main LED coordinates: X - %03i, Y - %03i" % (m_led_coord_x,m_led_coord_y) img.dl().text( text_temp, (120,250), color=Color.WHITE) text_temp = "Average colour data: Hue - %.1f, Sat - %.1f" % (round(avg_hue,2),round(avg_sat,2)) img.dl().text( text_temp, (120,300), color=Color.WHITE) text_temp = "Distance between always on and flashing LED - %.2f" % (round(dist_led,2)) img.dl().text( text_temp, (120,350), color=Color.WHITE) text_temp = "Sequence length - %i" % seq_time img.dl().text( text_temp, (120,400), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def looking_for_LED(self, img): img.dl().setFontSize(70) img.dl().text( "Looking for always on LED", (170, 30), # (img.width, img.width), color=Color.WHITE) return self.screen.show_briefly_till_n(img) def sequence_scanning_image_shown(self, img, main_blob, filtered_img_with_LEDs, crop_width, time_of_current_state, delta_T, number_of_blobs): img.dl().blit(filtered_img_with_LEDs, ((main_blob.coordinates()[0] - crop_width/2), main_blob.coordinates()[1] - crop_width/2)) img.dl().centeredRectangle((main_blob.coordinates()[0], main_blob.coordinates()[1]),(main_blob.width(),main_blob.height()), color = Color.RED, width = 2) img.dl().rectangle2pts( ((main_blob.coordinates()[0] - crop_width/2), (main_blob.coordinates()[1] + crop_width/2)), ((main_blob.coordinates()[0] + crop_width/2), (main_blob.coordinates()[1] - crop_width/2)), color = Color.YELLOW, width = 2) if number_of_blobs > 1: state = "ON" previous_state = "OFF" else: state = "OFF" previous_state = "ON" img.dl().setFontSize(70) img.dl().text( ("LED is: %s for: %.1fs" % (state, round(time_of_current_state,1))), (240, 30), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( ("Previous state was %s and lasted for: %.2fs" % (previous_state, delta_T)), (120,img.height - 80), # (img.width, img.width), color=Color.WHITE) return self.screen.show_briefly_till_n(img) def non_valid_scan(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Scanning results list:", (170,50), color=Color.WHITE) img.dl().setFontSize(45) img.dl().text( "Scanning results are not valid:", (120,250), color=Color.WHITE) img.dl().text( "Always on LED was not found for ", (120,300), color=Color.WHITE) img.dl().text( "more than half of the scan time", (120,350), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def scanning_done_image(self, results_list, average_period): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Scanning results list:", (210, 50), color=Color.WHITE) img.dl().setFontSize(45) results_limit = 11 iterator = range(1,results_limit) text_location = 120 for i in iterator: img.dl().text( results_list[i], (100,text_location), color=Color.WHITE) text_location = text_location + 50 img.dl().setFontSize(70) img.dl().text( ("Average period is: %s" % average_period), (210,img.height - 100), color=Color.WHITE) self.screen.show_till_press_enter(img)
def __init__(self): self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images()
# Scanning software has to be in "Controller folder" # Calibration files have to be in "Controller folder/Calibration_files". import math import sys # Only for RPI sys.path.append('/home/pi/MCS_Software') # Only for RPI from SimpleCV import * from Demonstration.show_images import Show_images screen = Show_images() # disp = Display((960, 720)) #((1024, 768)) 640,480 # Create a display IMAGE640 = Image("640Background.jpg") IMAGE1024 = Image("BlackBackground.gif") IMAGE960 = Image("960x720.jpg") BACKGROUND_IMAGE = IMAGE960 # Start of calibration def start_scanning_image(): img = BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Coolant valve handle detection", (110, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter",
class orange_calibration_images(): def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def calibration_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Orange flap calibration", (200,img.height/3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340,img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_flat_position(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(40) img.dl().text( "Place the camera as it would be during orange flap inspection", (60,img.height/3), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( "Put the orange flap to FLAT position", (180,img.height/3 + 50), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_slope_position(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(40) img.dl().text( "Place the camera as it would be during orange flap inspection", (60,img.height/3), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( "Put the orange flap to SLOPE position", (180,img.height/3 + 50), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_mouse_coords(self, img, crop_length): text_layer = DrawingLayer((img.width, img.height)) text_layer.setFontSize(50) text_layer.text( "Left click on orange flap and press enter", (140, 30), # (img.width, img.width), color=Color.WHITE) text_layer.setFontSize(40) text_layer.text( "Press N if orange flap is not clearly seen in the image", (110,img.height - 80), # (img.width, img.width), color=Color.WHITE) local_result = self.screen.get_coords_YorN(img, crop_length, text_layer) return local_result def no_flaps_found(self, img): img.dl().setFontSize(70) img.dl().text( "Flap was not found", (245, 30), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def show_detected_orange_flap(self, img, detected_flap, FlapWHRatio, position): if position == "Flat": text_colour = Color.YELLOW else: text_colour = Color.RED img.dl().rectangle2pts(detected_flap.bottomLeftCorner(), detected_flap.topRightCorner(), text_colour, width = 3) img.dl().setFontSize(35) # to show the width: width_text = "%s" % detected_flap.width() width_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width()/2 - 15) width_y = int(detected_flap.bottomLeftCorner()[1] + 5) img.dl().text( width_text, (width_x,width_y), color=text_colour) # to show the height: height_text = "%s" % detected_flap.height() height_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width() + 5) height_y = int(detected_flap.bottomLeftCorner()[1] - detected_flap.height()/2 - 10) img.dl().text( height_text, (height_x,height_y), color=text_colour) img.dl().setFontSize(50) img.dl().text( "Press Y if orange flap was correctly found", (130, 30), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( "Press N if orange flap was not found correctly", (160,img.height - 80), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( ("%s W/H ratio: %.3f" % (position, FlapWHRatio)), (20, 540), # (img.width, img.width), color=text_colour) if self.screen.show_till_YorN(img): result_local = True else: result_local = False return result_local def data_stored_image(self, coord_x, coord_y, flat_ratio, slope_ratio, colour_hue, colour_sat): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Data is recorded and stored", (160,50), color=Color.WHITE) img.dl().setFontSize(45) # img.dl().text("%f" % round(angle_average,2))[0:2] # "%04i" % found_object_x text_temp = "Flap coordinates: X - %03i, Y - %03i" % (coord_x,coord_y) img.dl().text( text_temp, (120,250), color=Color.WHITE) text_temp = "W/H ratios: flat - %.2f, slope - %.2f" % (round(flat_ratio,3),round(slope_ratio,3)) img.dl().text( text_temp, (120,300), color=Color.WHITE) text_temp = "Average colour data: Hue - %.1f, Sat - %.1f" % (round(colour_hue,2),round(colour_sat,2)) img.dl().text( text_temp, (120,350), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img)
class orange_scanning_images(): def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def scanning_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Orange flap detection", (210,img.height/3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340,img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def reading_from_file_image(self, coord_x, coord_y, flat_ratio, slope_ratio, colour_hue, colour_sat): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Reading calibration data", (160,50), color=Color.WHITE) img.dl().setFontSize(45) # img.dl().text("%f" % round(angle_average,2))[0:2] # "%04i" % found_object_x text_temp = "Flap coordinates: X - %03i, Y - %03i" % (coord_x,coord_y) img.dl().text( text_temp, (120,250), color=Color.WHITE) text_temp = "W/H ratios: flat - %.2f, slope - %.2f" % (round(flat_ratio,3),round(slope_ratio,3)) img.dl().text( text_temp, (120,300), color=Color.WHITE) text_temp = "Average colour data: Hue - %.1f, Sat - %.1f" % (round(colour_hue,2),round(colour_sat,2)) img.dl().text( text_temp, (120,350), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340,img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def no_flaps_found(self, img): img.dl().setFontSize(70) img.dl().text( "Flap was not found", (245, 30), # (img.width, img.width), color=Color.WHITE) return self.screen.show_briefly_till_n(img) def show_detected_orange_flap(self, img, detected_flap, FlapWHRatio, position, flat_ratio, slope_ratio): if position == "Flat": text_colour = Color.YELLOW else: text_colour = Color.RED img.dl().rectangle2pts(detected_flap.bottomLeftCorner(), detected_flap.topRightCorner(), text_colour, width = 3) img.dl().setFontSize(35) # to show the width: width_text = "%s" % detected_flap.width() width_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width()/2 - 15) width_y = int(detected_flap.bottomLeftCorner()[1] + 5) img.dl().text( width_text, (width_x,width_y), color=text_colour) # to show the height: height_text = "%s" % detected_flap.height() height_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width() + 5) height_y = int(detected_flap.bottomLeftCorner()[1] - detected_flap.height()/2 - 10) img.dl().text( height_text, (height_x,height_y), color=text_colour) img.dl().setFontSize(40) img.dl().text( ("Detected W/H ratio: %.3f" % (FlapWHRatio)), (20, 500), # (img.width, img.width), color=text_colour) img.dl().text( ("Flat W/H ratio: %.3f" % (flat_ratio)), (20, 540), # (img.width, img.width), color=Color.YELLOW) img.dl().text( ("Slope W/H ratio: %.3f" % (slope_ratio)), (20, 580), # (img.width, img.width), color=Color.RED) img.dl().setFontSize(60) img.dl().text( ("Flap position is: %s" % position), (200, 40), color = text_colour) return self.screen.show_briefly_till_n(img)
class orange_calibration_images(): def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def calibration_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "Orange flap calibration", (200, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340, img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_flat_position(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(40) img.dl().text( "Place the camera as it would be during orange flap inspection", (60, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( "Put the orange flap to FLAT position", (180, img.height / 3 + 50), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_slope_position(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(40) img.dl().text( "Place the camera as it would be during orange flap inspection", (60, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( "Put the orange flap to SLOPE position", (180, img.height / 3 + 50), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def ask_for_mouse_coords(self, img, crop_length): text_layer = DrawingLayer((img.width, img.height)) text_layer.setFontSize(50) text_layer.text( "Left click on orange flap and press enter", (140, 30), # (img.width, img.width), color=Color.WHITE) text_layer.setFontSize(40) text_layer.text( "Press N if orange flap is not clearly seen in the image", (110, img.height - 80), # (img.width, img.width), color=Color.WHITE) local_result = self.screen.get_coords_YorN(img, crop_length, text_layer) return local_result def no_flaps_found(self, img): img.dl().setFontSize(70) img.dl().text( "Flap was not found", (245, 30), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def show_detected_orange_flap(self, img, detected_flap, FlapWHRatio, position): if position == "Flat": text_colour = Color.YELLOW else: text_colour = Color.RED img.dl().rectangle2pts(detected_flap.bottomLeftCorner(), detected_flap.topRightCorner(), text_colour, width=3) img.dl().setFontSize(35) # to show the width: width_text = "%s" % detected_flap.width() width_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width() / 2 - 15) width_y = int(detected_flap.bottomLeftCorner()[1] + 5) img.dl().text(width_text, (width_x, width_y), color=text_colour) # to show the height: height_text = "%s" % detected_flap.height() height_x = int(detected_flap.bottomLeftCorner()[0] + detected_flap.width() + 5) height_y = int(detected_flap.bottomLeftCorner()[1] - detected_flap.height() / 2 - 10) img.dl().text(height_text, (height_x, height_y), color=text_colour) img.dl().setFontSize(50) img.dl().text( "Press Y if orange flap was correctly found", (130, 30), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( "Press N if orange flap was not found correctly", (160, img.height - 80), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(40) img.dl().text( ("%s W/H ratio: %.3f" % (position, FlapWHRatio)), (20, 540), # (img.width, img.width), color=text_colour) if self.screen.show_till_YorN(img): result_local = True else: result_local = False return result_local def data_stored_image(self, coord_x, coord_y, flat_ratio, slope_ratio, colour_hue, colour_sat): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text("Data is recorded and stored", (160, 50), color=Color.WHITE) img.dl().setFontSize(45) # img.dl().text("%f" % round(angle_average,2))[0:2] # "%04i" % found_object_x text_temp = "Flap coordinates: X - %03i, Y - %03i" % (coord_x, coord_y) img.dl().text(text_temp, (120, 250), color=Color.WHITE) text_temp = "W/H ratios: flat - %.2f, slope - %.2f" % (round( flat_ratio, 3), round(slope_ratio, 3)) img.dl().text(text_temp, (120, 300), color=Color.WHITE) text_temp = "Average colour data: Hue - %.1f, Sat - %.1f" % (round( colour_hue, 2), round(colour_sat, 2)) img.dl().text(text_temp, (120, 350), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img)
class LED_scanning_images(): def __init__(self): self.IMAGE640 = Image("640Background.jpg") self.IMAGE1024 = Image("BlackBackground.gif") self.IMAGE960 = Image("960x720.jpg") self.BACKGROUND_IMAGE = self.IMAGE960 self.screen = Show_images() #self.disp = Display((960, 720)) #((1024, 768)) # Create a display def scanning_start(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text( "LED sequence detection", (205, img.height / 3), # (img.width, img.width), color=Color.WHITE) img.dl().text( "Press Enter", (340, img.height - 150), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def reading_from_file_image(self, m_led_coord_x, m_led_coord_y, dist_led, seq_time, avg_hue, avg_sat): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text("Reading calibration data", (160, 50), color=Color.WHITE) img.dl().setFontSize(45) # img.dl().text("%f" % round(angle_average,2))[0:2] # "%04i" % found_object_x text_temp = "Main LED coordinates: X - %03i, Y - %03i" % ( m_led_coord_x, m_led_coord_y) img.dl().text(text_temp, (120, 250), color=Color.WHITE) text_temp = "Average colour data: Hue - %.1f, Sat - %.1f" % (round( avg_hue, 2), round(avg_sat, 2)) img.dl().text(text_temp, (120, 300), color=Color.WHITE) text_temp = "Distance between always on and flashing LED - %.2f" % ( round(dist_led, 2)) img.dl().text(text_temp, (120, 350), color=Color.WHITE) text_temp = "Sequence length - %i" % seq_time img.dl().text(text_temp, (120, 400), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def looking_for_LED(self, img): img.dl().setFontSize(70) img.dl().text( "Looking for always on LED", (170, 30), # (img.width, img.width), color=Color.WHITE) return self.screen.show_briefly_till_n(img) def sequence_scanning_image_shown(self, img, main_blob, filtered_img_with_LEDs, crop_width, time_of_current_state, delta_T, number_of_blobs): img.dl().blit(filtered_img_with_LEDs, ((main_blob.coordinates()[0] - crop_width / 2), main_blob.coordinates()[1] - crop_width / 2)) img.dl().centeredRectangle( (main_blob.coordinates()[0], main_blob.coordinates()[1]), (main_blob.width(), main_blob.height()), color=Color.RED, width=2) img.dl().rectangle2pts(((main_blob.coordinates()[0] - crop_width / 2), (main_blob.coordinates()[1] + crop_width / 2)), ((main_blob.coordinates()[0] + crop_width / 2), (main_blob.coordinates()[1] - crop_width / 2)), color=Color.YELLOW, width=2) if number_of_blobs > 1: state = "ON" previous_state = "OFF" else: state = "OFF" previous_state = "ON" img.dl().setFontSize(70) img.dl().text( ("LED is: %s for: %.1fs" % (state, round(time_of_current_state, 1))), (240, 30), # (img.width, img.width), color=Color.WHITE) img.dl().setFontSize(50) img.dl().text( ("Previous state was %s and lasted for: %.2fs" % (previous_state, delta_T)), (120, img.height - 80), # (img.width, img.width), color=Color.WHITE) return self.screen.show_briefly_till_n(img) def non_valid_scan(self): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text("Scanning results list:", (170, 50), color=Color.WHITE) img.dl().setFontSize(45) img.dl().text("Scanning results are not valid:", (120, 250), color=Color.WHITE) img.dl().text("Always on LED was not found for ", (120, 300), color=Color.WHITE) img.dl().text("more than half of the scan time", (120, 350), color=Color.WHITE) img.dl().setFontSize(70) img.dl().text( "Press Enter", (340, img.height - 100), # (img.width, img.width), color=Color.WHITE) self.screen.show_till_press_enter(img) def scanning_done_image(self, results_list, average_period): img = self.BACKGROUND_IMAGE img.dl().setFontSize(70) img.dl().text("Scanning results list:", (210, 50), color=Color.WHITE) img.dl().setFontSize(45) results_limit = 11 iterator = range(1, results_limit) text_location = 120 for i in iterator: img.dl().text(results_list[i], (100, text_location), color=Color.WHITE) text_location = text_location + 50 img.dl().setFontSize(70) img.dl().text(("Average period is: %s" % average_period), (210, img.height - 100), color=Color.WHITE) self.screen.show_till_press_enter(img)