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