dmlc / gluon-cv

Gluon CV Toolkit
http://gluon-cv.mxnet.io
Apache License 2.0
5.83k stars 1.22k forks source link

predict action recognition models on continuous video such as webcam streams... #1351

Closed alighofrani95 closed 4 years ago

alighofrani95 commented 4 years ago

Hi dear gcv developer I really enjoyed the action recognition implementation on gcv

just one thing How can I predict models such as i3d-nl and slowFast on continuous video such as webcam streams

thanks a lot

bryanyzhu commented 4 years ago

Hi, one simple way is to follow this tutorial, https://gluon-cv.mxnet.io/build/examples_action_recognition/demo_i3d_kinetics400.html

Instead of reading the video offline, you can use cv2 to read webcam streams and save the frames to a queue. Once the queue has 32 frames, you perform one inference. After that, you will enqueue new frames and deque the oldest frames to perform online prediction.

For more details, you can refer to ECO (ECCV 2018) paper to see how people perform online video prediction. https://arxiv.org/pdf/1804.09066.pdf

bryanyzhu commented 4 years ago

Closing the issue. Feel free to reopen it if new things come up.

bernalou commented 2 years ago

TypeError: Don't know how to handle type <class 'list'> This is the error when i tried save the frames in a list. How i can save the frames in a queue ? Do you have a code example ? Thanks

bryanyzhu commented 2 years ago

Use a simple list should do the job.

frames = []
cap = cv2.VideoCapture(0)
num_frames = 32

for i in range(num_frames):
    ret, frame = cap.read()
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    frames.append(frame)

I didn't run this code snippet, but should be something like this.