def _(): assert Camera.cameras == set() a = Camera(1) assert Camera.cameras == {a} Camera(1) assert Camera.cameras == {a} Camera(1, 1) assert Camera.cameras == {a} c = Camera(2) assert Camera.cameras == {a, c}
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert a._video_capture.isOpened() with a: assert a._video_capture.isOpened() assert not a._video_capture.isOpened() assert not a._video_capture.isOpened()
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert a.resolution == (640, 480) a.downscale(2) assert a.resolution == (320, 240) a.downscale(2) assert a.resolution == (160, 120) a.downscale(2) assert a.resolution == (160, 120)
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert a.width == 640
def _(): assert Camera(0).id == 0
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert type(a._video_capture) is VideoCapture and a._video_capture.isOpened()
def _(): a = Camera(GOOD_CAMERA_INDEX) with a as b: assert a is b
def _(): with raises(ConnectionError): with Camera(BAD_CAMERA_INDEX): ...
def _(): a = Camera(0) assert a._id == 0 and a._code is None and a._video_capture is None a = Camera(1, COLOR_RGB2LUV) assert a._id == 1 and a._code == COLOR_RGB2LUV and a._video_capture is None
def _(): with Camera(GOOD_CAMERA_INDEX, COLOR_RGB2GRAY) as a: assert type(a.img) == ndarray and a.img.shape == (480, 640)
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert type(a.img) == ndarray and a.img.shape == (480, 640, 4)
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert a.resolution == (640, 480)
def _(): with Camera(GOOD_CAMERA_INDEX) as a: assert a.height == 480