无法读取新写的图像

时间:2018-06-20 19:29:51

标签: python python-3.x object-detection

我实际上是在尝试读取图像,对图像进行对象检测,并写一个新的图像来检测其中标记的对象。新图像确实确实保存在工作目录中,但是我无法使用cv2或fedora上的任何图像显示软件打开它。 我尝试将其上传到照片上传网站,并且显示正确。 我确实经历了堆栈溢出,他们说问题是关于尝试使用jpeg阅读器读取png图像,并且据我了解我尝试安装libpng但仍然无法正常工作。如果有人可以帮助我,我将不胜感激它。 这是我尝试过的代码:

from imageai.Detection import ObjectDetection
import os
import cv2

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "car.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))

for eachObject in detections:
    print(eachObject["name"] + " : " + eachObject["percentage_probability"] )
print(cv2.imshow('detected',imagenew))

0 个答案:

没有答案