How do I capture images, so I can label them, and then train a ML model?

Ideally, I’d like to use the Arduino Nano 33 BLE Sense from the TinyML course to capture images.

According to Pete Warden that’d be ‘difficult’.

From the research I’ve done, it appears that using a webcam/dashcam and saving the stream in the MJPEG format is the way to go. Then extract JPEGs using the OpenCV library to wind up with something that’s labelable.

I want to train the model on images that resemble what the OV7675 camera on the Arduino will see.

I.E. 640x480 colour (VGA) and not a wide angle image. The Arduino will be deployed to the same location where the images were collected.

Any help is very much appreciated.

1 Like

I have not successfully done this, but I wonder if there is a way to capture the stream from the camera as described in the optional section of the camera test at the beginning of course 3? This is beyond my skills at the moment, but I plan to work on it. I’ll post if I get anywhere.

1 Like

I imagine you can take any picture size and resolution and resize it to whatever you would like it to be.
A simple loop in Python can take all images you have, crop them, lower the resolution, and make them the format you need to feed into the model.

I can help with the code if you need to. Let me know first if this approach would work.

My problem is collecting the images. Since using the Arduino Nano and the OV7675 camera is difficult, I’ve been researching options.

Currently I’m trying to see if I can connect the OV7675 to a Raspberry Pi. If that doesn’t work, I could try a comparable camera that does work with Pi. I’ve never worked with a Raspberry Pi, so there’ll be a learning curve.

Another way to go is with a dashcam/webcam, saving the video to a micro sd card, and extracting the individual images using FFjpeg or a similar tool.

Any help or suggestions are welcome.

I imagine you can take pictures with any camera. Phone, dashcam, one of those small digital cameras (you can find online for 20$). As long as you have a camera to take the pictures you can save them to a file.

Once you have those pictures, in different sizes and resolutions, you can write a simple Python program (and I can help you with this) to resize them however you want. Here below is an example of the code I am suggesting.

  • this line tells the program where your pictures exist on the computer.
    f = r’C://Users/xx/Desktop/testimages’

  • This for loop goes through all the pictures in that folder and resize them to 640 X 480 if this is your desired output.

for file in os.listdir(f):
f_img = f+"/"+file
img =
img = img.resize((640,480))

We can do the same to lower the resolution.

This way, you can put your pictures on a laptop, work them through to become the correct format, and then present them to your ML to learn or test.

I hope this helps! Please ask if you have questions!

1 Like