module art.videodl
¶
Short summary¶
module code_beatrix.art.videodl
Fonctions proposant de traiter des vidéos avec des traitements compliqués type deep learning.
Functions¶
function |
truncated documentation |
---|---|
Applies one complex process to a video such as extracting characters from videos and removing the backaground. It … |
|
Blurs people faces. Uses function detectmultiscale. … |
|
Extracts characters from a movie. The movie is composed with an image and a mask. … |
Documentation¶
Fonctions proposant de traiter des vidéos avec des traitements compliqués type deep learning.
- code_beatrix.art.videodl.video_map_images(video_or_file, name, fLOG=None, **kwargs)¶
Applies one complex process to a video such as extracting characters from videos and removing the backaground. It is done image by image. Applique un traitement compliqué sur une séquence d’images telle que la séparation des personnages et du fond.
- Paramètres:
video_or_file – string or VideoClip
name – name of the processing to do, see the list below
fLOG – logging function
kwargs – additional parameters
- Renvoie:
List of available treatments:
'people'
: extracts characters from a movie. The movie is composed with an image and a mask. Parameters: see @fn video_map_images_people.'detect'
: blurs or put a rectangle around faces, uses opencv
Avertissement
A couple of errors timeout, out of memory… The following processes might be quite time consuming or memory consuming. If it is the case, you should think of reducing the resolution, the number of frames per seconds (fps). You can also split the video and process each piece independently and finally concatenate them.
- code_beatrix.art.videodl.video_map_images_detect(video_or_file, fps=None, with_times=False, logger=None, dtype=None, scaleFactor=1.3, minNeighbors=4, minSize=(30, 30), action='blur', color=(255, 255, 0), haar=None, fLOG=None)¶
Blurs people faces. Uses function detectmultiscale. Relies on opencv. Floute les visages.
- Paramètres:
video_or_file – string or VideoClip
fps – see
video_enumerate_frames
, faces are detected in each frame returned byvideo_enumerate_frames
with_times – see
video_enumerate_frames
logger – see
video_enumerate_frames
dtype – see
video_enumerate_frames
fLOG – logging function
scaleFactor –
see detectmultiscale
minNeighbors –
see detectmultiscale
minSize –
see detectmultiscale
haar – shape classifier to load, face by default, see below
action – to blur, to put a rectangle around the detected zone… see below
color – rectangle color if action is
'rect'
- Renvoie:
Only
haarcascade_frontalface_alt.xml
is provided but you can get more at haarcascades.Parameter action can be:
'blur'
: to blur faces (or detector zones)'rect'
: to draw a rectangle around faces (or detector zones)
Faces in a yellow box in a video
The following example uses opencv to detect faces on each image of a video and put a yellow box around each of them.
from code_beatrix.art.videodl import video_map_images from code_beatrix.art.video import video_save, video_extract_video vide = video_extract_video(vid, 0, 5 if __name__ == "__main__" else 1) vid2 = video_map_images( vide, fps=10, name='detect', action='rect', logger='bar', fLOG=fLOG) exp = os.path.join(temp, "people.mp4") video_save(vid2, exp, fps=10)
The following video is taken from Charlie Chaplin’s movies.
unable to find 'face.mp4'
- code_beatrix.art.videodl.video_map_images_people(video_or_file, resize=('max2', 400), fps=None, with_times=False, logger=None, dtype=None, class_to_keep=15, fLOG=None, **kwargs)¶
Extracts characters from a movie. The movie is composed with an image and a mask. Extrait les personnages d’un film, le résultat est composé d’une image et d’un masque transparent qui laissera apparaître l’image d’en dessous si cette vidéo est aposée sur une autre.
- Paramètres:
video_or_file – string or VideoClip
resize – see
predict
fps – see
video_enumerate_frames
with_times – see
video_enumerate_frames
logger – see
video_enumerate_frames
dtype – see
video_enumerate_frames
class_to_keep – class to keep from the image, it can a number (15 for the background, a list of classes, a function which takes an image and the prediction and returns an image)
fLOG – logging function
kwargs – see
DLImageSegmentation
- Renvoie:
Avertissement
A couple of errors timeout, out of memory… The following processes might be quite time consuming or memory consuming. If it is the case, you should think of reducing the resolution, the number of frames per seconds (fps). You can also split the video and process each piece independently and finally concatenate them.
Extract characters from a video.
The following example shows how to extract a movie with people and without the background. It works better if the contrast between the characters and the background is high.
from code_beatrix.art.video import video_extract_video, video_save from code_beatrix.art.videodl import video_map_images vide = video_extract_video("something.mp4", 0, 5) vid2 = video_map_images(vide, fps=10, name="people", logger='bar') video_save(vid2, "people.mp4")
The function returns something like the the following. The character is wearing black and the background is quite dark too. That explains that the kind of large halo around the character.
unable to find 'videodl.mp4'