Étape 6: Personnalisation de la Video.py pour capturer image et supprimer fond
Créer un fond Subtractor utilisant OpenCV :
background_subtractor = cv2. BackgroundSubtractorMOG2 (histoire = 3, varThreshold = 10, bShadowDetection = False)
Pour chaque image, appliquez-le à le subtractor fond :
background_mask = background_subtractor.apply (cadre, learningRate = 0.1)
Appliquer le masque de l’arrière-plan de l’image originale :
background_masked_image = cv2.bitwise_and (cadre, cadre, masque = background_mask)
Afficher la nouvelle image avec son arrière-plan soustrait