Exemplo n.º 1
0
def main():
    import argparse

    parser = argparse.ArgumentParser(description='Apply image correction')
    #parser.add_argument('--images', type=int, default=0, help='Only take first n images, for debugging')
    parser.add_argument('--cal-dir', default='', help='')
    parser.add_argument('--hist-eq-roi',
                        default=None,
                        help='hist eq x1,y1,x2,y2')
    add_bool_arg(parser, "--hist-eq", default=True)
    add_bool_arg(parser, "--invert", default=True)
    add_bool_arg(parser, "--rescale", default=True)
    add_bool_arg(parser, "--bpr", default=True)
    add_bool_arg(parser, "--raw", default=False)
    parser.add_argument('--scalar', default=None, type=float, help='')
    parser.add_argument('dir_in', help='')
    parser.add_argument('fn_out', default=None, nargs='?', help='')
    args = parser.parse_args()

    run(args.dir_in,
        args.fn_out,
        cal_dir=args.cal_dir,
        hist_eq=args.hist_eq,
        invert=args.invert,
        hist_eq_roi=im_util.parse_roi(args.hist_eq_roi),
        scalar=args.scalar,
        rescale=args.rescale,
        bpr=args.bpr,
        raw=args.raw)

    print("done")
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(description='Replay captured USB packets')
    parser.add_argument('--verbose', '-v', action='store_true', help='verbose')
    parser.add_argument('--dir', default='', help='Output dir')
    parser.add_argument('--postfix',
                        default='',
                        help='Default output dir postfix')
    parser.add_argument('--force',
                        '-f',
                        action='store_true',
                        help='Force trigger')
    parser.add_argument('--number',
                        '-n',
                        type=int,
                        default=1,
                        help='number to take')
    # Most users should not touch these
    parser.add_argument('--int-t',
                        type=int,
                        default=None,
                        help='Integration time in ms (default: 700)')
    parser.add_argument('--ctr-thresh',
                        type=int,
                        default=None,
                        help='Advanced')
    parser.add_argument('--bin-thresh',
                        type=int,
                        default=None,
                        help='Advanced')
    parser.add_argument('--cap-mode',
                        default=None,
                        help='Advanced: norm (default), hblock, vblock, vbar')
    parser.add_argument('--bin',
                        '-b',
                        action='store_true',
                        help='Write .bin raw data capture')
    util.add_bool_arg(parser,
                      '--png',
                      default=True,
                      help='Write normal .png image file')

    args = parser.parse_args()

    run(outdir=args.dir,
        postfix=args.postfix,
        imgn=args.number,
        force_trig=args.force,
        cap_mode=args.cap_mode,
        int_t=args.int_t,
        ctr_thresh=args.ctr_thresh,
        bin_thresh=args.bin_thresh)
Exemplo n.º 3
0
#!/usr/bin/env python3
from __future__ import print_function
from gxs700 import util
from gxs700 import usbint

import argparse
import binascii
import os

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Dump device data')
    parser.add_argument('--verbose', '-v', action='store_true', help='verbose')
    util.add_bool_arg(
        parser, '--eeprom', default=False, help='Dump only EEPROM')
    util.add_bool_arg(parser, '--flash', default=False, help='Dump only flash')
    util.add_bool_arg(
        parser,
        '--hexdump',
        default=False,
        help='Instead of writing out, just hexdump')
    parser.add_argument('dout', nargs='?', default=None, help='File out')
    args = parser.parse_args()

    gxs = usbint.GXS700()

    sn_flash = usbint.sn_flash_r(gxs)
    try:
        sn_eeprom = usbint.sn_eeprom_r(gxs)
    except:
        sn_eeprom = None
    print('S/N (flash): %s' % sn_flash)
Exemplo n.º 4
0
import gxs700.util
from uvscada import util

import argparse
import os

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Dump device data')
    parser.add_argument('--verbose', '-v', action='store_true', help='verbose')
    util.add_bool_arg(parser, '--quick', default=True, help='')
    util.add_bool_arg(parser, '--eeprom', default=False, help='')
    util.add_bool_arg(parser, '--flash', default=False, help='')
    parser.add_argument('din', nargs='?', default='dump', help='File in')
    args = parser.parse_args()

    usbcontext, dev, gxs = gxs700.usbint.ez_open_ex()

    print 'Ready'

    if args.eeprom:
        print
        print 'Writing EEPROM'
        eeprom_w = open(os.path.join(args.din, 'eeprom.bin'), 'r').read()
        if args.quick:
            eeprom_w = eeprom_w[0:0x400]
        gxs.eeprom_w(0x0000, eeprom_w)

        print 'Reading back to verify'
        eeprom_r = gxs.eeprom_r()
        if eeprom_w != eeprom_r:
            raise Exception("Failed to update EEPROM")
Exemplo n.º 5
0
def main():
    import argparse

    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--verbose', action="store_true")
    add_bool_arg(parser, "--xray", default=None)
    add_bool_arg(parser, "--force-trig", default=None)
    parser.add_argument('--dir', default=None, help='Output dir')
    parser.add_argument('--cap-mode',
                        default=None,
                        help='Advanced: norm (default), hblock, vblock, vbar')
    parser.add_argument('--int-t',
                        type=int,
                        default=None,
                        help='Integration time in ms (default: 700)')
    parser.add_argument('-n', default=1, type=int, help='Number images')
    parser.add_argument('--postfix', default=None, help='')
    parser.add_argument('--cal-dir', default=None, help='')
    parser.add_argument('--hist-eq-roi',
                        default="258,258,516,516",
                        help='hist eq x1,y1,x2,y2')
    add_bool_arg(parser, "--hist-eq", default=True)
    add_bool_arg(parser, "--raw", default=False)
    parser.add_argument('fn_out', default=None, nargs='?', help='')
    args = parser.parse_args()

    outdir = args.dir
    if outdir is None:
        outdir = default_date_dir("out", "", args.postfix)

    xray = args.xray
    if xray is None:
        xray = os.getenv('WPS7_HOST', None) is not None
    # Never create x-ray if forcing trigger
    if xray and not args.force_trig:
        print("Opening x-ray")
        xr = WPS7XRay(verbose=args.verbose)
        util.mkdir_p(outdir)
        xr.write_json(outdir)
        xr.warm()
    else:
        xr = None

    try:
        force_trig = args.force_trig
        # Force a capture by default if not given
        if force_trig is None:
            force_trig = xr is None
        raw_main.run(outdir=outdir,
                     postfix=args.postfix,
                     cap_mode=args.cap_mode,
                     imgn=args.n,
                     int_t=args.int_t,
                     force_trig=force_trig,
                     xr=xr)
    # notably ^C can cause this
    finally:
        xr and xr.beam_off()

    process_main.run(outdir,
                     args.fn_out,
                     cal_dir=args.cal_dir,
                     hist_eq=args.hist_eq,
                     raw=args.raw,
                     hist_eq_roi=im_util.parse_roi(args.hist_eq_roi))

    print("done")