pysilcam/__main__.py
def silcam():
    '''Main entry point function to acquire/process images from the SilCam.

    Use this function in command line arguments according to the below documentation.

    Usage:
      silcam acquire <configfile> <datapath>
      silcam process <configfile> <datapath> [--nbimages=<number of images>] [--nomultiproc] [--appendstats]
      silcam realtime <configfile> <datapath> [--discwrite] [--nomultiproc] [--appendstats] [--discread]
      silcam -h | --help
      silcam --version

    Arguments:
        acquire     Acquire images
        process     Process images
        realtime    Acquire images from the camera and process them in real time

    Options:
      --nbimages=<number of images>     Number of images to process.
      --discwrite                       Write images to disc.
      --nomultiproc                     Deactivate multiprocessing.
      --appendstats                     Appends data to output STATS.csv file. If not specified, the STATS.csv file will be overwritten!
      -h --help                         Show this screen.
      --version                         Show version.
      --discread                        emergency disc read version of realtime analysis, to be run seperately but at the same time as silcam acquire

    '''
    print(title)
    print('')
    args = docopt(silcam.__doc__, version='PySilCam {0}'.format(__version__))

    overwriteSTATS = True

    if args['<datapath>']:
        # The following is solving problems in transfering arguments from shell on windows
        # Remove ' characters
        datapath = os.path.normpath(args['<datapath>'].replace("'", ""))
        # Remove " characters at the end (occurs when user give \" at the end)
        while datapath[-1] == '"':
            datapath = datapath[:-1]

    # this is the standard processing method under development now
    if args['process']:
        multiProcess = True
        if args['--nomultiproc']:
            multiProcess = False
        nbImages = args['--nbimages']
        if (nbImages != None):
            try:
                nbImages = int(nbImages)
            except ValueError:
                print('Expected type int for --nbimages.')
                sys.exit(0)
        if args['--appendstats']:
            overwriteSTATS = False  # if you want to append to the stats file, then overwriting should be False
        silcam_process(args['<configfile>'], datapath, multiProcess=multiProcess, realtime=False,
                       nbImages=nbImages, overwriteSTATS=overwriteSTATS)

    elif args['acquire']:  # this is the standard acquisition method under development now
        try:
            pid = psutil.Process(os.getpid())
            if (sys.platform == 'linux'):
                pid.nice(-20)
            else:
                pid.nice(psutil.ABOVE_NORMAL_PRIORITY_CLASS)
        except:
            print('Could not prioritise acquisition process!')
        silcam_acquire(datapath, args['<configfile>'], writeToDisk=True)

    elif args['realtime']:
        discWrite = False
        if args['--discwrite']:
            discWrite = True
        multiProcess = True
        if args['--nomultiproc']:
            multiProcess = False
        if args['--appendstats']:
            overwriteSTATS = False  # if you want to append to the stats file, then overwriting should be False
        if args['--discread']:
            os.environ['REALTIME_DISC'] = ''
            print('discWrite = False')
            discWrite = False
        silcam_process(args['<configfile>'], datapath, multiProcess=multiProcess, realtime=True,
                       discWrite=discWrite, overwriteSTATS=overwriteSTATS)
Main entry point function to acquire/process images from the SilCam.

    Use this function in command line arguments according to the below documentation.

    Usage:
      silcam acquire <configfile> <datapath>
      silcam process <configfile> <datapath> [--nbimages=<number of images>] [--nomultiproc] [--appendstats]
      silcam realtime <configfile> <datapath> [--discwrite] [--nomultiproc] [--appendstats] [--discread]
      silcam -h | --help
      silcam --version

    Arguments:
        acquire     Acquire images
        process     Process images
        realtime    Acquire images from the camera and process them in real time

    Options:
      --nbimages=<number of images>     Number of images to process.
      --discwrite                       Write images to disc.
      --nomultiproc                     Deactivate multiprocessing.
      --appendstats                     Appends data to output STATS.csv file. If not specified, the STATS.csv file will be overwritten!
      -h --help                         Show this screen.
      --version                         Show version.
      --discread                        emergency disc read version of realtime analysis, to be run seperately but at the same time as silcam acquire

    
Main entry point function to acquire/process images from the SilCam.
Use this function in command line arguments according to the below documentation.



acquire     Acquire images
process     Process images
realtime    Acquire images from the camera and process them in real time

nbimages=     Number of images to process.
discwrite                       Write images to disc.
nomultiproc                     Deactivate multiprocessing.
appendstats                     Appends data to output STATS.csv file. If not specified, the STATS.csv file will be overwritten.
h --help                         Show this screen.
version                         Show version.
discread                        emergency disc read version of realtime analysis, to be run seperately but at the same time as silcam acquire
Main entry point function to acquire / process images from the SilCam . Use this function in command line arguments according to the below documentation . acquire Acquire images process Process images realtime Acquire images from the camera and process them in real time nbimages = Number of images to process . discwrite Write images to disc . nomultiproc Deactivate multiprocessing . appendstats Appends data to output STATS . csv file . If not specified the STATS . csv file will be overwritten . h -- help Show this screen . version Show version . discread emergency disc read version of realtime analysis to be run seperately but at the same time as silcam acquire
def silcam():
    print(title)
    print('')
    args = docopt(silcam.__doc__, version='PySilCam {0}'.format(__version__))
    overwriteSTATS = True
    if args['<datapath>']:
        datapath = os.path.normpath(args['<datapath>'].replace("'", ""))
        while datapath[-1] == '"':
            datapath = datapath[:-1]
    if args['process']:
        multiProcess = True
        if args['--nomultiproc']:
            multiProcess = False
        nbImages = args['--nbimages']
        if (nbImages != None):
            try:
                nbImages = int(nbImages)
            except ValueError:
                print('Expected type int for --nbimages.')
                sys.exit(0)
        if args['--appendstats']:
            overwriteSTATS = False  
        silcam_process(args['<configfile>'], datapath, multiProcess=multiProcess, realtime=False,
                       nbImages=nbImages, overwriteSTATS=overwriteSTATS)
    elif args['acquire']:  
        try:
            pid = psutil.Process(os.getpid())
            if (sys.platform == 'linux'):
                pid.nice(-20)
            else:
                pid.nice(psutil.ABOVE_NORMAL_PRIORITY_CLASS)
        except:
            print('Could not prioritise acquisition process!')
        silcam_acquire(datapath, args['<configfile>'], writeToDisk=True)
    elif args['realtime']:
        discWrite = False
        if args['--discwrite']:
            discWrite = True
        multiProcess = True
        if args['--nomultiproc']:
            multiProcess = False
        if args['--appendstats']:
            overwriteSTATS = False  
        if args['--discread']:
            os.environ['REALTIME_DISC'] = ''
            print('discWrite = False')
            discWrite = False
        silcam_process(args['<configfile>'], datapath, multiProcess=multiProcess, realtime=True,
                       discWrite=discWrite, overwriteSTATS=overwriteSTATS)
def silcam ( ) : print ( title ) print ( '' ) args = docopt ( silcam . __doc__ , version = 'PySilCam {0}' . format ( __version__ ) ) overwriteSTATS = True if args [ '<datapath>' ] : datapath = os . path . normpath ( args [ '<datapath>' ] . replace ( "'" , "" ) ) while datapath [ - 1 ] == '"' : datapath = datapath [ : - 1 ] if args [ 'process' ] : multiProcess = True if args [ '--nomultiproc' ] : multiProcess = False nbImages = args [ '--nbimages' ] if ( nbImages != None ) : try : nbImages = int ( nbImages ) except ValueError : print ( 'Expected type int for --nbimages.' ) sys . exit ( 0 ) if args [ '--appendstats' ] : overwriteSTATS = False silcam_process ( args [ '<configfile>' ] , datapath , multiProcess = multiProcess , realtime = False , nbImages = nbImages , overwriteSTATS = overwriteSTATS ) elif args [ 'acquire' ] : try : pid = psutil . Process ( os . getpid ( ) ) if ( sys . platform == 'linux' ) : pid . nice ( - 20 ) else : pid . nice ( psutil . ABOVE_NORMAL_PRIORITY_CLASS ) except : print ( 'Could not prioritise acquisition process!' ) silcam_acquire ( datapath , args [ '<configfile>' ] , writeToDisk = True ) elif args [ 'realtime' ] : discWrite = False if args [ '--discwrite' ] : discWrite = True multiProcess = True if args [ '--nomultiproc' ] : multiProcess = False if args [ '--appendstats' ] : overwriteSTATS = False if args [ '--discread' ] : os . environ [ 'REALTIME_DISC' ] = '' print ( 'discWrite = False' ) discWrite = False silcam_process ( args [ '<configfile>' ] , datapath , multiProcess = multiProcess , realtime = True , discWrite = discWrite , overwriteSTATS = overwriteSTATS )
Main entry point function to acquire/process images from the SilCam.
Main entry point function to acquire / process images from the SilCam .
'''Main entry point function to acquire/process images from the SilCam.

    Use this function in command line arguments according to the below documentation.

    Usage:
      silcam acquire <configfile> <datapath>
      silcam process <configfile> <datapath> [--nbimages=<number of images>] [--nomultiproc] [--appendstats]
      silcam realtime <configfile> <datapath> [--discwrite] [--nomultiproc] [--appendstats] [--discread]
      silcam -h | --help
      silcam --version

    Arguments:
        acquire     Acquire images
        process     Process images
        realtime    Acquire images from the camera and process them in real time

    Options:
      --nbimages=<number of images>     Number of images to process.
      --discwrite                       Write images to disc.
      --nomultiproc                     Deactivate multiprocessing.
      --appendstats                     Appends data to output STATS.csv file. If not specified, the STATS.csv file will be overwritten!
      -h --help                         Show this screen.
      --version                         Show version.
      --discread                        emergency disc read version of realtime analysis, to be run seperately but at the same time as silcam acquire

    ''' # The following is solving problems in transfering arguments from shell on windows # Remove ' characters # Remove " characters at the end (occurs when user give \" at the end) # this is the standard processing method under development now # if you want to append to the stats file, then overwriting should be False # this is the standard acquisition method under development now # if you want to append to the stats file, then overwriting should be False