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

add a blog section on code.groundlight.ai and a blog post on framegrab #138

Merged
merged 9 commits into from
Dec 11, 2023
175 changes: 175 additions & 0 deletions docs/blog/2023-12-06-framegrab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
---
title: Announcing Groundlight's FrameGrab Library
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
description: Today, we are happy to announce FrameGrab 0.4.3.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: its a little funny for us to make a big blog post about version 0.4.3 specifically. Why didnt version 0.4.2 get a blog post??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the v0.4.3 specific features?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it feels like we should make this 0.5.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Today, we are happy to announce FrameGrab 0.4.3.
description: We'd like to introduce you to the FrameGrab library.

I agree. This is why I like the phrase "Introducing" framegrab. It's been around for a while, but now we're going to introduce you to it.

slug: announcing-framegrab
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
authors:
- 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

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
announce FrameGrab, an extremely easy-to-use Python library designed to make it easy to grab frames from
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
cameras or streams.

FrameGrab also supports generic USB cameras, RTSP streams, Basler USB cameras, Basler GigE cameras, and
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
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
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
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()
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved

```

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:[email protected]/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

With this release, we also introduce autodiscovery mode. This mode 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 lauch autodiscovery mode.
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved

```python
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 the frame differencing
algorithm. This is an extremely fast algorithm for easily detecting motion in a sequence of frames.

To use motion detection, it suffices to initialize the MotionDetector instance with the desired percentage of pixels
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
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
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


This release of FrameGrab comes with several awesome features that are very easy to use. We now support
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
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 awesome library.
blaise-muhirwa marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const config = {
label: "GitHub",
position: "right",
},
{
to: 'blog',
label: 'Blog',
position: 'left',
},
],
},
footer: {
Expand Down
Loading