Robert KeithMark Phillips
Published © Apache-2.0

People Counting with Helium, Grid-EYE, and Raspberry Pi

A simple way to identify objects in a room using the Grid-EYE, a Raspberry Pi, OpenCV, and the Helium Network.

IntermediateFull instructions provided1 hour3,889
People Counting with Helium, Grid-EYE, and Raspberry Pi

Things used in this project


Read more


Extracted AWS IoT Data

Here is a short result of the Grid-Eye scanning a room with a 30 degree celsius or higher threshold

Raspberry Pi Zero Schematic

Screen shot 2017 11 12 at 6 40 29 pm 0ckuy8ktuk


R Pi GridEye

Connecting the Pi to the Grid-Eye and transmitting to Helium Channel code
import numpy as np
import math
import time
from matplotlib import pyplot as plt
from Adafruit_AMG88xx import Adafruit_AMG88xx
from scipy.interpolate import griddata
import cv2
from helium_client import Helium

helium = Helium("YOUR SERIAL PORT HERE")

channel = helium.create_channel("YOUR CHANNEL NAME HERE")

# Access an instance of Configuration
config = channel.config()
# Start sensor
sensor = Adafruit_AMG88xx()

active = True

    if active == True:
        # Read pixels, convert them to values between 0 and 1, map them to an 8x8 grid
        pixels = sensor.readPixels()
        pixmax = max(pixels)
        pixels = [x / pixmax for x in pixels]
        points = [(math.floor(ix / 8), (ix % 8)) for ix in range(0, 64)]
        grid_x, grid_y = np.mgrid[0:7:32j, 0:7:32j]

        # bicubic interpolation of 8x8 grid to make a 32x32 grid
        bicubic = griddata(points, pixels, (grid_x, grid_y), method='cubic')
        image = np.array(bicubic)
        image = np.reshape(image, (32, 32))
        plt.imsave('color_img.jpg', image)

        # Read image
        img = cv2.imread("color_img.jpg", cv2.IMREAD_GRAYSCALE)
        img = cv2.bitwise_not(img)

        # Setup SimpleBlobDetector parameters.
        params = cv2.SimpleBlobDetector_Params()

        # Change thresholds
        params.minThreshold = 10
        params.maxThreshold = 255

        # Filter by Area.
        params.filterByArea = True
        params.minArea = 5

        # Filter by Circularity
        params.filterByCircularity = True
        params.minCircularity = 0.1

        # Filter by Convexity
        params.filterByConvexity = False
        params.minConvexity = 0.87

        # Filter by Inertia
        params.filterByInertia = False
        params.minInertiaRatio = 0.01

        # Set up the detector with default parameters.
        detector = cv2.SimpleBlobDetector_create(params)

        # Detect blobs.
        keypoints = detector.detect(img)

        for i in range (0, len(keypoints)):
            x = keypoints[i].pt[0]
            y = keypoints[i].pt[1]
            print(x, y)

        # Get the channel setting for interval_ms
        interval = config.get("channel.interval_ms")
        interval = config.get("")
        # Report the device having set interval_ms
        config.set("channel.interval_ms", interval)
        config.set("", active)
        # time.sleep(5)

        interval = config.get("")
        config.set("", active)

Adafruit Grid-EYE repository

Add this through the Arduino library manager or through the public repository to test and operate the AMG88xx version Grid-EYE boards from Adafruit.


Robert Keith

Robert Keith

1 project • 2 followers
Mark Phillips

Mark Phillips

2 projects • 7 followers
Director of Customer Success at Helium