The right way to do digits recognition

Hi,
Question/Issue:
What kind of photos are better to use as data set and label the digits on LCD?
The large photo with everything on the table or the smaller photo with the LCD display only? (see below images)

On this project, I’ve tried to upload very large photos and label the digits in the display. So the square region in the entire photo were very small. After the ML process, the results is not useable. (See how I label the numbers in this image)

Screen Shot 2023-02-22 at 3.23.58 PM

Project ID: 188804

Context/Use case:
I would like to take a photo of the figures(digits) from a blood pressure machine and then use ML to get readings and send the readings to Google sheets.

Stonez56

Hello @stonez56,

The easiest for the ML model would definitely be the second picture. However, this will probably require some pre-processing on the image size to detect the region of interest.
Alternatively, you can “force” the camera to always have a similar view by creating a setup around the blood pressure machine.

I can see in your dataset that some of the samples are not labelled. Make sure to disable them or label them before training your model otherwise, the model will use these pictures to train the “background” class, which will contain your digits. Thus decreasing a lot your model performances.

Best,

Louis

Hi Louis,
I just completed the labeling!

  1. The best one to use is → you mean the “LCD only” pictures right?
  2. “probably require some pre-processing on the image size to detect the region of interest.” Do you have an example for me to reference.

P.S:My first ML failed and I deleted all the data and upload the data set again and done the labeling…
Hope to get it right next time!

Looks like this is not going to work for me…see the result:

Thanks for your quick reply…
Stonez5

Hello @stonez56,

  1. The best one to use is → you mean the “LCD only” pictures right?

Correct

  1. “probably require some pre-processing on the image size to detect the region of interest.” Do you have an example for me to reference.

I think I remember seeing a video on the OpenMV cam that was doing something similar.

Also, I noticed that your dataset is probably not labelled correctly.
e.g. scene02821_result sample (same as your third picture on your post) is missing label 9, 8 and probably 7 and 3.
If the labels are not set, the model will learn as being a background class.

I hope that helps,

Best,

Louis

Hi Louis,
Thanks for these information.
I will try to prepare the dataset and label the figures and do it again.

Best regards,
Stonez56

Hi Lous,
After re-cropping and re-labeling the images, the result still not very good.
How can I improve the ML accuracy? Do I need more images for ML?

Project ID: 188804

Here are the images I uploaded and labeled as well as the ML results for your reference.


Hello @stonez56,

I remember @yodaimpulse did a webinar on the digit recognition topic some times ago:

You might want to have a look.

Best,

Louis

Thanks! I’ve watched the video, but it didn’t help me much.
This video see the numbers one at a time.

I have few more questions:

  • Is it possible to recognize 3 digits at a time?
    Like the images I provide above? (Need to see it as 127 at a time)
  • Is labeling 3 digits in a image a right way to label?
  • What ML model is best for my purpose?

Thanks a lot for your kind help.

Stonez56

@stonez56

Are you using image recognition or object detection to solve the problem? To get some ideas, you can always look at similar problems like:

Maybe try object detection and MobileNetV2 SSD FPN.

I noticed this TinyML Digital Counter for Electric Metering System on the Edge Impulse Expert Network page. Is this what you are looking for?

@jorei Thanks for those tips! I will keep trying!

Hi there @Joeri and @louis, I read through this discussion and went through some of the suggested links for the creation of a pre-processing block to define a region of interest. I have a similar issue as @stonez56 that I am struggling with, wherein I have to say if the water is on/off (not so much to read the digits). My initial model was only giving me 66% accuracy. Therefore, I needed to reduce the noise and focus and crop the image to only to the digits. I have tried the examples from GitHub - edgeimpulse/example-custom-processing-block-python: Example of a custom processing block in Python. But I am looking for an example to crop images (or to define roi?).
In OpenCV I know this is possible. Can we do the same in Edge Impulse and if so do you have an example for it? Thanks for your time in advance.

[water identified]
water

[no water]
no water

[Roi example]

[In OpenCV we could do something like this]

[What code can we write to return cropped image?]

My project id is: 194971

@stonez56 What images you use to train depends on your end goal, aka your production model. If you want to build a generic blood pressure reader then the 1st photo is better. For example, YOLOv7 uses image collages for training because it can help improve the performance of the object detection model. The idea behind image collages is to combine multiple smaller images into a larger single image, which can then be used as input to the model. By doing this, the model is able to learn to detect objects at different scales and locations within a single image. This can help improve the model’s ability to detect small objects, as well as objects that are partially occluded or appear at the edge of an image.

If you are designing a Model for a single blood pressure machine where you can also control the camera then I agree with Louis, that the 2nd photo is better.

@MMarcial Thanks for the reply! A generic blood pressure reader is what I had in mind. I had labeling the data in few different ways and trained few times, but non of them worked.

Can you suggest a good tutorial using YOLOv7 with EdgeImpulse for Blood pressure machine digits readings?

Stonez56

You don’t necessarily need to use YOLO but if so try this.

You can perform custom training data augmentation via a custom processing block.

This image shows how your original JPGs get combined in various ways to create a new training image:

Hi @stonez56 , Came across this blog that might be of value to you … Recognizing digits with OpenCV and Python - PyImageSearch

1 Like

Thanks for the link, but I would like to know how to use Edge Impulse to do this task.
Still can’t figure out how… :thinking:

Need more detailed specifics. Where are you getting stuck?

Thats exactly what I did -

3 Likes

This is exactly what I had in mind.
Please share your method with us, thank you!