annotations.FaceClustering package

Submodules

annotations.FaceClustering.identifycoords module

filename

sppas.src.annotations.FaceClustering.identifycoords.py

author

Brigitte Bigi

contact

develop@sppas.org

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.

__init__()[source]

Create a new instance.

create_kids_writers_buffers(video_writer)[source]

Create as many kids writers&buffers as the number of persons.

invalidate()[source]

Invalidate the list of all known identifiers.

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

set_out_ident(value)[source]

Export a video/csv file for each identified person.

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

develop@sppas.org

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)

next()[source]

Override. Fill in the buffer with the next images & reset ids.

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

reset()[source]

Override. Reset all the info related to the buffer content.

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

set_id(buffer_index, coord_index, identifier)[source]

Set the id to coordinate of a given image index.

Parameters
  • buffer_index – (int) Index of the image in the buffer

  • coord_index – (int) Index of the coordinates for this id

  • identifier – (any) Any relevant information

set_ids(buffer_index, ids)[source]

Set the coord identifiers of a given image index.

The number of identifiers must match the number of coords.

Parameters
  • buffer_index – (int) Index of the image in the buffer

  • ids – (list of identifiers) A list of identifiers

annotations.FaceClustering.kidswriter module

filename

sppas.src.annotations.FaceClustering.kidswriter.py

author

Brigitte Bigi

contact

develop@sppas.org

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

__init__(csv_file, separator=';')[source]

Set the list of coords & ids defined in the given file.

Parameters
  • csv_file – (str) coords&identifiers from a sppasKidsVideoWriter

  • separator – (char) Columns separator in the CSV file

class annotations.FaceClustering.kidswriter.sppasKidsVideoWriter(image_writer=None)[source]

Bases: sppas.src.videodata.sppasCoordsVideoWriter

Write a video and optionally coords and ids into files.

__init__(image_writer=None)[source]

Create a new instance.

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

develop@sppas.org

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.

fix_options(options)[source]

Fix all options.

Parameters

options – (sppasOption)

static get_input_extensions()[source]

Extensions that the annotation expects for its input filename.

get_input_patterns()[source]

Patterns this annotation expects for its input filenames.

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

get_output_pattern()[source]

Pattern this annotation adds to the output filename.

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

set_out_csv(out_csv=False)[source]

The result includes a CSV file.

Parameters

out_csv – (bool) Create a CSV file when detecting

set_out_folder(out_folder=False)[source]

The result includes a folder with image files.

Parameters

out_folder – (bool) Create a folder with image files when detecting

Module contents

filename

sppas.src.annotations.FaceClustering.__init__.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Set a person identity to detected faces of a video.

This package requires video feature, for opencv and numpy dependencies.

class annotations.FaceClustering.sppasFaceIdentifier(*args, **kwargs)[source]

Bases: object

__init__(*args, **kwargs)[source]