Код: Выделить всё
while True:
ret, frame = self.video.read()
results = self.model.track(frame)
frame_result = results[0].plot()
for r in results:
boxes = r.boxes
for box in boxes:
c = box.cls
if model.names[int(c)] == 'cell phone':
playsound('audio.mp3') #i want this to play in background while code is still runninng
ret, jpeg = cv2.imencode('.jpg', frame_result)
frame = jpeg.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
Подробнее здесь: https://stackoverflow.com/questions/791 ... l-run-code