CameraCapture

class imagepypelines.core.io.CameraCapture(cam=0, fourcc='MJPG')[source]

Bases: object

object used to talk to pull imagery from UVC camera (webcam)

Parameters:
  • cam (str,int) – the file path to the camera, or alternatively the camera’s numerical device id (on linux, this number is at the end of the camera’s file path eg: “/dev/video0”)
  • fourcc (str) – the codec used to encode images off the camera. Many UVC camera device achieve highest frame rates with MJPG
cap

the cv2 camera object

Type:cv2.VideoCapture
fourcc

the fourcc codec used for this camera

Type:str
frame_number

the number of frame retrieval attempts

Type:int

Methods Summary

change_setting(setting, value) changes a setting on the capture object acceptable
close()
metadata() grabs all metadata from the frame using the metadata properties and outputs it in an easy to use dictionary.
open()
retrieve() reads an image from the capture stream, returns a static debug frame if it fails to read the frame

Methods Documentation

change_setting(setting, value)[source]

changes a setting on the capture object acceptable

Parameters:
  • setting (str) – The setting to modify. Must be one of [width,height,fps,contrast,brightness,hue,gain, exposure,writer_dims,fourcc,fourcc_val, capture_time,frame_number]
  • value (variable) – The value to switch the setting to
Returns:

None

close()[source]
metadata()[source]

grabs all metadata from the frame using the metadata properties and outputs it in an easy to use dictionary. also adds key “capture_time”, which is the time.time() at the time the metadata is collected WARNING - what metadata is available is dependent on what camera is attached!

Parameters:None
Returns:dictionary containing all metadata values
Return type:dict
open()[source]
retrieve()[source]

reads an image from the capture stream, returns a static debug frame if it fails to read the frame

Parameters:None
Returns:image frame from the Capture Stream
Return type:np.ndarray