Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello,
I want to read a video from a folder using the python package OpenCV but I have this error :
OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'VideoCapture' > Overload resolution failed: > - Can't convert object to 'str' for 'filename' > - Required argument 'apiPreference' (pos 2) not found > - Argument 'index' is required to be an integer > - Required argument 'apiPreference' (pos 2) not found
Have you got a solution ?
Thanks
Hi @Niaussat,
It will depend on if cv2.VideoCapture() can read in a file-like object, which is what you are currently passing into it, and it seems like it may not be able to. Because of this, I would focus on:
If you could use help on the latter part, can you clarify what type of connection your managed folder is using, so that I might provide an example?
Here is an example of reading in the videos based on the "locally stored" video files:
import cv2
import dataiku
video = dataiku.Folder('YKDPuZkg')
folder_path = video.get_info()['path']
for vid in video.get_path_details()['children']:
full_vido_path = folder_path + vid['fullPath']
cap = cv2.VideoCapture(full_vido_path)
cap.read()
 
I hope that's helpful.
Thanks,
Sarina
Hi @Niaussat,
It will depend on if cv2.VideoCapture() can read in a file-like object, which is what you are currently passing into it, and it seems like it may not be able to. Because of this, I would focus on:
If you could use help on the latter part, can you clarify what type of connection your managed folder is using, so that I might provide an example?
Here is an example of reading in the videos based on the "locally stored" video files:
import cv2
import dataiku
video = dataiku.Folder('YKDPuZkg')
folder_path = video.get_info()['path']
for vid in video.get_path_details()['children']:
full_vido_path = folder_path + vid['fullPath']
cap = cv2.VideoCapture(full_vido_path)
cap.read()
 
I hope that's helpful.
Thanks,
Sarina
Thank you, that works.