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

Missing usage example for live stream/camera #273

Closed
Breakthrough opened this issue Jul 7, 2022 · 1 comment
Closed

Missing usage example for live stream/camera #273

Breakthrough opened this issue Jul 7, 2022 · 1 comment
Milestone

Comments

@Breakthrough
Copy link
Owner

Breakthrough commented Jul 7, 2022

As identified in #151, there is no example in the API documentation for how to use a callback, e.g. for processing a live video stream. An example should clearly document and demonstrate this use case, e.g.:

from scenedetect import VideoStreamCv2, SceneManager, ContentDetector
scene_manager = SceneManager()
cam = VideoStreamCv2(0)
scene_manager.add_detector(ContentDetector())
scene_manager.detect_scenes(video=cam, callback=lambda frame: print("a new scene: ", len(frame)))

Also note that the callback API is still unstable, so if you are using this in production you should pin your scenedetect package to < 0.7.


This arose from the following comment:

A usage example:

cam = cv2.VideoCapture(0)
scene_manager.add_detector(ContentDetector())
scene_manager.detect_scenes(frame_source=cam, callback=lambda frame: print("a new scene: ", len(frame)))

when i tried this on a live video input, it throws error,

    scene_manager.detect_scenes(frame_source=cam, callback=lambda frame: print("a new scene: ", len(frame)))
  File "/usr/local/lib/python3.6/dist-packages/scenedetect/scene_manager.py", line 752, in detect_scenes
    self._base_timecode = video.base_timecode
AttributeError: 'cv2.VideoCapture' object has no attribute 'base_timecode'
```
any idea why is this happening?

Originally posted by @research-boy in #151 (comment)

@Breakthrough
Copy link
Owner Author

Breakthrough added a commit that referenced this issue Jul 12, 2022
This is better suited for devices/pipes as opposed to VideoStreamCv2,
which now focuses on files/image sequences/network streams. (#276)

Add tests demonstrating use of a callback when detecting scenes (#273).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant