如何从另一个类传递img框架?
示例:
我有process.py
import cv2
from camera import Camera
from fire_detection import FireDetection
camera = Camera()
camera.connect()
while True:
frame = camera.get_frame()
if frame is not None:
#Especifico a configuração dos bombeiros
FireDetection = FireDetection.configBombeiros(frame)
#cv2.imshow('frame', frame)
if cv2.waitKey(100) & 0xFF == ord('q'):
camera.disconnect()
cv2.destroyWindow('frame')
在此类中,我调用FireDetection = FireDetection.configBombeiros(frame)并将该帧作为参数传递,但是我收到此错误:
Traceback (most recent call last):
File "processamento.py", line 11, in <module>
FireDetection = FireDetection.configBombeiros(frame)
File "E:\Matheus\MachineLearning\mvc_fogo\novo padrao\fire_detection.py", line 17, in configBombeiros
mascara = cv2.inRange(rgb, minimo, maximo)
TypeError: Expected Ptr<cv::UMat> for argument '%s'
fireDetection()类
import cv2
class FireDetection(object):
def __init__(self):
print('Inicio')
def configBombeiros(frame):
minimo = [170, 0, 245]
maximo = [220, 255, 255]
blur = cv2.GaussianBlur(frame, (21, 21), 0)
#Metodo de detecção de cor (pode ser usado HSV ou RGB) RGB se utiliza o metodo padrão de cor, exemplo: Vermelho 255,0,0
rgb = frame.copy()
mascara = cv2.inRange(rgb, minimo, maximo)
cv2.imshow('frame', frame)
答案 0 :(得分:0)
最有可能是minimo
和maximo
类型的问题。 here文档说它们必须是数组或缩放器。因此,尝试传递numpy数组或缩放器,
minimo = np.array([170, 0, 245])
maximo = np.array([220, 255, 255])