示例#1
0
    categories = label_map_util.convert_label_map_to_categories(
        label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
    category_index = label_map_util.create_category_index(categories)

    inference = Inference()
    sess = inference.get_model_session(PATH_TO_CKPT)

    # Input tensor is the image.
    image_tensor = inference.get_input_tensor()

    # Output tensors are the detection boxes, scores, and classes.
    detection_boxes = inference.get_output_tensor()

    # Each score represents level of confidence for each of the objects.
    detection_scores = inference.get_model_detection_scores()
    detection_classes = inference.get_model_detection_classes()

    # Number of objects detected.
    num_detections = inference.get_model_detected_objects()

    camera = PiCamera()
    camera.resolution = (IM_WIDTH, IM_HEIGHT)
    camera.framerate = 10
    rawCapture = PiRGBArray(camera, size=(IM_WIDTH, IM_HEIGHT))
    rawCapture.truncate(0)

    # Initialize frame rate calculation
    collector = Collector()
    frame_rate_calc = collector.frame_rate_calc
    freq = collector.freq
    font = collector.font