예제 #1
0
    def test_set_compression_descriptor(self):
        decompressor = pylon.ImageDecompressor()
        decompressor.SetCompressionDescriptor(COMPRESSION_DESCRIPTOR_MONO8)
        self.assertTrue(decompressor.HasCompressionDescriptor())

        decompressor.ResetCompressionDescriptor()
        self.assertFalse(decompressor.HasCompressionDescriptor())
예제 #2
0
    def test_decompress_image(self):
        decompressor = pylon.ImageDecompressor()
        decompressor.SetCompressionDescriptor(COMPRESSION_DESCRIPTOR_MONO8)

        image = decompressor.DecompressImage(TEST_PAYLOAD_MONO8)

        buffer = image.GetBuffer()
        self.assertEqual(len(buffer), TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT)

        for y in range(TEST_IMAGE_HEIGHT):
            row = buffer[y * TEST_IMAGE_WIDTH:(y + 1) * TEST_IMAGE_WIDTH]
            for x, val in enumerate(row):
                self.assertEqual(val, x + y, "Mismatch in {}/{}".format(y, x))
예제 #3
0
    def test_numpy(self):
        try:
            import numpy as np
        except ImportError:
            self.skipTest("numpy is not installed")

        decompressor = pylon.ImageDecompressor()
        decompressor.SetCompressionDescriptor(COMPRESSION_DESCRIPTOR_MONO8)

        image = decompressor.DecompressImage(TEST_PAYLOAD_MONO8)

        array = image.Array
        self.assertEqual(array.shape, (image.Width, image.Height))
예제 #4
0
    def test_decompress_image(self):
        decompressor = pylon.ImageDecompressor()

        descriptor = self.camera.BslImageCompressionBCBDescriptor.GetAll()
        decompressor.SetCompressionDescriptor(descriptor)

        with self.camera.GrabOne(10000) as compressed_image:
            decompressed_image = decompressor.DecompressImage(compressed_image)
            decompressed_array = decompressed_image.Array

        assert_array_equal(self.reference_array, decompressed_array)

        self.camera.Close()
예제 #5
0
 def test_get_compression_info(self):
     decompressor = pylon.ImageDecompressor()
     info = decompressor.GetCompressionInfo(TEST_PAYLOAD_MONO8)
     self.assertEqual(info.hasCompressedImage, True)
     self.assertEqual(info.compressionStatus, pylon.CompressionStatus_Ok)
     self.assertEqual(info.lossy, False)
     self.assertEqual(info.pixelType, pylon.PixelType_Mono8)
     self.assertEqual(info.width, TEST_IMAGE_WIDTH)
     self.assertEqual(info.height, TEST_IMAGE_HEIGHT)
     self.assertEqual(info.offsetX, TEST_IMAGE_OFFSET_X)
     self.assertEqual(info.offsetY, TEST_IMAGE_OFFSET_Y)
     self.assertEqual(info.paddingX, 0)
     self.assertEqual(info.paddingY, 0)
     self.assertEqual(info.decompressedImageSize,
                      TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * 1)
     self.assertGreater(info.decompressedPayloadSize,
                        info.decompressedImageSize)
예제 #6
0
    def test_hash(self):
        decompressor = pylon.ImageDecompressor()

        # test computing hash from binary representation of descriptor
        descriptor_hash = decompressor.ComputeCompressionDescriptorHash(
            COMPRESSION_DESCRIPTOR_MONO8)
        self.assertEqual(descriptor_hash, DESCRIPTOR_HASH_MONO8)

        # test extracting hash from loaded descriptor
        decompressor.SetCompressionDescriptor(COMPRESSION_DESCRIPTOR_MONO8)
        descriptor_hash = decompressor.GetCurrentCompressionDescriptorHash()
        self.assertEqual(descriptor_hash, DESCRIPTOR_HASH_MONO8)

        decompressor.ResetCompressionDescriptor()
        self.assertRaises(genicam.RuntimeException,
                          decompressor.GetCurrentCompressionDescriptorHash)

        # test extracting hash from payload
        descriptor_hash = decompressor.GetCompressionDescriptorHash(
            TEST_PAYLOAD_MONO8)
        self.assertEqual(descriptor_hash, DESCRIPTOR_HASH_MONO8)
예제 #7
0
 def test_constructor(self):
     decompressor = pylon.ImageDecompressor()
     self.assertFalse(decompressor.HasCompressionDescriptor())