Comparing image similarity using Python in Code node

Describe the problem/error/question

In lieu of our security camera system being able to send Slack notifications, I am looking to compare the level of similarity between two camera still images taken at different times to determine if there is a change/obstruction and send a Slack message if so.

While I have tested using Python-OpenCV in an IDE to compare two images and determine the level of similarity between them as per this guide, I’m having a little bit of difficulty importing this to the Code node in n8n, as I haven’t successfully been able to get the data from the previous nodes into the Code node as I have been able to using Javascript.

Can anyone offer me any guidance? I’ve included a working Python script from the IDE to be modified.

Information on your n8n setup

  • n8n version: 1.33.1
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker Compose
  • Operating system: Ubuntu 22.04.4

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @ThomasLu_EarthDaily!

We actually have a very handy guide for gettng the output of other nodes in a code node. Output of other nodes | n8n Docs

I think that might help you move in the right direction. Let me know if you have any questions!

Happy building!

1 Like

Thank you!!

That was a point in the right direction… albeit it seems I needed to convert the image into Base64 and then into an OpenCV image.

2 Likes

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