예제 #1
0
def run(fname, target, mode, sequence, alg, output, profile, backend):
    serverHost,serverPort,serversocket = socketHelper.getSocket()
    displacements = disp.DisplacementCollection()
    color = 'b'
    threadSyncer = gbl.threadSyncVariables()

    # Check if executable exists
    if not os.path.exists(fname):
        print("Error: {binary} does not exist. Can not run using the specified options.".format(binary = fname))
        exit(1)

    t = threading.Thread(target=executeApplication, args=(fname, target, mode, sequence, alg, output, profile, serverHost, serverPort, threadSyncer, backend))
    t.start()

    if backend == 'displacementSocket':
        t2 = threading.Thread(target=socketHelper.runSocketServer, args=(serversocket, displacements, threadSyncer))
        t2.start()

        threadSyncer.startExecuting = True

        pltHelper.plotReceivedPoints(displacements, 'b', threadSyncer)
        plt.close()
        plt.figure()
        pltHelper.processResults(displacements, color)

        threadSyncer.continuePlotting = False
        t2.join()
    
    t.join()
        
    processProfilingInformation(profile)

    return 0
예제 #2
0
def run(fname, target, mode, sequence, alg, output, profile, backend):
    serverHost, serverPort, serversocket = socketHelper.getSocket()
    displacements = disp.DisplacementCollection()
    color = 'b'
    threadSyncer = gbl.threadSyncVariables()

    # Check if executable exists
    if not os.path.exists(fname):
        print(
            "Error: {binary} does not exist. Can not run using the specified options."
            .format(binary=fname))
        exit(1)

    t = threading.Thread(target=executeApplication,
                         args=(fname, target, mode, sequence, alg, output,
                               profile, serverHost, serverPort, threadSyncer,
                               backend))
    t.start()

    if backend == 'displacementSocket':
        t2 = threading.Thread(target=socketHelper.runSocketServer,
                              args=(serversocket, displacements, threadSyncer))
        t2.start()

        threadSyncer.startExecuting = True

        pltHelper.plotReceivedPoints(displacements, 'b', threadSyncer)
        plt.close()
        plt.figure()
        pltHelper.processResults(displacements, color)

        threadSyncer.continuePlotting = False
        t2.join()

    t.join()

    processProfilingInformation(profile)

    return 0
예제 #3
0
def main():
    """ Entry function """
    scriptDir = os.path.dirname(os.path.realpath(__file__))
    try:
        opts, args = getopt.getopt(sys.argv[1:], "t:m:pho:s:c:l:riad:b", ["help", "output="])
    except getopt.GetoptError as err:
        # print help information and exit:
        print(str(err))
        usage()
        return 1
    target = 'native'
    mode = 'debug'
    output = "displacements.result"
    skipProcessing = False
    sequence = os.path.abspath('{scriptDir}/../testSequences/tennisball_video2/tennisball_video2_DVD.dvd'.format(scriptDir=scriptDir))
    alg = 0
    logLevel = 'debug'
    rebuild = False
    interpolate = False
    profile = 'no'
    threadmode = 'none'
    showstuff = 'no'
    for o, a in opts:
        if o == "-t":
            target = a
        elif o == "-m":
            mode = a  
        elif o in ("-h", "--help"):
            usage()
            return 0
        elif o in ("-o", "--output"):
            output = a
        elif o == "-p":
            skipProcessing = True
        elif o == "-s":
            sequence = a
        elif o == "-c":
            alg = a
        elif o == "-l":
            logLevel = a
        elif o == "-r":
            rebuild = True
        elif o == "-i":
            interpolate = True
        elif o == "-a":
            profile = 'yes'
        elif o == "-b":
            showstuff = 'yes'
        elif o == "-d":
            threadmode = a
        else:
            assert False, "unhandled option"
            usage()
            return 1

    if(rebuild):
        fname = '{scriptDir}/../build/{target}/{mode}/bin/pipeline'.format(scriptDir=scriptDir,target=target, mode=mode)
        if(os.path.isfile(fname)):
           cmd = 'rm -rf {scriptDir}/../build/{target}/{mode}'.format(scriptDir=scriptDir,target=target,mode=mode)
           os.system(cmd)
    
    serverHost,serverPort,serversocket = socketHelper.getSocket()
    displacements = disp.DisplacementCollection()
    color = 'b'
    threadSyncer = gbl.threadSyncVariables()

    # Execute
    t = threading.Thread(target=executeApplication, args=(target, mode, sequence, alg, output, logLevel, profile, threadmode, showstuff, serverHost, serverPort, threadSyncer))
    t.start()

    while(threadSyncer.doneBuilding == False):
        continue

    threadSyncer.startExecuting = True

    t2 = threading.Thread(target=socketHelper.runSocketServer, args=(serversocket, displacements, threadSyncer))
    t2.start()

    pltHelper.plotReceivedPoints(displacements, 'b', threadSyncer)
    plt.close()
    plt.figure()
    pltHelper.processResults(displacements, color, interpolate)

    return 0
예제 #4
0
def main():
    """ Entry function """
    scriptDir = os.path.dirname(os.path.realpath(__file__))
    try:
        opts, args = getopt.getopt(sys.argv[1:], "t:m:pho:s:c:l:riad:b",
                                   ["help", "output="])
    except getopt.GetoptError as err:
        # print help information and exit:
        print(str(err))
        usage()
        return 1
    target = 'rpi'
    mode = 'debug'
    output = "displacements.result"
    skipProcessing = False
    sequence = os.path.abspath(
        '{scriptDir}/../testSequences/tennisball_video2/tennisball_video2_DVD.dvd'
        .format(scriptDir=scriptDir))
    alg = 0
    logLevel = 'debug'
    rebuild = False
    interpolate = False
    profile = 'no'
    ip = '10.20.5.103'
    user = '******'
    threadMode = 'none'
    showstuff = 'no'

    for o, a in opts:
        if o == "-t":
            target = a
        elif o == "-m":
            mode = a
        elif o in ("-h", "--help"):
            usage()
            return 0
        elif o in ("-o", "--output"):
            output = a
        elif o == "-p":
            skipProcessing = True
        elif o == "-s":
            sequence = a
        elif o == "-c":
            alg = a
        elif o == "-l":
            logLevel = a
        elif o == "-r":
            rebuild = True
        elif o == "-i":
            interpolate = True
        elif o == "-a":
            profile = 'yes'
        elif o == "-d":
            threadMode = a
        elif o == "-b":
            showstuff = 'yes'
        else:
            assert False, "unhandled option"
            usage()
            return 1

    if (rebuild):
        fname = '{scriptDir}/../build/{target}/{mode}/bin/pipeline'.format(
            scriptDir=scriptDir, target=target, mode=mode)
        if (os.path.isfile(fname)):
            cmd = 'rm -rf {scriptDir}/../build/{target}/{mode}'.format(
                scriptDir=scriptDir, target=target, mode=mode)
            os.system(cmd)

    serverHost, serverPort, serversocket = socketHelper.getSocket()

    displacements = disp.DisplacementCollection()
    color = 'b'
    threadSyncer = gbl.threadSyncVariables()

    # Execute
    t = threading.Thread(target=executeApplication,
                         args=(target, mode, sequence, alg, output, logLevel,
                               profile, threadMode, showstuff, user, ip,
                               sequence, serverHost, serverPort, threadSyncer))
    t.start()

    while (threadSyncer.doneBuilding == False):
        continue

    threadSyncer.startExecuting = True

    t2 = threading.Thread(target=socketHelper.runSocketServer,
                          args=(serversocket, displacements, threadSyncer))
    t2.start()

    pltHelper.plotReceivedPoints(displacements, 'b', threadSyncer)

    plt.close()
    plt.figure()
    pltHelper.processResults(displacements, color, interpolate)

    return 0