def _get_biggest_framediff_square(result_queue, capture, framenum): imgarray = videocapture.get_framediff_imgarray(capture, framenum - 2, framenum) biggest = square.get_biggest_square([255, 0, 0], imgarray, x_tolerance_min=100, x_tolerance_max=100, handle_multiple_scanlines=True) if biggest: result_queue.put(biggest)
def main(args=sys.argv[1:]): usage = "usage: %prog [options] <app name>" parser = eideticker.CaptureOptionParser( usage=usage, capture_area_option=False) parser.add_option("--no-capture", action="store_false", dest="capture", default=True, help="run through the test, but don't actually " "capture anything") parser.add_option("--capture-file", action="store", type="string", dest="capture_filename", help="Existing capture to analyze instead of running " "test") parser.add_option("--app-name", action="store", type="string", dest="appname", default="org.mozilla.fennec", help="Specify an application name (android only)") parser.add_option("--output-file", action="store", type="string", dest="output_file", help="Output the results to file") parser.add_option("--output-screenshot", action="store", type="string", dest="output_screenshot", help="Output screenshot of a capture frame with capture " "area overlayed") options, args = parser.parse_args() capture_filename = options.capture_filename if not capture_filename: if options.capture: capture_filename = os.path.join(CAPTURE_DIR, "capture-test-%s.zip" % time.time()) print "Capturing to file %s" % capture_filename run_capture(options, capture_filename) if not options.capture: # we were just doing a test run through the steps here, we're done return print "Processing capture..." capture = videocapture.Capture(capture_filename) # create a difference. threshold differences above 32 to 255, then # run our existing algorithm on it framediff = capture.get_frame(0) - capture.get_frame(capture.num_frames-1) for y,row in enumerate(framediff): for x,px in enumerate(row): if px[0] > 32 or px[1] > 32 or px[2] > 32: framediff[y][x] = [255.0,255.0,255.0] largest_square = square.get_biggest_square([255,255,255], framediff, x_tolerance_min=100, x_tolerance_max=100, handle_multiple_scanlines=True) if largest_square is not None: print "Capture area: %s" % largest_square if options.output_file: with open(options.output_file, 'w+') as f: f.write('CAPTURE_AREA=%s\n' % largest_square) if options.output_screenshot: im = capture.get_frame_image(int(capture.length / 2)) draw = ImageDraw.Draw(im) draw.rectangle(largest_square, outline=(255, 0, 0)) im.save(options.output_screenshot) else: print "Couldn't find capture area" sys.exit(1)
def main(args=sys.argv[1:]): usage = "usage: %prog [options] <app name>" parser = eideticker.CaptureOptionParser(usage=usage, capture_area_option=False) parser.add_option("--no-capture", action="store_false", dest="capture", default=True, help="run through the test, but don't actually " "capture anything") parser.add_option("--capture-file", action="store", type="string", dest="capture_file", help="Existing capture to analyze instead of running " "test") parser.add_option("--app-name", action="store", type="string", dest="appname", default="org.mozilla.fennec", help="Specify an application name (android only)") parser.add_option("--output-file", action="store", type="string", dest="output_file", help="Output the results to file") parser.add_option("--output-screenshot", action="store", type="string", dest="output_screenshot", help="Output screenshot of a capture frame with capture " "area overlayed") options, args = parser.parse_args() capture_file = options.capture_file if not capture_file: if options.capture: capture_file = os.path.join(CAPTURE_DIR, "capture-test-%s.zip" % time.time()) print "Capturing to file %s" % capture_file run_capture(options, capture_file) if not options.capture: # we were just doing a test run through the steps here, we're done return print "Processing capture..." capture = videocapture.Capture(capture_file) # create a difference. threshold differences above 32 to 255, then # run our existing algorithm on it framediff = capture.get_frame(0) - capture.get_frame(capture.num_frames - 1) for y, row in enumerate(framediff): for x, px in enumerate(row): if px[0] > 32 or px[1] > 32 or px[2] > 32: framediff[y][x] = [255.0, 255.0, 255.0] largest_square = square.get_biggest_square([255, 255, 255], framediff, x_tolerance_min=100, x_tolerance_max=100, handle_multiple_scanlines=True) if largest_square is not None: print "Capture area: %s" % largest_square if options.output_file: with open(options.output_file, 'w+') as f: f.write('CAPTURE_AREA=%s\n' % largest_square) if options.output_screenshot: im = capture.get_frame_image(int(capture.length / 2)) draw = ImageDraw.Draw(im) draw.rectangle(largest_square, outline=(255, 0, 0)) im.save(options.output_screenshot) else: print "Couldn't find capture area" sys.exit(1)