Measurement with Camera

Hi,

I am thinking about starting a project using cameras. I have a general idea for my set up, and I know that the function is possible because these products are sold on the market, however I wanted to know if there were any specific components you would recommend for a novice trying to accomplish this.

I want to measure a small object - lets say a pencil - length and width using a camera. I would have a glass table with a light underneath, and would set it on the table, and it would measure all the points I have programmed it to measure.

Is this something that is doable with Arduino? If so, what are going to be the obstacles for a novice such as myself?

Thanks!

Genuine Arduinos are microcontrollers, with very little memory, and are totally unsuitable for image processing.

Some other types microprocessors can be programmed using the Arduino IDE, and it might be possible to do what you want. You would have to write the code, and that might be a challenge.

A laptop or desktop would be a much better choice, and there is plenty of free image processing software (ImageJ, for example).

You would need enough pixels in your image to account for the length and width of the frame you will capture, and the pixels have to be small enough to give you good resolution at the finest resolution of your desired measurements. I'd just guess that your'd want not fewer than 5 pixels per minimum unit of measure.

I've never tried such a thing, but consider this. If your measuring surface had a color gradient across it, perhaps you could analyze pixel color to determine distance. You could build a color print out with a defined gradient on it, specifying each pixel by three color values. The camera might not see them quite as the printer prints them, so yo would have to work quite hard to register color between your printer and the camera. Just some random thoughts.

I would recommend having a look at the ESP32Cam modules, they can be programmed with the Arduino IDE and are very cheap.
The camera goes up to a resolution of 1600x1200 although you will find if capturing the image as RGB you are limited to 1280x1024 as you are limited by the available memory to store all the data.

If you search eBay for “esp32cam-mb” you can get one along with a motherboard for under £10 and this makes programming them easier as they do not have USB Serial built in (note I have found I have to reduce the serial port speed to get mine to work).

If you have a look at my sketch Here: ESP32Cam demo sketch
it shows how you can get raw data from the camera image and from this you could create your code to extract information from the image. The data in my example is in RGB format but you can capture Greyscale images which would probably simplify your task ?
Your code could be as simple as just looking from each side of the image for a sudden high change in brightness and measuring the distance between them.

The ESP32 is surprisingly powerful so should be able to do what you require although another option would be to get the camera to send data over the serial port in to Processing and do the image manipulation on the PC.
For lots of insparation/examples of working with images in Processing have a look at this Youtube channel: Coding Train

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.