esp32 calculate perceptual hash

amalakhov
Posts: 2
Joined: Wed May 25, 2022 8:30 am

esp32 calculate perceptual hash

Postby amalakhov » Wed May 25, 2022 8:49 am

Hello everyone !
An interesting task has appeared that needs to be implemented on the ESP 32 module.
There is an ip camera that looks at the TV on which the changing content is displayed
Sometimes, the program that displays this content freezes,
It is necessary to catch the fact that the image freezes and restart the computer using a relay module.
There is no access to the computer that outputs the content, there is only a picture from the ip camera.
I have an idea to get a picture to calculate a hash and compare 2 hashes
if the distance between them is short, then the picture does not change.
Since there is no way to send a picture from the camera to the server and calculate the hash there, everything needs to be done on the ESP itself

I will be grateful for ideas!

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 calculate perceptual hash

Postby chegewara » Wed May 25, 2022 12:43 pm

Did you try to capture 2 still images, store and compare?
I think you should start with this simple experiment to make sure you can capture at least 2 images with the same content before you even start to calculate hash.

amalakhov
Posts: 2
Joined: Wed May 25, 2022 8:30 am

Re: esp32 calculate perceptual hash

Postby amalakhov » Wed May 25, 2022 1:59 pm

Hello !

The camera I'm connecting to is AXIS model AXIS M3105-LVE Network Camera
it provides an opportunity to immediately receive a jpg example of an address at a dedicated address
http://10.178.0.101/axis-cgi/jpg/image. ... profile=S1
I get 1 minute intervals
  1.  
  2. http.begin(serverPath.c_str());
  3. int httpResponseCode = http.GET();
  4. if (httpResponseCode>0) {
  5.   Serial.print("HTTP Response code: ");
  6.   Serial.println(httpResponseCode);
  7.   String payload = http.getString();
  8.   Serial.println(payload);
  9. }
  10. else {
  11.   Serial.print("Error code: ");
  12.   Serial.println(httpResponseCode);
  13. }
  14.  

a2800276
Posts: 74
Joined: Sat Jan 23, 2016 1:59 pm

Re: esp32 calculate perceptual hash

Postby a2800276 » Wed May 25, 2022 4:37 pm

Just a heads up for googling this: a good hash should have a vastly different output for even slightly different inputs, so that's likely the opposite of what you're looking for. Instead "fingerprint" or "image similarity".


I doubt you would need to do anything fancy... I'd start with an extremely naive approach like xor'ing together two frames and summing the result. The value would be zero for identical data and should grow larger with dissimilarity. With any luck, that might be sufficient for your use case. Add a low pass filter to remove noise in the next step ...

These types of thing usually require a great deal of trial and error, you'll need to gather some real data and experiment.

Who is online

Users browsing this forum: gfvalvo and 72 guests