Count pixels value in image

I'm now working on a project to count coins value (coin acceptor but with a camera). I heard that Arduino doesn't actually have any image processing libraries, so I'm wondering if it is even possible to do something like that with Arduino.

Because of the camera(I'm using esp32-camera) being fixed in one place above the surface where coins will be dropped, (one by one) then goes to the sorter, even the background will be the same every time so I want to count the sum of the pixels value in two diagonals (the pixels of the background will always have the same value the only different will be with the pixels of the coin) and compare the results with the ones I have with a small tolerance to recognize which coin is dropped, does anyone knows how can this be done? Something like this: (D3 and D4 are optional for greater precision)

penny.jpg

Arduinos are not useful in vision systems due to the low memory capacity.
Use other technics to identify the coins. There is the radius, the thickness, the weight etc.

Have you got access to the raw image, or only to JPEGs?

You can do some image processing on the ESP32, but if you have to decompress a JPEG, it will slow things down considerably.

Why don't you process the image with the ESP32?

Maybe you can access the picture in a bit map format,
or you could decode the JPG that the camera is able to emit.

Railroader:
Arduinos are not useful in vision systems due to the low memory capacity.
Use other technics to identify the coins. There is the radius, the thickness, the weight etc.

Actually this is a high school graduation project and I have to work with Arduino, it's not my choice

TheMemberFormerlyKnownAsAWOL:
Have you got access to the raw image, or only to JPEGs?

You can do some image processing on the ESP32, but if you have to decompress a JPEG, it will slow things down considerably.

To be honest I didn't try to get a raw image I don't even know how can I do it. Simply I want to convert the images taken in the real time to arrays that I can work with to count the pixels sum in the diagonals like in the photo

Whandall:
Why don't you process the image with the ESP32?

Maybe you can access the picture in a bit map format,
or you could decode the JPG that the camera is able to emit.

Oh I will try but because the result will be displayed in a small screen and I'm using a scale with the camera(for the fake coins) the Arduino is necessary anyway

You can always involve an Arduino telling "Hello World" but the image processing has to be done elseware as it looks like.
You can try to use a tooth pick and jump 6.18 meters high..

Railroader:
You can always involve an Arduino telling "Hello World" but the image processing has to be done elseware as it looks like.
You can try to use a tooth pick and jump 6.18 meters high..

Why are you so toxic man:), sorry for being rude, but I'm not trying to do any complicated image processing. Even Arduino can count the sum of pixels value as matrix at least i think so.

Then follow Your thoughts.

Hussein_01:
but I'm not trying to do any complicated image processing. Even Arduino can count the sum of pixels value as matrix at least i think so.

Maybe not complicated, but a PITA with 2k/8k RAM total.

How big is the bit map representation of one picture?

I have to work with Arduino, it's not my choice

Your assignment was either designed to be an extremely challenging project, the instructor has no idea what they are doing, or you chose the wrong type of project to do with the assigned Arduino.

However, the Arduino compatible PIXY camera can analyze an image and report the size and color of a small number of blobs. It might be useful to recognize coins.

With the CIF (352*288) size and grayscale (presumably one byte per pixel) format, each frame should be about 100kB, which may be manageable with an ESP32.

Hussein_01:
Why are you so toxic man:),

He's not. He's just telling how it is. A normal Arduino is NOT suitable for image processing. You have 2 kB (Uno/Nano) or 8 kB in memory available. Best you can do is a very low resolution image (even in gray scale 128*64 is already taking up all your available memory) and processing... well, at 16 MHz that's going to take a while. Better close that coin slot while working on the previous one so the user doesn't put in the coins too fast.

Indeed you need an ESP32 or Teensy or something like that. Arguably part of the greater Arduino ecosystem, use that point to your advantage

Even so I doubt it's feasible to reliably identify coins this way (not just the value, but also that it's an actual coin to begin with), but that's a whole different issue.

What exactly are the requirements of the project? Is a specific type arduino required, does the coin acceptor have to use the esp32-camera, etc?

You clearly do not have the memory in an arduino to store an image, could you have some of the processing done on the esp32, maybe to reduce the image resolution, represent the image as a bitmapped black & white image with one bit per pixel, etc? If you can send a bitmapped image to the arduino, it could try to detect the top and bottom of the coin, as well as the widest part of the coin, without actually having to store any of the image data. Using the esp32 to detect the coin diameter, color, etc, and send that information to the arduino would probably be the best route.

david_2018:
What exactly are the requirements of the project? Is a specific type arduino required, does the coin acceptor have to use the esp32-camera, etc?

Maybe I wasn't that clear, yes, I can do some of the processing on the esp32 and send the results to the arduino, indeed after reading your answers I think this is the only possible solution.
PS. the requirements are basically to have an arduino in the project. I can add whatever I want but arduino is necessary so the answer is no, I don't have to use the esp32-camera in fact I can use any camera I want but I chose the esp because this is what I have now if You have any other suggestions for better cameras please tell me

jremington:
Your assignment was either designed to be an extremely challenging project, the instructor has no idea what they are doing, or you chose the wrong type of project to do with the assigned Arduino.

dap I'm in a high school of electrical engineering but my instructor in this assignment is totally lost and like you said he has no idea what I'm dealing with

You have any other suggestions for better cameras please tell me

PIXY.

According to You, what properties, what qualities, does such a camera need to have?

Is the use of a camera for the coin acceptor required for the project? Are you required to design your own coin acceptor?

"I'm in a high school of electrical engineering but my instructor in this assignment is totally lost and like you said he has no idea what I'm dealing with"

That seems to tell me that you chose this particular project and not the instructor. You might have the coin roll down a slot and have the coin top edge pass a break beam setup which would tell the height of the cons to tell them apart. That might be in the realm of what an arduino might do.