Exemplo n.º 1
0
def main():
    print "main"
    
    #num_processorhandlers = min(1,mproc.cpu_count-1)
    num_workhandlers = 2
    
    # set up data pipes and queue
    result_queue = mproc.Queue()
    datapipes = [mproc.Pipe(False) for i in xrange(num_workhandlers)]
    
    h_input = H.InputHandler(
                [datapipes[i][1] for i in xrange(num_workhandlers)],
                [inpSFG.inpSimpleFrameGrabber()])
                 
    h_work = [H.WorkerHandler(
                    datapipes[i][0], result_queue, [wrkDev.wrkDev()])
                for i in xrange(num_workhandlers)]
                
    waittime = [0,0]
    for i, handler in enumerate(h_work):
        handler.setup(waittime[i])
                
    h_output = H.OutputHandler(result_queue, [outSD.outSimpleDisplay()])
    processes = list([h_input, h_output])
    processes.extend(h_work)
    
    # start all the processes
    [p.start() for p in processes]
    
    #h_input.start()
    #h_output.start()
    #h_work[0].start()
    
    
    # cleaning up
    h_input.join() #close the input handler
    [handler.join() for handler in h_work] #wait for the workers to finish
    h_output.join() #wait for ouput to finish writing
    result_queue.close() #close the 
    result_queue.join_thread()
import plugins.wrkNull as wrkNull
import plugins.wrkInvert as wrkInv
import plugins.wrkEdgeFit as wrkEdge

import plugins.outSimpleDisplay as outSD
import plugins.outHistogram as outHG

inp = inpSFG.inpSimpleFrameGrabber()
inp1 = inpAFG.inpAveragingFrameGrabber()

#wrk0 = wrkNull.wrkNull()
#wrk1 = wrkInv.wrkInvert()
wrk2 = wrkEdge.wrkEdgeFit()

out0 = outSD.outSimpleDisplay() #display orginal
out1 = outSD.outSimpleDisplay() # display brighened orignal with edges overlay in red
out2 = outHG.outHistogram()




inp.setup()
inp1.setup()

#wrk0.setup([0,1])
#wrk1.setup([1])
wrk2.setup([1])

out0.setup([0,1])
out1.setup([0,2])
import plugins.inpSimpleFrameGrabber as inpSFG
import plugins.wrkEdgeFit as wrkEdge
import plugins.outSimpleDisplay as outSD
import plugins.outSimpleCSVWriter as outCSV

#initalise plugins
inp = inpSFG.inpSimpleFrameGrabber()
wrk2 = wrkEdge.wrkEdgeFit()
out3 = outCSV.outSimpleCSVWriter()
outDisp = outSD.outSimpleDisplay()

# setup input data tokens for plugins
inp.setup()
wrk2.setup([1])
out3.setup([0,2])
outDisp.setup([0,1])

#configure plugins
inp.config("move.avi")
wrk2.config()
out3.config("csvfile.csv")
outIWrt.config("path/for/images")

# trian the worker with 64 images
trainimg = []
for x in range(64):
    img = inp.getFrameNr(inp.nFrames//64*x)[1]
    trainimg.append(img)
wrk2.train(trainimg)

# reset the reader
import plugins.inpAveragingFrameGrabber as inpAFG

import plugins.wrkNull as wrkNull
import plugins.wrkInvert as wrkInv
import plugins.wrkEdgeFit as wrkEdge

import plugins.outSimpleDisplay as outSD
import plugins.outHistogram as outHG

inp = inpAFG.inpAveragingFrameGrabber()

#wrk0 = wrkNull.wrkNull()
#wrk1 = wrkInv.wrkInvert()
wrk2 = wrkEdge.wrkEdgeFit()

out0 = outSD.outSimpleDisplay()




inp.setup()


#wrk0.setup([0,1])
#wrk1.setup([1])
wrk2.setup([1])

out0.setup([0,1])
#out1.setup([0,2])

import plugins.outSimpleCSVWriter as outCSV
import plugins.outSaveFrame as outFrame

inp = inpSFG.inpSimpleFrameGrabber()
#inp1 = inpAFG.inpAveragingPlayPauseFrameGrabber()

#wrk0 = wrkNull.wrkNull()
#wrk1 = wrkInv.wrkInvert()
wrk2 = wrkEdge.wrkEdgeFit()

#out0 = outSD.outSimpleDisplay() #display orginal
#out1 = outSD.outSimpleDisplay() # display brighened orignal with edges overlay in red
#out2 = outHG.outHistogram()
out3 = outCSV.outSimpleCSVWriter()
outIWrt = outFrame.outSaveFrame()
outDisp = outSD.outSimpleDisplay() #display a frame on demand... (abuse the plugin)


inp.setup()
#inp1.setup()

#wrk0.setup([0,1])
#wrk1.setup([1])
wrk2.setup([1])

#out0.setup([0,1]) #display orginal image
#out1.setup([0,2]) #display the edidet file

out3.setup([0,2])
outIWrt.setup([0,1]) #remember: this plaugin is abused and not called with the datastream
outDisp.setup([0,1]) #remember: this plaugin is abused and not called with the datastream