运行对象检测脚本时收到图像空间尺寸错误

时间:2019-04-12 18:33:10

标签: python numpy opencv mask

我正在尝试在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)

我正在尝试实时可视化乐谱,标签,盒子和蒙版。

0 个答案:

没有答案