コード例 #1
0
 def test_return_type(self, img, pipeline_):
     r = pipeline_.run(img)
     assert isinstance(r, tuple)
     assert len(r) == 2
     out, ctx = r
     assert is_image(out)
     assert isinstance(ctx, PipelineContext)
コード例 #2
0
def _raise_if_invalid_img(img: Image, returned_from: Optional[str] = None):
    if not utils.is_image(img):
        message = 'Invalid image'
        if returned_from is not None:
            message += f' returned from "{returned_from}"'
        message += f': {img}'
        raise BadImageError(message)
コード例 #3
0
ファイル: context.py プロジェクト: fredtcaroli/ezCV
 def __init__(self, original_img: Image):
     if not is_image(original_img):
         raise ValueError('Invalid original image')
     self.original_img = original_img.copy()
     self.original_img.flags.writeable = False
     self._scopes = list()
     self.info = dict()
コード例 #4
0
def img2QImage(img: np.ndarray) -> QImage:
    if not is_image(img):
        raise ValueError('Invalid image')

    # Using straight numpy here just so we don't have a direct dependency on opencv
    if img.ndim == 2:
        img = np.repeat(img[..., None], 3, axis=2)
    else:
        img = img[..., ::-1].copy(
        )  # QImage doesn't accept a memoryview. So we make a copy

    height, width, _ = img.shape
    bytes_per_line = 3 * width
    qimg = QImage(img.data, width, height, bytes_per_line,
                  QImage.Format_RGB888)
    return qimg
コード例 #5
0
def test_is_image_valid(img):
    assert is_image(img)
コード例 #6
0
def test_is_image_random_object():
    assert not is_image(object())
コード例 #7
0
def test_is_image_none():
    assert not is_image(None)
コード例 #8
0
def test_is_image_invalid(img):
    assert not is_image(img)