Anna Mikhailova
asked on
Not able to read newly written image
I was actually trying to do read an image, do object detection on it and write a new image that has detected objects marked in it. A new image does indeed get saved in the working directory but I am unable to open it using cv2 or using any of the image displaying softwares on fedora. i tried uploading it to a photo uploading site and it displays properly. I did go through the stack overflow, they say the issue was regarding trying to read a png image using a jpeg reader and as per what i could understand i tried installing libpng but still does not work.Would be grateful if someone could help me with it. Here is the code I have tried:
from imageai.Detection import ObjectDetection
import os
import cv2
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRet inaNet()
detector.setModelPath( os.path.join(execution_pat h , "resnet50_coco_best_v2.0.1 .h5"))
detector.loadModel()
detections = detector.detectObjectsFrom Image(inpu t_image=os .path.join (execution _path , "car.jpg"), output_image_path=os.path. join(execu tion_path , "imagenew.jpg"))
for eachObject in detections:
print(eachObject["name"] + " : " + eachObject["percentage_pro bability"] )
print(cv2.imshow('detected ',imagenew ))
from imageai.Detection import ObjectDetection
import os
import cv2
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRet
detector.setModelPath( os.path.join(execution_pat
detector.loadModel()
detections = detector.detectObjectsFrom
for eachObject in detections:
print(eachObject["name"] + " : " + eachObject["percentage_pro
print(cv2.imshow('detected
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.