Commit 44f81f2b authored by 吴升宇's avatar 吴升宇

fix handle

parent d1cb0ff2
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import argparse import argparse
import cv2 import cv2
import urllib
import numpy as np
from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.config import cfg
from demo.predictor import COCODemo from demo.predictor import COCODemo
...@@ -69,11 +71,10 @@ def img_to_three_color_map(img): ...@@ -69,11 +71,10 @@ def img_to_three_color_map(img):
def handle_from_url(image_url): def handle_from_url(image_url):
""" 处理网路图片 """ """ 处理网路图片 """
cap = cv2.VideoCapture(image_url) resp = urllib.request.urlopen(image_url)
if (cap.isOpened()): image = np.asarray(bytearray(resp.read()), dtype="uint8")
ret, img = cap.read() image = cv2.imdecode(image, cv2.IMREAD_COLOR)
return img_to_three_color_map(img) return img_to_three_color_map(image)
return None
def handle_from_path(image_path): def handle_from_path(image_path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment