Ошибка получения пространственных размеров изображения при запуске сценария обнаружения объекта - PullRequest
0 голосов
/ 12 апреля 2019

Я пытаюсь запустить сценарий обнаружения моего объекта в потоке rtsp, но получаю сообщение об ошибке измерений?

ValueError: The image has spatial dimensions (480, 720) but the mask has dimensions (15, 15)

Я уже пытался удалить эту ошибку из visulization_utils и пытался настроить разрешение камеры.

#Gets the object mask
detection_masks = detection_graph.get_tensor_by_name('detection_masks:0')

# Initialize webcam feed
print("[INFO] starting video stream...")
cap = VideoStream(src="rtsp://192.168.0.12/media/video1", resolution=(720,480), framerate=10).start()
time.sleep(2.0)
fps = FPS().start()

while(True):

    # Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
    # i.e. a single-column array, where each item in the column has the pixel RGB value
    frame = cap.read()
    frame_expanded = np.expand_dims(frame, axis=0)

    # Perform the actual detection by running the model with the image as input
    (boxes, scores, classes, num, masks) = sess.run(
        [detection_boxes, detection_scores, detection_classes, num_detections, detection_masks],
        feed_dict={image_tensor: frame_expanded})

    # Draw the results of the detection (aka 'visulaize the results')
    vis_util.visualize_boxes_and_labels_on_image_array(
        frame,
        np.squeeze(boxes),
        np.squeeze(classes).astype(np.int32),
        np.squeeze(scores),
        category_index,
        np.squeeze(masks).astype(np.uint8),
        use_normalized_coordinates=True,
        line_thickness=8,
        min_score_thresh=0.60)

    # All the results have been drawn on the frame, so it's time to display it.
    cv2.imshow('Object detector', frame)

Я пытаюсь визуализировать результаты, метки, поля и маски в режиме реального времени.

...