Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 无法传递用于对象检测的视频帧Tensorflow python_Opencv_Tensorflow_Object Detection_Nvidia Jetson Nano - Fatal编程技术网

Opencv 无法传递用于对象检测的视频帧Tensorflow python

Opencv 无法传递用于对象检测的视频帧Tensorflow python,opencv,tensorflow,object-detection,nvidia-jetson-nano,Opencv,Tensorflow,Object Detection,Nvidia Jetson Nano,我可以将视频帧作为图像进行处理,然后对其进行处理。但无法将帧直接传递给目标检测。 使用imwrite保存图像会使程序变慢 以下是我的主要方法: cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=2), cv2.CAP_GSTREAMER) if cap.isOpened(): window_handle = cv2.namedWindow("CSI Camera", cv2.WINDOW_AUTOSIZE) # Wind

我可以将视频帧作为图像进行处理,然后对其进行处理。但无法将帧直接传递给目标检测。 使用imwrite保存图像会使程序变慢

以下是我的主要方法:

cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=2), cv2.CAP_GSTREAMER)

if cap.isOpened():
    window_handle = cv2.namedWindow("CSI Camera", cv2.WINDOW_AUTOSIZE)
    # Window
    while cv2.getWindowProperty("CSI Camera", 0) >= 0:
        ret_val, frame = cap.read()
        if not ret_val:
            break
        frame = imutils.resize(frame, width=600)

        #cv2.imwrite('box.jpg', frame)
        #image = Image.open(path)
        #Error in here!!!
        predictions = od_model.predict_image(frame)


        for x in range(len(predictions)):
            probab = (predictions[x]['probability'])*100
            if(probab > 45):
                print(predictions[x]['tagName'], end=' ')
                print(probab)
        #cv2.imshow("CSI Camera", frame)
        # This also acts as
        keyCode = cv2.waitKey(30) & 0xFF
        # Stop the program on the ESC key
        if keyCode == 27:
            break
    cap.release()
    cv2.destroyAllWindows()
else:
    print("Unable to open camera")
错误消息:

predictions = od_model.predict_image(frame)
File "/home/bharat/New_IT3/object_detection.py", line 125, in 
predict_image
inputs = self.preprocess(image)
File "/home/bharat/New_IT3/object_detection.py", line 130, in 
preprocess
image = image.convert("RGB") if image.mode != "RGB" else image
AttributeError: 'numpy.ndarray' object has no attribute 'mode'

open cv读取bgr彩色光谱中的图像,将其转换为rgb并发送图像进行检测,相同的api为-


frame=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)

如果取消注释#cv2.imwrite('box.jpg',frame)#image=image.open(path),则它可以工作,但一次又一次地将图像写入内存会减慢进程。我正在寻找直接从PIL导入映像im=Image.fromarray(frame)//导入PIL包传递对象