示例#1
0
def main(args):
    global debugSurface
    if len(args) > 1:
        camNum = int(args[1])
        print "Using cam %s" % (camNum,)
    else:
        camNum = 0
    capture, dims = initializeCapture(cam=camNum, dims=CAPSIZE00)
    changeExposure(camNum, value=100)

    sketchSurface = GTKGui(dims=GTKGUISIZE)
    sketchWindow = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
    sketchWindow.add(sketchSurface)
    sketchWindow.connect("destroy", gtk.main_quit)
    sketchWindow.show_all()
    sketchSurface.registerKeyCallback('C', lambda: displayCalibrationPattern(sketchSurface))

    calibArea = CalibrationArea(capture, dims, sketchSurface)
    calibArea.registerKeyCallback('+', lambda x: changeExposure(camNum, 100))
    calibArea.registerKeyCallback('-', lambda x: changeExposure(camNum, -100))
    calibWindow = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
    calibWindow.add(calibArea)
    calibWindow.connect("destroy", lambda x: calibWindow.destroy())
    calibWindow.show_all()

    debugSurface = DebugWindow()
    debugWindow = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
    debugWindow.add(debugSurface)
    # debugWindow.show_all()

    sketchSurface.grab_focus()
    gtk.main()
    print "gtkMain exits"
示例#2
0
 def testCaptureAndRecognize():
     """Open a GUI and perform recognition when the user hits 'p'"""
     from gtkStandalone import GTKGui
     import gtk
     def printBoardStrokes(board):
         flippedStrokes = flipStrokes(board.Strokes)
         equation = recognizeEquation(flippedStrokes)
         print "Equation: '%s'" % (equation)
         handwriting = recognizeHandwriting(flippedStrokes)
         print "Handwriting: %s" % (handwriting)
     win = gtk.Window()
     gui = GTKGui()
     gui.registerKeyCallback('p', lambda: printBoardStrokes(gui.board))
     win.add(gui)
     win.show_all()
     gtk.main()
示例#3
0
def main(args):
    dims = (2592, 1944)
    gui = GTKGui(dims = (1600, 1050))
    cam = CamArea( dims=dims)
#    diffImageArea = ImageArea()
#    lastImage = cv.CreateMat(cam.dimensions[1], cam.dimensions[0], cv.CV_8UC3)
#    cv.Set(lastImage, 0)
#    diffImageArea.setCvMat(lastImage)
    
    cam.pause()
    cam.registerKeyCallback('v', lambda : captureAndProcessImage(cam, gui) )
    cam.registerKeyCallback('P', lambda : cam.resume() )
    cam.registerKeyCallback('p', lambda : cam.pause() )
    gui.registerKeyCallback('v', lambda : captureAndProcessImage(cam, gui) )
    gui.registerKeyCallback('f', lambda : cam.pause() )
    gui.registerKeyCallback('c', lambda : displayCalibrationPattern(gui) )

    sketchWindow = gtk.Window()
    sketchWindow.add(gui)
    sketchWindow.connect("destroy", gtk.main_quit)
    sketchWindow.show_all()
    
#    diffWindow = gtk.Window()
#    diffWindow.add(diffImageArea)
#    diffWindow.connect("destroy", gtk.main_quit)
#    diffWindow.show_all()
    

    cameraWindow = gtk.Window()
    cameraWindow.add(cam)
    cameraWindow.connect("destroy", gtk.main_quit)
    cameraWindow.show_all()

    displayCalibrationPattern(gui)
    gtk.main()