-
Notifications
You must be signed in to change notification settings - Fork 6
add a blog section on code.groundlight.ai and a blog post on framegrab
#138
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
235e49c
add a blog section on code.groundlight.ai
blaise-muhirwa 667c4af
accept suggested changes
blaise-muhirwa 3dbb6fa
accept suggested change
blaise-muhirwa fad5467
accept suggested changes
blaise-muhirwa b3bd078
Apply suggestions from code review
blaise-muhirwa 70a70ad
Merge branch 'main' of https://github.com/groundlight/python-sdk into…
blaise-muhirwa bc020cd
Merge branch 'setup-docusaurus-blog' of https://github.com/groundligh…
blaise-muhirwa 947aa1b
clean up the blogpost
blaise-muhirwa 69ba1e6
edit blogpost
blaise-muhirwa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| --- | ||
| title: Introducing Groundlight's FrameGrab Library | ||
| description: We would like to introduce you to the FrameGrab library. | ||
| slug: introducing-framegrab | ||
| authors: | ||
| - name: Tim Huff | ||
| title: Engineering intern at Groundlight | ||
| image_url: https://media.licdn.com/dms/image/D5603AQGQwDSbGUBQGA/profile-displayphoto-shrink_800_800/0/1666299654820?e=1707955200&v=beta&t=0V2Y83ZcAIvVnyGsm7HVmo9FK4S54cRdVu3jnOW1mRE | ||
| - name: Blaise Munyampirwa | ||
| title: Engineer at Groundlight | ||
| image_url: https://media.licdn.com/dms/image/C5603AQFn3zyJUMwMUA/profile-displayphoto-shrink_800_800/0/1656538661201?e=1707350400&v=beta&t=LtAkwTpt4avbqaQLSUdFerM7ydEfTTlZ3dOgmnDTpj4 | ||
| - name: Leo Dirac | ||
| title: CTO and Co-founder at Groundlight | ||
| image_url: https://media.licdn.com/dms/image/C5603AQGtXilFu-aISw/profile-displayphoto-shrink_400_400/0/1646094305554?e=1707955200&v=beta&t=ZaD2WPrNTdLeWzeuSMjdgz08pEz92v0JyLvQHs4iA4w | ||
| - name: Tyler Romero | ||
| title: Senior Machine Learning Engineer | ||
| image_url: https://media.licdn.com/dms/image/D5603AQF0tC5-7i7o5g/profile-displayphoto-shrink_400_400/0/1667186510594?e=1707955200&v=beta&t=CAKXZuSxsNgLlNZxKUwREOlWeu7tz6GnKBHQCZ7U-d0 | ||
| - name: Michael Vogelsong | ||
| title: Chief ML Scientist | ||
| image_url: https://media.licdn.com/dms/image/C4E03AQGNcA6o2YP-yw/profile-displayphoto-shrink_200_200/0/1516836772974?e=1707955200&v=beta&t=sm1qBabL3bN1oZlO4iBvwuWhuqeMa0E-Jc4EqTtmJps | ||
|
|
||
|
|
||
| tags: [groundlight-extensions, framegrab] | ||
| image: https://i.imgur.com/mErPwqL.png | ||
| hide_table_of_contents: false | ||
| --- | ||
|
|
||
|
|
||
| <!-- truncate --> | ||
|
|
||
| At Groundlight, we continue to build infrastructure that allows our customers to easily use computer | ||
| vision without a pre-existing dataset for industrial inspection, retail analytics, mobile robotics, and | ||
| much more. We've built many features towards the goal of declarative computer vision, and today we are excited to | ||
| introduce FrameGrab, a Python library designed to make it easy to grab frames from | ||
| cameras or streams. | ||
|
|
||
| FrameGrab supports generic USB cameras, RTSP streams, Basler USB cameras, Basler GigE cameras, and Intel RealSense depth cameras. | ||
|
|
||
|
|
||
| ## Grabbing Camera Frames | ||
|
|
||
| Frame grabber objects are configured through YAML. The configuration combines the camera type, camera ID, and the camera | ||
| options. The YAML config contains many configurable features, but only `input_type` is required. Valid choices for | ||
| `input_type` include | ||
|
|
||
| * generic_usb | ||
| * rtsp | ||
| * realsense | ||
| * basler | ||
|
|
||
| Here is an example of how to use the generic USB configuration | ||
|
|
||
| ```python notest | ||
| from framegrab import FrameGrabber | ||
|
|
||
| config = """ | ||
| name: Front Door Camera | ||
| input_type: generic_usb | ||
| id: | ||
| serial_number: 23432570 | ||
| options: | ||
| resolution: | ||
| height: 1080 | ||
| width: 1920 | ||
| zoom: | ||
| digital: 1.5 | ||
| """ | ||
|
|
||
| grabber = FrameGrabber.create_grabber_yaml(config) | ||
| frame = grabber.grab() | ||
|
|
||
| # Do real work with the frame | ||
|
|
||
| # Finally release the grabber object | ||
| grabber.release() | ||
|
|
||
| ``` | ||
|
|
||
| For the full set of configurable parameters, please refer to the [FrameGrab repository](https://github.com/groundlight/framegrab/tree/main). | ||
|
|
||
| ## Multi-cam Configuration | ||
|
|
||
| If you have multiple cameras of the same type plugged in, we recommend you include serial numbers in the YAML config to | ||
| ensure proper pairing. The default pairing behavior is sequential (i.e., configurations will be paired with cameras in | ||
| a sequential ordering). | ||
|
|
||
| You can add serial numbers for multiple cameras like this | ||
|
|
||
| ```yaml | ||
| GL_CAMERAS: | | ||
| - name: on robot arm | ||
| input_type: realsense | ||
| options: | ||
| depth: | ||
| side_by_side: 1 | ||
| crop: | ||
| relative: | ||
| right: .8 | ||
| - name: conference room | ||
| input_type: rtsp | ||
| id: | ||
| rtsp_url: rtsp://admin:password@192.168.1.20/cam/realmonitor?channel=1&subtype=0 | ||
| options: | ||
| crop: | ||
| pixels: | ||
| top: 350 | ||
| bottom: 1100 | ||
| left: 1100 | ||
| right: 2000 | ||
| - name: workshop | ||
| input_type: generic_usb | ||
| id: | ||
| serial_number: B77D3A8F | ||
|
|
||
| ``` | ||
|
|
||
| ## FrameGrab Autodiscovery Mode | ||
|
|
||
| Among other features, FrameGrab also includes autodiscovery mode. This allows you to automatically connect to all cameras | ||
| that are plugged into your machine (or discoverable on the network). Autodiscovery will load up default configurations | ||
| for each camera. | ||
|
|
||
| :::note | ||
|
|
||
| Please note that RTSP streams cannot be autodiscovered in this manner. RTSP URLs must be pre-specified in the | ||
| configurations. | ||
|
|
||
| ::: | ||
|
|
||
| We recommend autodiscovery for simple applications where you don't need to set any special options on your cameras. | ||
| It is also a convenient method for finding the serial numbers of your cameras in case they are not printed on them. | ||
|
|
||
| Below is a short example of how to launch autodiscovery mode. | ||
|
|
||
| ```python notest | ||
| from framegrab import FrameGrabber | ||
|
|
||
| grabbers = FrameGrabber.autodiscover() | ||
|
|
||
| # Print some information about the discovered cameras | ||
| for grabber in grabbers.values(): | ||
| print(grabber.config) | ||
|
|
||
| # Do real work | ||
|
|
||
| # Release the frame grabber object | ||
| grabber.release() | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ## Using FrameGrab for Motion Detection | ||
|
|
||
| With this release, we also continue to support [motion detection](https://en.wikipedia.org/wiki/Motion_detection) via frame differencing, a | ||
| fast algorithm for easily detecting motion in a sequence of frames. | ||
|
|
||
| To use motion detection, initialize the MotionDetector instance with the desired percentage of pixels | ||
| needed to change in an image for it to be flagged for motion and the minimum brightness change for each pixel for it | ||
| to be considered changed. Here is a comprehensive example. | ||
|
|
||
| ```python notest | ||
| from framegrab import FrameGrabber, MotionDetector | ||
|
|
||
| config = { | ||
| 'input_type': 'webcam', | ||
| } | ||
| grabber = FrameGrabber.create_grabber(config) | ||
| motion_detector = MotionDetector(pct_threshold=motion_threshold, val_threshold=60) | ||
|
|
||
| while True: | ||
| frame = grabber.grab() | ||
| if frame is None: | ||
| print("No frame captured!") | ||
| continue | ||
|
|
||
| if motion_detector.motion_detected(frame): | ||
| print("Motion detected!") | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ## Conclusion | ||
|
|
||
| Recent releases of FrameGrab add various easy to use features. We now support | ||
| multiple camera types and continue to support motion detection. | ||
|
|
||
| If you encounter any issues while using FrameGrab, please feel free to file an issue in our [GitHub repository](https://github.com/groundlight/framegrab) | ||
| and while there, review guidelines for [contributing](https://github.com/groundlight/framegrab#contributing) to this library. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.