- class frc_apriltags.USBCamera(camNum: int = 0, path: str = None, resolution: tuple = (0, 0), fps: int = 30, calibrate: bool = False, dirPath: str = '/home/robolions/Documents/2023-Jetson-Code-Test')
Bases:
objectUse this class to create a USBCamera.
- Parameters:
camNumber – The camera number.
path – It can be found on Linux by running
find /dev/v4l.resolution – The desired resolution for the camera (width, length).
fps – The desired fps for the camera.
calibrate – Should the camera be calibrated this camera.
dirPath – Should be aquired by running
Path(__file__).absolute().parent.__str__()in the script calling this method.
- calibrateCamera(dirPath: str)
Calibrates the camera and gets the calibration parameters.
- Parameters:
dirPath – The path of the directory calling this function.
- displayStream(streamType: int = 1)
Displays a flipped version of this camera’s stream.
- Parameters:
streamType – 0 for normal stream, 1 for undistorted stream.
- enableLogging()
Enables logging for this class.
- getEnd()
Gets if the program should end.
- Returns:
Should the program end?
- getMatrix()
Gets the intrinsic camera matrix.
- Returns:
The camera’s intrinsic matrix.
- getResolution()
Gets the camera’s true resolution.
- Returns:
The camera resolution.
- getStream()
Gets the stream from this camera’s capture.
- Returns:
The stream.
- getUndistortedStream(algorithm: int = 1)
Gets the undistorted stream from this camera’s capture.
- Parameters:
algorithm – 0 to use
cv.undistort(), 1 to usecv.remap()- Returns:
The undistorted stream.
- prealocateSpace()
Prealocates space for the stream.
- Returns:
An array of zeros with the same resolution as the camera.
- rectify()
Undistorts an image using cv.remap().
- Returns:
The undistorted stream.
- resize(cameraRes: tuple, fps: int)
Resizes the capture to a given resolution. If the specified resolution or fps is too high, sets to the highest value possible.
- Parameters:
cameraRes – The desired resolution for the camera.
fps – The desired FPS for the camera.
- Returns:
The resized capture.
- undistort()
Undistorts an image using cv.undistort().
- Returns:
The undistorted stream.