Example #1
0
    def test_02_02_add_two_image_providers(self):
        x = cpi.ImageSetList()
        y = x.get_image_set(0)
        img1 = cpi.Image(np.ones((10, 10)))

        def fn1(image_set, image_provider):
            self.assertEquals(
                y, image_set,
                "Callback was not called with the correct image set")
            return img1

        img2 = cpi.Image(np.ones((5, 5)))

        def fn2(image_set, image_provider):
            self.assertEquals(
                y, image_set,
                "Callback was not called with the correct image set")
            return img2

        y.providers.append(cpi.CallbackImageProvider("IP1", fn1))
        y.providers.append(cpi.CallbackImageProvider("IP2", fn2))
        self.assertEquals(img1, y.get_image("IP1"),
                          "Failed to get correct first image")
        self.assertEquals(img2, y.get_image("IP2"),
                          "Failed to get correct second image")
Example #2
0
    def test_02_01_add_image_provider(self):
        x = cpi.ImageSetList()
        y = x.get_image_set(0)
        img = cpi.Image(np.ones((10, 10)))

        def fn(image_set, image_provider):
            self.assertEquals(y, image_set, "Callback was not called with the correct image provider")
            return img

        z = cpi.CallbackImageProvider("TestImageProvider", fn)
        y.providers.append(z)
        self.assertEquals(img, y.get_image("TestImageProvider"))