Collecting image data with the OpenMV Cam H7 Plus

This page is part of Adding sight to your sensors and describes how you can use the OpenMV Cam H7 Plus to build a dataset, and import the data into Edge Impulse.

1. Setting up your environment

To set up your OpenMV camera, and collect some data:

  1. Install the OpenMV IDE.

  2. Follow the OpenMV hardware setup guide to clean the sensor and focus the lens.

  3. Connect a micro-USB cable to the camera, and open the OpenMV IDE. The camera should automatically update to the latest firmware.

  4. Verify that the camera can capture live images, by clicking on the Connect button in the bottom left corner, then pressing Play to run the application.

Set up your OpenMV camera. Press the 'Connect' button, then press 'Play' to run the application.

A live feed from your camera will be displayed in the top right corner of the IDE.

2. Collecting images

Once your camera is up and running, it's time to start capturing some images and build our dataset.

First, set up a new dataset via Tools -> Dataset Editor, select New Dataset.

Creating a new dataset in the OpenMV IDE

This opens the 'Dataset editor' panel on the left side, and the 'dataset capture script' in the main panel of the IDE. Here, create three classes: "plant", "lamp" and "unknown". It's important to add an unknown class that contains random images which are neither lamps nor plants.

Create three classes in the OpenMV IDE by clicking the 'New class folder' (highlighted in yellow).

As we'll build a model that takes in square images, change the 'Dataset capture script' to read:

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # Modify as you like.
sensor.set_framesize(sensor.QVGA) # Modify as you like.
sensor.set_windowing((240, 240)) # Modify as you like.
sensor.skip_frames(time = 2000)

clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()
    print(clock.fps())

Now you can capture data for the three classes.

  1. Click the Play icon to run the 'dataset capture script' on your OpenMV camera.

  2. Select one of the classes by clicking on the folder name in the 'Dataset editor'.

  3. Take a snap by clicking the Capture data (camera icon) button.

Do this until you have captured 30 images per class from a variety of angles. Also make sure to vary the things you capture for the unknown class.

Capturing data (a plant image shown on the left) into a dataset using the OpenMV camera

3. Sending the dataset to Edge Impulse

To import the dataset into Edge Impulse go to Tools > Dataset Editor > Export > Upload to Edge Impulse project.

Synchronize your dataset with Edge Impulse straight from the OpenMV IDE

Then, choose the project name, and the split between training and testing data (recommended to keep this to 80/20).

Choose a project, and then the dataset split to upload your data

A duplicate check runs when you upload new data, so you can upload your dataset multiple times (for example, when you've added new files) without adding the same data twice.

Training and testing data split

The split between training and testing data is based on the hash of the file in order to have a deterministic process. As a consequence you may not have a perfect 80/20 split between training and testing, but this process ensures samples are always placed in the same category.

Our dataset now appears under the Data acquisition section of our project.

Collected data

You can now go back to the Image classification tutorial to build your machine learning model.

Last updated

Revision created

Merge branch 'main' into brickml