ovl.camera.camera module

class ovl.camera.camera.Camera(source: Union[str, int, cv2.VideoCapture] = 0, image_width: int = 320, image_height: int = 240, start_immediately=True)[source]

Bases: object

camera_thread
frame
get(property_id) → Any[source]

Retrieves the value of a property based on its id

Parameters:property_id – the property number, for more information: https://docs.opencv.org/3.1.0/d8/dfe/classcv_1_1VideoCapture.html
Returns:the value of the property
get_backend_name() → str[source]

Gets the backend name of the camera using cv2.VideoCapture.getBackendName()

Returns:returns the backend name of a camera
get_image() → numpy.ndarray[source]

Returns the current image

Returns:numpy array of the image
grabbed
is_opened() → bool[source]

Returns true_shape if the camera is opened, false otherwise

Returns:if the camera is open
read() → [<class 'bool'>, <class 'numpy.ndarray'>][source]

Returns the return value (if getting the frame was successful and the frame itself

This function is mainly for compatibility with cv2.VideoCapture, Camera.get_image() is recommended for common use.

Returns:if the image was taken successfully, the image
Return type:bool, numpy.array
release() → None[source]

Stops the camera thread and releases the camera

Returns:None
set(property_id: int, value: Union[float, bool, str, Any]) → None[source]

Sets the value of the given property to the given value

Properties are characteristics of the camera that can be changed to alter how images are returns, things from image width and height, contrast and saturation exposure etc.

Not all cameras support all property changes, make sure the one you are using does.

Read more at: https://docs.opencv.org/3.1.0/d8/dfe/classcv_1_1VideoCapture.html#aeb1644641842e6b104f244f049648f94

import cv2 and use cv2.CAP_PROP_<PROPERTY NAME> or simply use the property id number (number depends on the property’s location f.e CAP_PROP_FRAME_WIDTH is 3

Parameters:
  • property_id – the property id (number)
  • value – the value to be set, a number
Returns:

None

set_exposure(exposure_value: float) → bool[source]

Sets the exposure for the camera. Value range depend on the camera some use the value as the exponential negative values or actual number of ms

Parameters:exposure_value – the exposure value to be set
Returns:if it was successful in setting the value
start() → ovl.camera.camera.Camera[source]

Starts the image taking thread

Returns:self
start_immediately
stop() → None[source]

Stops the camera thread.

stopped
stream