def get_mjpeg_stream_image(stream):
global bytes
while True:
bytes += stream.read(20000)
a = bytes.find(b'\xff\xd8')
b = bytes.find(b'\xff\xd9')
if a!= -1 and b != -1:
jpg = bytes[a:b+2]
bytes = bytes[b+2:]
img = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.IMREAD_COLOR)
q.put_nowait(img)
cv2.waitKey(1)
评论列表
文章目录