Exemple #1
0
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}
Exemple #2
0
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()
Exemple #3
0
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)
Exemple #4
0
def _():
    with Camera(GOOD_CAMERA_INDEX) as a:
        assert a.width == 640
Exemple #5
0
def _():
    assert Camera(0).id == 0
Exemple #6
0
def _():
    with Camera(GOOD_CAMERA_INDEX) as a:
        assert type(a._video_capture) is VideoCapture and a._video_capture.isOpened()
Exemple #7
0
def _():
    a = Camera(GOOD_CAMERA_INDEX)
    with a as b:
        assert a is b
Exemple #8
0
def _():
    with raises(ConnectionError):
        with Camera(BAD_CAMERA_INDEX):
            ...
Exemple #9
0
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
Exemple #10
0
def _():
    with Camera(GOOD_CAMERA_INDEX, COLOR_RGB2GRAY) as a:
        assert type(a.img) == ndarray and a.img.shape == (480, 640)
Exemple #11
0
def _():
    with Camera(GOOD_CAMERA_INDEX) as a:
        assert type(a.img) == ndarray and a.img.shape == (480, 640, 4)
Exemple #12
0
def _():
    with Camera(GOOD_CAMERA_INDEX) as a:
        assert a.resolution == (640, 480)
Exemple #13
0
def _():
    with Camera(GOOD_CAMERA_INDEX) as a:
        assert a.height == 480