BarcodeGenerator Class¶
Barcode Generator Class
-
class
kalmus.barcodes.BarcodeGenerator.
BarcodeGenerator
(frame_type='Whole_frame', color_metric='Average', barcode_type='Color', sampled_frame_rate=1, skip_over=0, total_frames=10)[source]¶ Bases:
object
Barcode Generator Class
- Parameters
frame_type (str) -- The type of the frame sampling
color_metric (str) -- The metric of computing the frame color
barcode_type (str) -- The type of the generated barcode
sampled_frame_rate (int) -- The frame sample rate (one frame will be sampled from every sampled_frame_rate frames)
skip_over (int) -- How many frames to skip with at the beginning of the input video
total_frames (int) -- Total number of frames that will be computed (included in the barcode/sampled frames)
-
generate_barcode
(video_file_path, user_defined_letterbox=False, low_ver=- 1, high_ver=- 1, left_hor=- 1, right_hor=- 1, num_thread=None, save_frames=False, rescale_frames_factor=- 1, save_frames_rate=4)[source]¶ Generate the barcode
- Parameters
video_file_path (str) -- The path to the video file
user_defined_letterbox (bool) -- Whether use the user defined the letterbox, or use the automatically found letterbox
low_ver (int) -- The lower vertical letterbox given by user
high_ver (int) -- The higher vertical letterbox given by user
left_hor (int) -- The left horizontal letterbox given by user
right_hor (int) -- The right horizontal letterbox given by user
num_thread (int) -- Number of thread for computation. None == Single thread. num_thread > 1: multi-thread
save_frames (bool) -- Whether to save the frames during the barcode generation
save_frames_rate (float) -- The period of seconds of one frame being saved. In other words, save 1 frame every save_frame_rate seconds in the barcode generation
rescale_frames_factor (float) -- factor to rescale the input frames during the generation
-
generate_barcode_from_json
(json_file_path, barcode_type=None)[source]¶ Generate the barcode from a json file, which contain a dictionary representation of barcode object
- Parameters
json_file_path (str) -- the path to the json file
barcode_type (str) -- the type of the barcode saved in the json file
-
kalmus.barcodes.BarcodeGenerator.
build_barcode_from_json
(path_to_json, barcode_type='Color')[source]¶ Helper function that build a barcode object from the attributes stored in a json file
- Parameters
path_to_json (str) -- Path to the json file
barcode_type (str) -- Type of the barcode that stored in the json file
- Returns
The barcode built from the json file at given path
- Return type
class:kalmus.barcodes.Barcode.ColorBarcode or class:kalmus.barcodes.Barcode.BrightnessBarcode