@@ -104,7 +104,7 @@ def get_cameras_mac(self):
104
104
from AVFoundation import AVCaptureDevice
105
105
106
106
except ImportError :
107
- print ("Installez pyobjc avec 'pip install pyobjc'" )
107
+ self . label . setText ("Installez pyobjc avec 'pip install pyobjc'" )
108
108
return {}
109
109
110
110
camera_indices = []
@@ -282,11 +282,11 @@ def stop(self):
282
282
class VideoTreatment ():
283
283
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 ):
284
284
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
287
287
super ().__init__ ()
288
288
self .frame = frame
289
- self .rain_drops = [[- 1 ] * 110 for _ in range (2 )]
289
+ self .rain_drops = [[- 1 ] * 220 for _ in range (2 )]
290
290
self .rain_00ff00_image = rain_00ff00_image
291
291
self .rain_00ee00_image = rain_00ee00_image
292
292
self .rain_00dd00_image = rain_00dd00_image
@@ -354,7 +354,6 @@ def update_ascii_image(self, frame):
354
354
f = frame
355
355
y_image = self .image_to_ascii (f )
356
356
ascii_image = y_image
357
- time .sleep (0.001 )
358
357
self .create_rain_drops (ascii_image )
359
358
except Exception as e :
360
359
print (f"Erreur dans video_treatment.update_ascii_image: { e } " )
@@ -363,7 +362,7 @@ def update_ascii_image(self, frame):
363
362
def create_rain_drops (self , ascii_image ):
364
363
if self .running :
365
364
try :
366
- for column in range (110 ):
365
+ for column in range (220 ):
367
366
if self .rain_drops [0 ][column ] == - 1 :
368
367
if self .drop_of_water_image_ascii [0 ][column ] == ' ' :
369
368
self .rain_drops [0 ][column ] = 0
@@ -395,37 +394,52 @@ def create_rain_drops(self, ascii_image):
395
394
self .drop_of_water_image_ascii [row - 1 ][column ] = ' '
396
395
self .rain_00ff00_image [row - 1 ][column ] = ascii_image [row - 1 ][column ]
397
396
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 ]
400
398
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 ]
403
401
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 ]
409
406
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 ]
412
408
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 ]
415
411
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 ]
418
414
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 ] = ' '
423
432
if self .rain_00bb00_image [self .len_array_height - 1 ][column ] != ' ' :
424
433
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 ] = ' '
429
443
430
444
ascii_image_result = ""
431
445
drop_of_water_image_ascii_result = ""
@@ -487,7 +501,7 @@ def create_rain_drops(self, ascii_image):
487
501
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 ):
488
502
if self .running :
489
503
width , height = 848 , 480
490
- ascii_font_size_width = 16
504
+ ascii_font_size_width = 8
491
505
wd = sys ._MEIPASS if getattr (sys , 'frozen' , False ) else ''
492
506
font_path = os .path .join (wd , '.' , 'mtx.ttf' )
493
507
font = ImageFont .truetype (font_path , ascii_font_size_width )
@@ -554,14 +568,14 @@ def __init__(self):
554
568
self .cap = None
555
569
self .timer_capture = QTimer ()
556
570
self .timer_capture .timeout .connect (self .capture_frame )
557
- self .timer_capture .start (33 )
571
+ self .timer_capture .start (100 )
558
572
559
573
self .rain_intensity = 0.5
560
574
self .image_updated = ""
561
575
562
576
width , height = 848 , 480
563
577
564
- self .ascii_font_size_width = 20
578
+ self .ascii_font_size_width = 8
565
579
self .ascii_font_size_height = self .ascii_font_size_width * 9 / 16
566
580
567
581
self .font_path = os .path .join (self .wd , 'mtx.ttf' )
@@ -572,8 +586,8 @@ def __init__(self):
572
586
self .virtual_frame = np .zeros ((480 , 640 , 3 ), dtype = np .uint8 )
573
587
574
588
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
577
591
drop_of_water_image_ascii = [[' ' for _ in range (self .len_array_width )] for _ in range (self .len_array_height )]
578
592
rain_00ff00_image = [[' ' for _ in range (self .len_array_width )] for _ in range (self .len_array_height )]
579
593
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):
694
708
self .cap .set (cv2 .CAP_PROP_FRAME_WIDTH , 848 )
695
709
self .cap .set (cv2 .CAP_PROP_FRAME_HEIGHT , 480 )
696
710
self .cap .set (cv2 .CAP_PROP_FPS , 60 )
697
- time .sleep (1 )
698
711
699
712
def stop (self ):
700
713
# print("entre dans stop()\n")
@@ -730,6 +743,7 @@ def initUI(self):
730
743
if not self .UIdefine :
731
744
# print("entre dans matrix.initUI()\n")
732
745
self .setWindowFlags (self .windowFlags () & ~ Qt .WindowType .FramelessWindowHint )
746
+ self .setStyleSheet ("background-color: black;" )
733
747
734
748
frame = QFrame (self )
735
749
frame .setFrameStyle (QFrame .Shape .NoFrame )
0 commit comments