本文整理汇总了Python中keras_retinanet.utils.image.read_image_bgr方法的典型用法代码示例。如果您正苦于以下问题:Python image.read_image_bgr方法的具体用法?Python image.read_image_bgr怎么用?Python image.read_image_bgr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras_retinanet.utils.image
的用法示例。
在下文中一共展示了image.read_image_bgr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: viewImageFromURL
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def viewImageFromURL(url_pic):
import requests, cv2
from keras_retinanet.utils.image import read_image_bgr
import matplotlib.pyplot as plt
r = requests.get(url_pic, allow_redirects=True)
image = read_image_bgr(BytesIO(r.content))
# copy to draw on
draw = image.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)
plt.figure(figsize=(15, 15))
plt.axis('off')
plt.imshow(draw)
plt.show()
示例2: getImageFromURL
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def getImageFromURL(url_pic, draw=False):
''' The image is the one that will be processed, the draw is the one to be shown '''
import requests, cv2
from keras_retinanet.utils.image import read_image_bgr
r = requests.get(url_pic, allow_redirects=True)
image = read_image_bgr(BytesIO(r.content))
if draw:
# copy to draw on
draw = image.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)
return image, draw
else:
return image
示例3: getImageFromFilePath
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def getImageFromFilePath(img_path, draw=False):
''' The image is the one that will be processed, the draw is the one to be shown '''
import requests, cv2
from keras_retinanet.utils.image import read_image_bgr
image = read_image_bgr(img_path)
if draw:
# copy to draw on
draw = image.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)
return image, draw
else:
return image
示例4: detect
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def detect(self, img_path, min_prob=0.6):
image = read_image_bgr(img_path)
image = preprocess_image(image)
image, scale = resize_image(image)
boxes, scores, labels = Detector.detection_model.predict_on_batch(np.expand_dims(image, axis=0))
boxes /= scale
processed_boxes = []
for box, score, label in zip(boxes[0], scores[0], labels[0]):
if score < min_prob:
continue
box = box.astype(int).tolist()
label = Detector.classes[label]
processed_boxes.append({'box': box, 'score': score, 'label': label})
return processed_boxes
示例5: load_image
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def load_image(self, image_index):
image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
path = os.path.join(self.data_dir, 'images', image_info['file_name']) #, self.set_name
return read_image_bgr(path)
示例6: predict
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def predict(imagePath):
# load the input image (in BGR order), clone it, and preprocess it
image = read_image_bgr(imagePath)
output = image.copy()
image = preprocess_image(image)
(image, scale) = resize_image(image)
image = np.expand_dims(image, axis=0)
# detect objects in the input image and correct for the image scale
(boxes, scores, labels) = model.predict_on_batch(image)
boxes /= scale
# loop over the detections
for (box, score, label) in zip(boxes[0], scores[0], labels[0]):
# filter out weak detections
if score < 0.5:
continue
# convert the bounding box coordinates from floats to integers
box = box.astype("int")
# build the label and draw the label + bounding box on the output
# image
label = "{}: {:.2f}".format(LABELS[label], score)
cv2.rectangle(output, (box[0], box[1]), (box[2], box[3]),
(0, 255, 0), 2)
cv2.putText(output, label, (box[0], box[1] - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
# show the output image
cv2.imwrite("prediction.jpg", output)
return boxes
示例7: load_image
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def load_image(self, image_index):
image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
path = os.path.join(self.data_dir, 'images', self.set_name, image_info['file_name'])
return read_image_bgr(path)
示例8: load_image
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def load_image(self, image_index):
return read_image_bgr(self.image_path(image_index))
示例9: test_read_image_bgr
# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import read_image_bgr [as 别名]
def test_read_image_bgr(tmp_path):
stub_image_path = os.path.join(tmp_path, _STUB_IMG_FNAME)
original_img = np.asarray(Image.open(
stub_image_path).convert('RGB'))[:, :, ::-1]
loaded_image = image.read_image_bgr(stub_image_path)
# Assert images are equal
np.testing.assert_array_equal(original_img, loaded_image)