0

So i am using a raspberry pi 4 8gb running RPi OS and i'm having trouble with the yolov3 module of ImageAI 2.1.6. It's not accepting my picamera2 images. I can't seem to find a solution to my issue. When i use cv2 as the camera on my regular computer everything works but when i run it on the pi i get this error: ValueError: Ensure you specified correct input image, input type, output type and/or output image path

I know i am reciving images from it since i have ran a camtest.py based on picamera2 so there must be some issue with yolo not accepting images.

from imageai import Detection
from picamera2 import Picamera2
import numpy as np

 

modelpath = "/home/admin/Desktop/yolo.h5"
PLAYCAM = True
 

mpp = 75
picam2 = Picamera2() 
picam2.configure(picam2.create_preview_configuration(main={"format": 'RGB888', "size": (640, 480)}))
picam2.start()
 
yolo = Detection.ObjectDetection()
yolo.setModelTypeAsYOLOv3()
yolo.setModelPath(modelpath)
yolo.loadModel(detection_speed="flash")
 
def capframe():
    # read frames
    img = picam2.capture_array("main")
    img = cv2.flip(img, 0)
    preds = yolo.detectObjectsFromImage(input_image=img,
                                custom_objects=None, input_type="array",
                                output_type="array",
                                minimum_percentage_probability=mpp,
                                display_percentage_probability=True,
                                display_object_name=True)

    # predict yolo
    #print(preds)
 
 
    return preds[1:]

I tried using cv2 on the raspberry pi along with a webcam but i couldn't get images from it at all. I tried decreasing the color depth. Not much more than that because i don't understand the reason i am getting this error.

0 Answers0