Ejemplo n.º 1
0
def main():
    import sys
    import imstream
    filename = 'test.jpg'
    runLong = False
    if len(sys.argv) > 1:
        filename = sys.argv[1]
        if len(sys.argv) > 2 and sys.argv[2] == 'r':
            runLong = True
    state = {k:v for k,v in defaultState.iteritems()}
    def printShit(s,x,gui = True):
        notes,img = processImage(x,s,[lambda s,x: initState(s,x,gui)])
        # print notes
        # print list(notes)
        print '['
        first = True
        for n in notes:
            if not first:
                print ','
            else:
                first = False
            print json.dumps(n),
        print
        print ']'
        return img

    wholeProcess = lambda s,x: processImage(x,s,[initState])[1]

    if runLong:
        imstream.runStream(lambda x: swallow(wholeProcess)(state,x),
                            winName=winName,
                        filename=filename,printTime=True)
    else:
        img = cv2.imread(filename)
        def runOnce(s,x):
            s['pipelineLen'] = len(process) + 1
            return printShit(s,x,gui=False)
        swallow(runOnce)(state,img)
Ejemplo n.º 2
0

def parseWhiteboard(filename):
    return extractStructure(cv2.imread(filename))


def swallow(f):
    def fn(x):
        try:
            return f(x)
        except:
            import traceback
            print(sys.exc_info()[0])
            traceback.print_tb(sys.exc_info()[2])
            return x

    return fn


if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        print(repr([parseWhiteboard(f) for f in sys.argv[1:]]))
    else:
        import imstream
        pipe = globPipeline(wholeProcess + [printHierarchy, drawHierarchy])
        imstream.runStream(swallow(pipe),
                           winName=winName,
                           init=initGui,
                           filename='IMG_2.jpg')
Ejemplo n.º 3
0
                # drawContours]
                buildHierarchy] 

def extractStructure(img):
    return pipeline(wholeProcess)(img)[1][2]

def parseWhiteboard(filename):
    return extractStructure(cv2.imread(filename))

def swallow(f):
    def fn(x):
        try: 
            return f(x)
        except:
            import traceback
            print (sys.exc_info()[0])
            traceback.print_tb(sys.exc_info()[2])
            return x
    return fn

if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        print (repr([parseWhiteboard(f) for f in sys.argv[1:]]))
    else:
        import imstream
        pipe = globPipeline(wholeProcess + [printHierarchy,drawHierarchy])
        imstream.runStream(swallow(pipe), winName=winName,
                           init=initGui,filename='IMG_2.jpg')

Ejemplo n.º 4
0
import cv2
import numpy as np

def gaussian(img):
    return cv2.GaussianBlur(img, (51,51), 50)

if __name__ == '__main__':
    import imstream
    imstream.runStream(gaussian)