summaryrefslogtreecommitdiffstats
path: root/tests/roi.py
blob: fad07173010c4689029b2883842109ffa38c0e25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import argparse
import PyTango
import tifffile


def grab(camera, height=3840, offset=0):
    if height < 3840:
        camera.roi_y0 = offset
        camera.roi_height = height
    else:
        camera.roi_height = height
        camera.roi_y0 = offset

    try:
        camera.Start()
    except:
        camera.Stop()
        camera.Start()

    frame = camera.image
    tifffile.imsave('frame-{}-{}.tif'.format(offset, height), frame)
    camera.Stop()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--device', '-d', type=str, required=True,
                        help="TANGO device path")

    args = parser.parse_args()

    camera = PyTango.DeviceProxy(args.device)
    camera.trigger_source = 0

    grab(camera)
    grab(camera, height=3640)
    grab(camera, height=3640, offset=200)