annotations.FaceClustering package¶
Submodules¶
annotations.FaceClustering.identifycoords module¶
- filename
sppas.src.annotations.FaceClustering.identifycoords.py
- author
Brigitte Bigi
- contact
- summary
Cluster and identify the sets of coords of a video.
- class annotations.FaceClustering.identifycoords.VideoCoordsIdentification[source]¶
Bases:
object
Set an identity to the coordinates detected in a video.
- create_kids_writers_buffers(video_writer)[source]¶
Create as many kids writers&buffers as the number of persons.
- set_ident_min_confidence(value)[source]¶
Fix the minimum confidence score to propose a coord as candidate.
- Parameters
value – (float) threshold for the confidence score of coords
- video_identity(video, csv_coords, video_writer=None, output=None, pattern='-ident')[source]¶
Browse the video, get coords then cluster, identify and write results.
- Parameters
video – (str) Video filename
csv_coords – (str) Filename with the coords
video_writer – (sppasKidsVideoWriter)
output – (str) The output name for the folder
pattern – (str) Optional output pattern
- Returns
(list)
annotations.FaceClustering.kidsbuffer module¶
- filename
sppas.src.annotations.FaceClustering.kidsbuffer.py
- author
Brigitte Bigi
- contact
- summary
Video buffer with coords and known identifiers.
- class annotations.FaceClustering.kidsbuffer.sppasKidsVideoBuffer(video=None, size=- 1)[source]¶
Bases:
sppas.src.videodata.sppasCoordsVideoBuffer
A video buffer with both a list of coordinates and their identifiers.
- __init__(video=None, size=- 1)[source]¶
Create a new instance.
- Parameters
video – (str) The video filename
size – (int) Number of images of the buffer or -1 for auto
- append_coordinate(buffer_index, coord)[source]¶
Override. Append the coordinates to a given image index.
- Parameters
buffer_index – (int) Index of the image in the buffer
coord – (sppasCoords) Append the given coord
- Returns
(int) Index of the new coordinate
- get_id(buffer_index, coord_index)[source]¶
Return the identifier of a coord of a given image.
- Parameters
buffer_index – (int) Index of the image in the buffer
coord_index – (int) Index of the coords
- Returns
(Sights)
- get_id_coordinate(buffer_index, identifier)[source]¶
Return the coordinate of a given identifier in a given image.
- Parameters
buffer_index – (int) Index of the image in the buffer
identifier – (int) Identifier to search
- Returns
(sppasCoords) Coordinates or None
- get_ids(buffer_index=None)[source]¶
Return the identifiers of all detected coords of a given image.
- Parameters
buffer_index – (int) Index of the image in the buffer
- Returns
(list of identifiers)
- pop_coordinate(buffer_index, coord_index)[source]¶
Override. Remove the coordinates to a given image index.
Override to pop the identifier too.
- Parameters
buffer_index – (int) Index of the image in the buffer
coord_index – (int) Pop the given coord
- remove_coordinate(buffer_index, coord)[source]¶
Override. Remove the coordinates to a given image index.
Override to remove the identifier too.
- Parameters
buffer_index – (int) Index of the image in the buffer
coord – (sppasCoords) Remove the given coord
- set_coordinates(buffer_index, coords)[source]¶
Set the coordinates to a given image index.
Override to invalidate the corresponding identifiers.
- Parameters
buffer_index – (int) Index of the image in the buffer
coords – (list of sppasCoords) Set the list of coords
annotations.FaceClustering.kidswriter module¶
- filename
sppas.src.annotations.FaceClustering.kidswriter.py
- author
Brigitte Bigi
- contact
- summary
Write coords and identifiers.
- class annotations.FaceClustering.kidswriter.sppasKidsVideoReader(csv_file, separator=';')[source]¶
Bases:
object
Read&create list of coords and ids from a CSV file.
The CSV file must have the following columns:
frame number
identifier
timestamp
confidence
success
buffer number
index in the buffer
x, y, w, h
- class annotations.FaceClustering.kidswriter.sppasKidsVideoWriter(image_writer=None)[source]¶
Bases:
sppas.src.videodata.sppasCoordsVideoWriter
Write a video and optionally coords and ids into files.
- write_coords(fd, video_buffer, buffer_idx, idx)[source]¶
Override to write the coords AND ids into the stream.
frame number
the identifier
timestamp
confidence
success
buffer number
index in the buffer
x, y, w, h,
- Parameters
fd – (Stream) File descriptor, String descriptor, stdout, etc
video_buffer – (sppasCoordsVideoBuffer)
buffer_idx – (int) Buffer number
idx – (int) An integer to write
- write_video(video_buffer, out_name, pattern)[source]¶
Save the result in video format.
- Parameters
video_buffer – (sppasImage) The image to write
out_name – (str) The filename of the output video file
pattern – (str) Pattern to add to cropped video filename(s)
- Returns
list of newly created video file names
annotations.FaceClustering.sppasfaceid module¶
- filename
sppas.src.annotations.FaceClustering.sppasfaceid.py
- author
Brigitte Bigi
- contact
- summary
SPPAS integration of FaceClustering automatic annotation
- class annotations.FaceClustering.sppasfaceid.sppasFaceIdentifier(log=None)[source]¶
Bases:
annotations.baseannot.sppasBaseAnnotation
SPPAS integration of the automatic video coordinates identification.
Requires both an image/video and a CSV file with face coordinates.
- __init__(log=None)[source]¶
Create a new sppasFaceIdentifier instance.
- Parameters
log – (sppasLog) Human-readable logs.
- static get_input_extensions()[source]¶
Extensions that the annotation expects for its input filename.
- get_inputs(input_files)[source]¶
Return the media and the csv filenames.
- Parameters
input_files – (list)
- Raise
NoInputError
- Returns
(str, str) Names of the 2 expected files
- run(input_files, output=None)[source]¶
Run the automatic annotation process on an input.
- Parameters
input_files – (list of str) (video ) Video file, CSV file with coords of faces
output – (str) the output base name for files
- Returns
(list) Either the list of list of detected faces or the list
of all created files.
- set_fd_threshold(value)[source]¶
Threshold to FD confidence to assign a person to a face.
- Parameters
value – (float) fd score
- set_ident_export(value)[source]¶
Set the export of a video/csv file for each identified person.
- Parameters
value – (bool) True to export video/csv files
- set_img_crop(value=True)[source]¶
Create an image/video for each detected person.
- Parameters
value – (bool) Crop the images
- set_img_height(value)[source]¶
Height of the resulting images/video.
- Parameters
value – (int) Number of pixel
- set_img_tag(value=True)[source]¶
Surround the faces with a square.
- Parameters
value – (bool) Tag the images
- set_img_width(value)[source]¶
Width of the resulting images/video.
- Parameters
value – (int) Number of pixels
Module contents¶
- filename
sppas.src.annotations.FaceClustering.__init__.py
- author
Brigitte Bigi
- contact
- summary
Set a person identity to detected faces of a video.
This package requires video feature, for opencv and numpy dependencies.