Exemplo n.º 1
0
    def test_convert(self):
        ic1 = ImageContainer(Image())
        ci = ConvertImage.create('ci', 'bypass')
        ic2 = ci.convert(ic1)

        nt.assert_not_equal(ic1, ic2)
        nt.assert_not_equal(ic1.c_pointer, ic2.c_pointer)
        nt.assert_equal(hex(mem_address(ic1.c_pointer)),
                        hex(mem_address(ic2.c_pointer)))
Exemplo n.º 2
0
def _convert_image_container_in(datum_ptr):
    """
    Convert datum as PyCapsule to image_container opaque handle.
    """
    _VCL = _find_converter_lib()
    # Convert from datum to opaque handle.
    func = _VCL.vital_image_container_from_datum
    func.argtypes = [ ctypes.py_object ]
    func.restype = ImageContainer.C_TYPE_PTR
    # get opaque handle from the datum
    handle = func(datum_ptr)

    # convert handle to python object
    py_ic_obj = ImageContainer.from_c_pointer( handle )

    return py_ic_obj
Exemplo n.º 3
0
    def convert(self, image_container):
        """
        :param image_container: The image container with image data to convert
        :type image_container: ImageContainer

        :return: A new ImageContainer with the converted underlying data
        :rtype: ImageContainer

        """
        ci_convert = self.VITAL_LIB.vital_algorithm_convert_image_convert
        ci_convert.argtypes = [self.C_TYPE_PTR, ImageContainer.C_TYPE_PTR,
                               VitalErrorHandle.C_TYPE_PTR]
        ci_convert.restype = ImageContainer.C_TYPE_PTR
        with VitalErrorHandle() as eh:
            return ImageContainer.from_c_pointer(
                ci_convert(self, image_container, eh)
            )
Exemplo n.º 4
0
    def load(self, filepath):
        """
        Load an image into a ImageContainer

        :param filepath: Path to the image to load
        :type filepath: str

        :return: New ImageContainer containing the loaded image
        :rtype: ImageContainer

        """
        iio_load = self.VITAL_LIB.vital_algorithm_image_io_load
        iio_load.argtypes = [self.C_TYPE_PTR, ctypes.c_char_p,
                             VitalErrorHandle.C_TYPE_PTR]
        iio_load.restype = ImageContainer.C_TYPE_PTR
        with VitalErrorHandle() as eh:
            ic_ptr = iio_load(self, filepath, eh)
        return ImageContainer.from_c_pointer(ic_ptr)
Exemplo n.º 5
0
    def convert(self, image_container):
        """
        :param image_container: The image container with image data to convert
        :type image_container: ImageContainer

        :return: A new ImageContainer with the converted underlying data
        :rtype: ImageContainer

        """
        ci_convert = self.VITAL_LIB.vital_algorithm_convert_image_convert
        ci_convert.argtypes = [
            self.C_TYPE_PTR, ImageContainer.C_TYPE_PTR,
            VitalErrorHandle.C_TYPE_PTR
        ]
        ci_convert.restype = ImageContainer.C_TYPE_PTR
        with VitalErrorHandle() as eh:
            return ImageContainer.from_c_pointer(
                ci_convert(self, image_container, eh))
Exemplo n.º 6
0
    def load(self, filepath):
        """
        Load an image into a ImageContainer

        :param filepath: Path to the image to load
        :type filepath: str

        :return: New ImageContainer containing the loaded image
        :rtype: ImageContainer

        """
        iio_load = self.VITAL_LIB.vital_algorithm_image_io_load
        iio_load.argtypes = [
            self.C_TYPE_PTR, ctypes.c_char_p, VitalErrorHandle.C_TYPE_PTR
        ]
        iio_load.restype = ImageContainer.C_TYPE_PTR
        with VitalErrorHandle() as eh:
            ic_ptr = iio_load(self, filepath, eh)
        return ImageContainer.from_c_pointer(ic_ptr)
Exemplo n.º 7
0
 def test_height(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.height(), 480)
Exemplo n.º 8
0
 def test_width(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.width(), 720)
Exemplo n.º 9
0
 def test_size(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.size(), 720 * 480)
Exemplo n.º 10
0
 def test_height(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.height(), 480)
Exemplo n.º 11
0
 def test_width(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.width(), 720)
Exemplo n.º 12
0
 def test_size(self):
     i = Image(720, 480)
     ic = ImageContainer(i)
     nose.tools.assert_equal(ic.size(), 720 * 480)
Exemplo n.º 13
0
    def test_new(self):
        image = Image()
        img_c = ImageContainer(image)

        image = Image(100, 100)
        img_c = ImageContainer(image)