@@ -104,7 +104,7 @@ def get_cameras_mac(self):
104104 from AVFoundation import AVCaptureDevice
105105
106106 except ImportError :
107- print ("Installez pyobjc avec 'pip install pyobjc'" )
107+ self . label . setText ("Installez pyobjc avec 'pip install pyobjc'" )
108108 return {}
109109
110110 camera_indices = []
@@ -282,11 +282,11 @@ def stop(self):
282282class VideoTreatment ():
283283 def __init__ (self , frame , rain_00ff00_image , rain_00ee00_image , rain_00dd00_image , rain_00cc00_image , rain_00bb00_image , rain_00aa00_image , rain_009900_image , rain_008800_image , rain_007700_image , drop_of_water_image_ascii , matrix_instance ):
284284 self .matrix_instance = matrix_instance
285- self .len_array_width = 110
286- self .len_array_height = 34
285+ self .len_array_width = 220
286+ self .len_array_height = 68
287287 super ().__init__ ()
288288 self .frame = frame
289- self .rain_drops = [[- 1 ] * 110 for _ in range (2 )]
289+ self .rain_drops = [[- 1 ] * 220 for _ in range (2 )]
290290 self .rain_00ff00_image = rain_00ff00_image
291291 self .rain_00ee00_image = rain_00ee00_image
292292 self .rain_00dd00_image = rain_00dd00_image
@@ -354,7 +354,6 @@ def update_ascii_image(self, frame):
354354 f = frame
355355 y_image = self .image_to_ascii (f )
356356 ascii_image = y_image
357- time .sleep (0.001 )
358357 self .create_rain_drops (ascii_image )
359358 except Exception as e :
360359 print (f"Erreur dans video_treatment.update_ascii_image: { e } " )
@@ -363,7 +362,7 @@ def update_ascii_image(self, frame):
363362 def create_rain_drops (self , ascii_image ):
364363 if self .running :
365364 try :
366- for column in range (110 ):
365+ for column in range (220 ):
367366 if self .rain_drops [0 ][column ] == - 1 :
368367 if self .drop_of_water_image_ascii [0 ][column ] == ' ' :
369368 self .rain_drops [0 ][column ] = 0
@@ -395,37 +394,52 @@ def create_rain_drops(self, ascii_image):
395394 self .drop_of_water_image_ascii [row - 1 ][column ] = ' '
396395 self .rain_00ff00_image [row - 1 ][column ] = ascii_image [row - 1 ][column ]
397396 if row - 2 >= 0 and row - 2 < self .len_array_height :
398- self .rain_00ff00_image [row - 2 ][column ] = ' '
399- self .rain_00ee00_image [row - 2 ][column ] = ascii_image [row - 2 ][column ]
397+ self .rain_00ff00_image [row - 2 ][column ] = ascii_image [row - 2 ][column ]
400398 if row - 3 >= 0 and row - 3 < self .len_array_height :
401- self .rain_00ee00_image [row - 3 ][column ] = ' '
402- self .rain_00dd00_image [row - 3 ][column ] = ascii_image [row - 3 ][column ]
399+ self .rain_00ff00_image [row - 3 ][column ] = ' '
400+ self .rain_00ee00_image [row - 3 ][column ] = ascii_image [row - 3 ][column ]
403401 if row - 4 >= 0 and row - 4 < self .len_array_height :
404- self .rain_00dd00_image [row - 4 ][column ] = ' '
405- self .rain_00cc00_image [row - 4 ][column ] = ascii_image [row - 4 ][column ]
406- if row - 5 >= 0 and row - 5 < self .len_array_height :
407- self .rain_00cc00_image [row - 5 ][column ] = ' '
408- self .rain_00bb00_image [row - 5 ][column ] = ascii_image [row - 5 ][column ]
402+ self .rain_00ee00_image [row - 4 ][column ] = ascii_image [row - 4 ][column ]
403+ if row - 5 >= 0 and row - 5 < self .len_array_height :
404+ self .rain_00ee00_image [row - 5 ][column ] = ' '
405+ self .rain_00dd00_image [row - 5 ][column ] = ascii_image [row - 5 ][column ]
409406 if row - 6 >= 0 and row - 6 < self .len_array_height :
410- self .rain_00bb00_image [row - 6 ][column ] = ' '
411- self .rain_00aa00_image [row - 6 ][column ] = ascii_image [row - 6 ][column ]
407+ self .rain_00dd00_image [row - 6 ][column ] = ascii_image [row - 6 ][column ]
412408 if row - 7 >= 0 and row - 7 < self .len_array_height :
413- self .rain_00aa00_image [row - 7 ][column ] = ' '
414- self .rain_009900_image [row - 7 ][column ] = ascii_image [row - 7 ][column ]
409+ self .rain_00dd00_image [row - 7 ][column ] = ' '
410+ self .rain_00cc00_image [row - 7 ][column ] = ascii_image [row - 7 ][column ]
415411 if row - 8 >= 0 and row - 8 < self .len_array_height :
416- self .rain_009900_image [row - 8 ][column ] = ' '
417- self .rain_008800_image [row - 8 ][column ] = ascii_image [row - 8 ][column ]
412+ self .rain_00cc00_image [row - 8 ][column ] = ' '
413+ self .rain_00bb00_image [row - 8 ][column ] = ascii_image [row - 8 ][column ]
418414 if row - 9 >= 0 and row - 9 < self .len_array_height :
419- self .rain_008800_image [row - 9 ][column ] = ' '
420- self .rain_007700_image [row - 9 ][column ] = ascii_image [row - 9 ][column ]
421- if row - 10 >= 0 and row - 10 < self .len_array_height :
422- self .rain_007700_image [row - 10 ][column ] = ' '
415+ self .rain_00bb00_image [row - 9 ][column ] = ' '
416+ self .rain_00aa00_image [row - 9 ][column ] = ascii_image [row - 9 ][column ]
417+ if row - 10 >= 0 and row - 10 < self .len_array_height :
418+ self .rain_00aa00_image [row - 10 ][column ] = ' '
419+ self .rain_009900_image [row - 10 ][column ] = ascii_image [row - 10 ][column ]
420+ if row - 11 >= 0 and row - 11 < self .len_array_height :
421+ self .rain_009900_image [row - 11 ][column ] = ascii_image [row - 11 ][column ]
422+ if row - 12 >= 0 and row - 12 < self .len_array_height :
423+ self .rain_009900_image [row - 12 ][column ] = ' '
424+ self .rain_008800_image [row - 12 ][column ] = ascii_image [row - 12 ][column ]
425+ if row - 13 >= 0 and row - 13 < self .len_array_height :
426+ self .rain_008800_image [row - 13 ][column ] = ascii_image [row - 13 ][column ]
427+ if row - 14 >= 0 and row - 14 < self .len_array_height :
428+ self .rain_008800_image [row - 14 ][column ] = ' '
429+ self .rain_007700_image [row - 14 ][column ] = ascii_image [row - 14 ][column ]
430+ if row - 15 >= 0 and row - 15 < self .len_array_height :
431+ self .rain_007700_image [row - 15 ][column ] = ' '
423432 if self .rain_00bb00_image [self .len_array_height - 1 ][column ] != ' ' :
424433 self .rain_00bb00_image [self .len_array_height - 1 ][column ] = ' '
425- self .rain_00aa00_image [self .len_array_height - 2 ][column ] = ' '
426- self .rain_009900_image [self .len_array_height - 3 ][column ] = ' '
427- self .rain_008800_image [self .len_array_height - 4 ][column ] = ' '
428- self .rain_007700_image [self .len_array_height - 5 ][column ] = ' '
434+ self .rain_00bb00_image [self .len_array_height - 2 ][column ] = ' '
435+ self .rain_00aa00_image [self .len_array_height - 3 ][column ] = ' '
436+ self .rain_00aa00_image [self .len_array_height - 4 ][column ] = ' '
437+ self .rain_009900_image [self .len_array_height - 5 ][column ] = ' '
438+ self .rain_009900_image [self .len_array_height - 6 ][column ] = ' '
439+ self .rain_008800_image [self .len_array_height - 7 ][column ] = ' '
440+ self .rain_008800_image [self .len_array_height - 8 ][column ] = ' '
441+ self .rain_007700_image [self .len_array_height - 9 ][column ] = ' '
442+ self .rain_007700_image [self .len_array_height - 10 ][column ] = ' '
429443
430444 ascii_image_result = ""
431445 drop_of_water_image_ascii_result = ""
@@ -487,7 +501,7 @@ def create_rain_drops(self, ascii_image):
487501 def send_to_virtual_camera (self , ascii_image_result , rain_00ff00_image_result , rain_00ee00_image_result , rain_00dd00_image_result , rain_00cc00_image_result , rain_00bb00_image_result , rain_00aa00_image_result , rain_009900_image_result , rain_008800_image_result , rain_007700_image_result , drop_of_water_image_ascii_result ):
488502 if self .running :
489503 width , height = 848 , 480
490- ascii_font_size_width = 16
504+ ascii_font_size_width = 8
491505 wd = sys ._MEIPASS if getattr (sys , 'frozen' , False ) else ''
492506 font_path = os .path .join (wd , '.' , 'mtx.ttf' )
493507 font = ImageFont .truetype (font_path , ascii_font_size_width )
@@ -554,14 +568,14 @@ def __init__(self):
554568 self .cap = None
555569 self .timer_capture = QTimer ()
556570 self .timer_capture .timeout .connect (self .capture_frame )
557- self .timer_capture .start (33 )
571+ self .timer_capture .start (100 )
558572
559573 self .rain_intensity = 0.5
560574 self .image_updated = ""
561575
562576 width , height = 848 , 480
563577
564- self .ascii_font_size_width = 20
578+ self .ascii_font_size_width = 8
565579 self .ascii_font_size_height = self .ascii_font_size_width * 9 / 16
566580
567581 self .font_path = os .path .join (self .wd , 'mtx.ttf' )
@@ -572,8 +586,8 @@ def __init__(self):
572586 self .virtual_frame = np .zeros ((480 , 640 , 3 ), dtype = np .uint8 )
573587
574588 frame = None
575- self .len_array_width = 110
576- self .len_array_height = 34
589+ self .len_array_width = 220
590+ self .len_array_height = 68
577591 drop_of_water_image_ascii = [[' ' for _ in range (self .len_array_width )] for _ in range (self .len_array_height )]
578592 rain_00ff00_image = [[' ' for _ in range (self .len_array_width )] for _ in range (self .len_array_height )]
579593 rain_00ee00_image = [[' ' for _ in range (self .len_array_width )] for _ in range (self .len_array_height )]
@@ -694,7 +708,6 @@ def setCameraIndex(self, index):
694708 self .cap .set (cv2 .CAP_PROP_FRAME_WIDTH , 848 )
695709 self .cap .set (cv2 .CAP_PROP_FRAME_HEIGHT , 480 )
696710 self .cap .set (cv2 .CAP_PROP_FPS , 60 )
697- time .sleep (1 )
698711
699712 def stop (self ):
700713 # print("entre dans stop()\n")
@@ -730,6 +743,7 @@ def initUI(self):
730743 if not self .UIdefine :
731744 # print("entre dans matrix.initUI()\n")
732745 self .setWindowFlags (self .windowFlags () & ~ Qt .WindowType .FramelessWindowHint )
746+ self .setStyleSheet ("background-color: black;" )
733747
734748 frame = QFrame (self )
735749 frame .setFrameStyle (QFrame .Shape .NoFrame )
0 commit comments