arcjetCV.utils.processor module
- class arcjetCV.utils.processor.ArcjetProcessor(videometa)[source]
Bases:
objectVideo frame processor
Primary image processing class: used to read in video data, extract leading edges, hold processed arrays, and output processed data to file.
- get_edges_metrics(contour_dict, argdict, offset)[source]
Retrieves edges and metrics from contour dictionary.
- Parameters:
contour_dict – dictionary containing contours
argdict – dictionary containing metrics
offset – tuple containing offset values
- Returns:
edges: dictionary containing edges argdict: updated dictionary containing metrics
- get_flow_direction(frame)[source]
Infers flow direction from the provided frame.
- Parameters:
frame – opencv image
- Returns flowDirection:
string, “left or “right”
TODO: add support for top/bottom directions
- get_image_flags(frame, argdict)[source]
Uses histogram of 8-bit grayscale image (0,255) to classify image type.
- Parameters:
frame – opencv image
argdict – dictionary to store flags
- Returns:
dictionary of flags
- make_crop_square(frame)[source]
Makes the provided frame square by cropping or padding.
- Parameters:
frame – opencv image
- Returns:
square_frame: square opencv image offset: list containing offset values
- process(frame, argdict)[source]
Processes the given frame.
- Parameters:
frame – opencv image
argdict – dictionary containing segmentation parameters
- Returns:
edges: dictionary containing edges argdict: updated dictionary containing metrics
Example:
`python processor = ArcjetProcessor(videometa) frame = cv.imread('frame.jpg') argdict = {"SEGMENT_METHOD": "AutoHSV", "MODEL_FRACTION": 0.005} edges, argdict = processor.process(frame, argdict) `
- process_all(video: Video, options, first_frame, last_frame, frame_stride, output_prefix='', write_json=True, write_video=False, display_shock=True)[source]
Processes all frames in the video.
- Parameters:
video – video object (defined in utils/video.py)
options – dictionary containing segmentation options
first_frame – index of the first frame to process
last_frame – index of the last frame to process
frame_stride – stride for frame processing
write_json – boolean indicating whether to write processed data to JSON file
write_video – boolean indicating whether to write processed video
Example:
`python video = Video('input_video.mp4') options = {"SEGMENT_METHOD": "AutoHSV", "MODEL_FRACTION": 0.005} processor = ArcjetProcessor(videometa) processor.process_all(video, options, 0, 100, 1, 'output.json', write_video=True) `
- segment(img_crop, argdict)[source]
Segments image using one of several methods specified in argdict.
- Parameters:
img_crop – cropped opencv image
argdict – dictionary containing segmentation method and related parameters
- Returns:
contour_dict: dictionary containing contours flags: dictionary containing flags