def main(argv=None):

    # declair globals
    global ser, output, curX, curY, last_dir

    # Open serial connection
    ser = serial.Serial(DEFAULT_SERIAL_PORT, 9600, timeout=1)
    last_dir = [None, None]

    # Print starting time stamp
    print time.strftime ('Start Time: %H:%M:%S')

    # Create the output image
    curX = 0
    curY = 0
    output = opencv.cvCreateImage(opencv.cvSize(DEFAULT_OUTPUT_WIDTH,DEFAULT_OUTPUT_HEIGHT), opencv.IPL_DEPTH_8U, 3)
    opencv.cvZero(output)
    opencv.cvNot(output,output)

    global window, screen
    # Initialize pygame if not already initialized
    if not pygame.display.get_init():
        pygame.init()
        window = pygame.display.set_mode((DEFAULT_OUTPUT_WIDTH,DEFAULT_OUTPUT_HEIGHT))
        pygame.display.set_caption("Etch-A-Sketch")
        screen = pygame.display.get_surface()
    
    # Draw the image
    calibrationRoutine(60)

    # Show the image
    displayImage(output)

    # Print end time stamp
    print time.strftime ('End Time: %H:%M:%S')

    # loop
    while(1):
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT or (event.type == KEYDOWN):
		exit()
def main(argv=None):
    if argv is None:
        argv = sys.argv
    if len(argv) <= 1 or argv[1] is "-":
        im = DEFAULT_INPUT_IMAGE
    else:
        im = argv[1]
    if len(argv) <= 2 or argv[2] is "-":
        psize = DEFAULT_PIXEL_SCALE
    else:
        psize = int(argv[2])
    if len(argv) <= 3 or argv[3] is "-":
        h = DEFAULT_OUTPUT_HEIGHT
    else:
        h = int(argv[3])
    if len(argv) <= 4 or argv[4] is "-":
        w = DEFAULT_OUTPUT_WIDTH
    else:
        w = int(argv[4])
    if len(argv) <= 5 or argv[5] is "-":
        serialport = DEFAULT_SERIAL_PORT
    else:
        serialport = argv[5]

    # declair globals
    global ser, output, curX, curY, last_dir

    # Open serial connection
    if serialport is not -1:
        ser = serial.Serial(serialport, 9600, timeout=1)
    else:
        ser = 0
    last_dir = [None,None]

    # Print starting time stamp
    print time.strftime ('Start Time: %H:%M:%S')

    # Load the image
    image = highgui.cvLoadImage(im)

    # Create the output image
    curX = 0
    curY = 0
    output = opencv.cvCreateImage(opencv.cvSize(w,h), opencv.IPL_DEPTH_8U, 3)
    opencv.cvZero(output)
    opencv.cvNot(output,output)
    
    # Draw the image
    drawImage(image,h,w,psize)

    # Show the image
    displayImage(output)

    # Print end time stamp
    print time.strftime ('End Time: %H:%M:%S')

    # loop
    while(1):
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT or (event.type == KEYDOWN):
		exit()