Exemplo n.º 1
0
def imread(file):
    x = int(file[0])
    y = int(file[1])
    im = cv2.imread(dir + file, cv2.IMREAD_COLOR)
    h, w = im.shape[:2]
    rect = Rectangle(Vector(0, 0), 0, 1., h / w)
    return Image(rect, im)
Exemplo n.º 2
0
    def capture(self, x, y):
        """capture an image and apply our calibration parameters to (un)distort it"""

        im = self.backend.get(x, y, *self.shape)
        if self.calibration is not None:
            _, mat, coe, *_ = self.calibration
            im = cv2.undistort(im, mat, coe)
        return Image(
            Rectangle(Vector(0, 0),
                      Vector(1, 0).rotate(self.orientation()), *self.shape),
            im)
Exemplo n.º 3
0
import cv2
import os

imshow = lambda im: Image(None, im).show()

dir = "./var/stitch/tile%s/" % input("Which? ")
files = os.listdir(dir)
w = max(int(file[0]) for file in files) + 1
h = max(int(file[1]) for file in files) + 1
print(h, w)
ims = np.empty((w, h), object)
for file in files:
    x = int(file[0])
    y = int(file[1])
    im = cv2.imread(dir + file, cv2.IMREAD_COLOR)
    h, w = im.shape[:2]
    rect = Rectangle(Vector(0, 0), 0, 1., h / w)
    ims[x, y] = Image(rect, im)

print(ims)
ctx = StitchContext()
ctx.features.histeq_clr()
stitcher = TileStitcher(ctx, ims)
im = stitcher.assemble()

h, w = im.shape[:2]
im2 = cv2.resize(im, (800, int(800 * h / w)))
imshow(im2)
save = lambda fn: cv2.imwrite(fn, im)
os._exit(0)
Exemplo n.º 4
0
    ws = Workspace(virtual)

    # test queuing
    ws.optimise_queue(True)
    ws.pause()
    imcb = lambda im:im.show()
    ws.enqueue(σ, [Vector(0,0)], lambda _:print(0), {}, {})
    ws.enqueue(μ, [Vector(0.1065,0.1432)], lambda _:print(1), {'a':1}, {})
    ws.enqueue(μ, [Vector(0.2789,0.2809)], lambda _:print(2), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.1012,0.2544)], lambda _:print(3), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.1065,0.1432)], lambda _:print(4), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.2789,0.2809)], lambda _:print(5), {'a':1}, {})
    ws.enqueue(μ, [Vector(0.1012,0.2544)], lambda _:print(6), {'a':1}, {})
    ws.play()

    # test canvas
    μ.calibrate()
    ws.optimise_queue(False)
    poly = Rectangle(Vector(0.05,0.05), Vector(0,1), 0.15, 0.1)
    canvas = Canvas(ws, {'a':1}, poly, 5e-6, 900, 100)
    canvas.wait(False)
    ws.optimise_queue(True)

    # print images
    print()
    for x,r,im in canvas.images:
        print("Image %r at %r:" % (x,r))
        im.show()


Exemplo n.º 5
0
 def bounds(self):
     """return the bounding rectangle, only xy"""
     (_, _, xm), (_, _, ym), _ = self._bounds
     return Rectangle(Vector(0, 0), Vector(1, 0), xm, ym)
Exemplo n.º 6
0
 def bounds(self):
     # origin, x-axis unit vector, width, height
     return Rectangle(Vector(0, 0), Vector(1, 0), *self.dims)