示例#1
0
    # Also close the tray so that both markers are unobstructed
    arm.move_abs(config.src_tray_pos)
    arm.wait_for_move_end()
    drive.close_tray()

    log.info("Acquiring calibration image")
    display.msg("IMAGE ACQUIRE")

    image_filename = vision.image_acquire(filename=tempfile.mktemp(dir=invocation_dir, prefix="calibration-image-"))
    if not image_filename:
        log.warn("Could not acquire image for calibration, please check the camera")
        display.msg("CANNOT ACQUIRE IMAGE, RETRY IN {} SECONDS".format(config.camera_calibration_delay))
        time.sleep(config.camera_calibration_delay)
        continue

    (calibration_markers,frame) = vision.detect_markers(image_filename)

    log.debug("Markers detected during calibration: '{}'".format(calibration_markers))

    if calibration_markers and 'disk_center' in calibration_markers and 'disk_edge' in calibration_markers:
        if image_filename:
            os.unlink(image_filename)        # Remove acquired image if calibration was successful
        break
    else:
        log.warn("Both calibration markers need to be detectable, please adjust the camera or lighting conditions")
        display.msg("NO MARKERS, RETRY IN {} SECONDS".format(config.camera_calibration_delay))
        time.sleep(config.camera_calibration_delay)

log.info("Camera calibration was successful, calibration markers detected: {}".format(calibration_markers))
display.msg("VISION OK")