Skip to content
Advertisement

Pass video uploaded via django to cv2

I am uploading video via django and want to process it using cv2. This is how video uploaded via django is accessed.

JavaScript

Next i want to pass it to opencv. I dont want to save video in disk first and then acess it via cv2 using following code

JavaScript

I tried passing this video_obj to VideoCapture this way

JavaScript

But i got following error

JavaScript

Advertisement

Answer

Seems like cv2.VideoCapture can only work with filepath. So to get the path from TemporaryUploadedFile object you can use temporary_file_path() method.

Advertisement