Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: videos_to_poses crash cv2.error: OpenCV(4.5.5) 👎 error: (-5:Bad argument) in function 'VideoCapture' #135

Closed
cleong110 opened this issue Dec 17, 2024 · 4 comments · Fixed by #136

Comments

@cleong110
Copy link
Contributor

cleong110 commented Dec 17, 2024

cap = cv2.VideoCapture(input_path)
This line expects a string. But our latest version installed from source gives it a pathlib Path here.

Propose fix, cast to str. Change this:

            pose_video(vid_path, pose_path, pose_format, additional_config, progress=False) 

To this:

            pose_video(str(vid_path), str(pose_path), pose_format, additional_config, progress=False) 

Step to replicate:

  1. Colab notebook
  2. clone repo
  3. navigate to the python folder, something like %cd /content/pose/src/python
  4. !pip install vidgear mediapipe psutil numpy scipy tqdm "opencv-python==4.5.5.64"
  5. !pip install -e. # should output something like install pose-format 0.7
  6. also installthe other deps,
  7. upload a .mp4 file
  8. !videos_to_poses -d directory_containing_the_file

Edit: Here's the traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 205, in _process_chunk
    return [fn(*args) for args in chunk]
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 205, in <listcomp>
    return [fn(*args) for args in chunk]
  File "/content/pose/src/python/pose_format/bin/directory.py", line 94, in process_video
    pose_video(vid_path, pose_path, pose_format, additional_config, progress=False)
  File "/content/pose/src/python/pose_format/bin/pose_estimation.py", line 21, in pose_video
    cap = cv2.VideoCapture(input_path)
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'VideoCapture'
> Overload resolution failed:
>  - Can't convert object to 'str' for 'filename'
>  - VideoCapture() missing required argument 'apiPreference' (pos 2)
>  - Argument 'index' is required to be an integer
>  - VideoCapture() missing required argument 'apiPreference' (pos 2)
@AmitMY
Copy link
Collaborator

AmitMY commented Dec 19, 2024

fair point! feel free to make that tiny PR :)

@cleong110
Copy link
Contributor Author

Looking into it further, it seems this was fixed in later versions of OpenCV-Python.

So another solution would be to update our requirements to use newer opencv.

But I'll go ahead and do the tiny PR anyway.

@cleong110
Copy link
Contributor Author

PR made!

Re: OpenCV version:
https://github.com/opencv/opencv/wiki/OpenCV-Change-Logs-v2.2%E2%80%90v4.10#version4100 Looks like after version 4.10 this problem goes away on its own.

@AmitMY do you happen to know why we require such a specific opencv version here? https://github.com/sign-language-processing/pose/blob/master/src/python/pyproject.toml#L22

AmitMY pushed a commit that referenced this issue Dec 19, 2024
* CDL: minor doc typo fix

* CDL: quick path-to-string fix for #135

* Undoing some changes that got mixed in
@AmitMY
Copy link
Collaborator

AmitMY commented Dec 19, 2024

Yes, at some point we had an issue with a new version of opencv, so had to fix the version to something that worked.
Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants