You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the Supervision issues and found no similar feature requests.
Description
Hello,
I'm using sv.VideoInfo.from_video_path to retrieve video metadata and perform video manipulations. However, I've noticed an issue with how fps is calculated. Specifically, sv.VideoInfo.from_video_path uses the following method: fps = int(video.get(cv2.CAP_PROP_FPS))
This approach can lead to inaccuracies in certain scenarios. For example, if the actual FPS of a video is 24.999, the method will round this down to 24. Over a long video, this discrepancy can cause significant shifts and synchronization problems.
Would it be possible to modify the implementation to return the FPS as a float rather than truncating it to an integer? This would improve accuracy for edge cases like this.
Thank you for your attention!
Use case
Change the method of fps from fps = int(video.get(cv2.CAP_PROP_FPS)) to fps = float(video.get(cv2.CAP_PROP_FPS))
Additional
No response
Are you willing to submit a PR?
Yes I'd like to help by submitting a PR!
The text was updated successfully, but these errors were encountered:
Thank you for reporting the issue! Indeed, half of our own asset videos don't have a round number for the fps.
Test code
importsupervisionassvfromsupervision.assetsimportVideoAssets, download_assetsimportcv2# int fps: People walking, Market square, Skiing, Milk bottling plant, Vehicles# float fps: Subway, Basketball, Grocery Store, Beach, Vehicles 2asset=VideoAssets.VEHICLES_2download_assets(asset)
video=cv2.VideoCapture(asset.value)
fps=video.get(cv2.CAP_PROP_FPS)
print(fps, type(fps))
video_info=sv.VideoInfo.from_video_path(asset.value)
print(video_info)
This would be a superb PR submission! However, since we've had the int(fps) code for a while, this issue requires looking at the wider impacts. There's multiple things to check, but I believe each of these is pretty simple:
Can we still use VideoSink to store a video?
Does ByteTrack still work if a non-int FPS is passed in? Does setting track_seconds * fps for the lost track buffer work?
Does speed estimation in inference_example.py work?
It's also used in coordinate calculation in {ultralytics,inference,yolo_nas}_example.py
timers.py for time in zone calculation. Used in ultralytics{_naive}_stream_example.py
Is FPS monitor anyhow affected? I don't think so, but it'd be worth checking.
Search before asking
Description
Hello,
I'm using
sv.VideoInfo.from_video_path
to retrieve video metadata and perform video manipulations. However, I've noticed an issue with how fps is calculated. Specifically,sv.VideoInfo.from_video_path
uses the following method:fps = int(video.get(cv2.CAP_PROP_FPS))
This approach can lead to inaccuracies in certain scenarios. For example, if the actual FPS of a video is 24.999, the method will round this down to 24. Over a long video, this discrepancy can cause significant shifts and synchronization problems.
Would it be possible to modify the implementation to return the FPS as a float rather than truncating it to an integer? This would improve accuracy for edge cases like this.
Thank you for your attention!
Use case
Change the method of fps from
fps = int(video.get(cv2.CAP_PROP_FPS))
tofps = float(video.get(cv2.CAP_PROP_FPS))
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: