Reputation: 3032
I added a Growl notification to my python app which also uses OpenCV. The basic ones work fine:
image = open('image.png', 'rb').read()
growl.notify(
noteType = "Messages",
title = "Title",
description = "Description",
icon = image,
sticky = False,
priority = 1,
)
Where image is just a plain old PNG.
Next I am trying to make a custom icon where I am adding some text (just numbers) to that PNG. After some searching came up with this:
image = cv2.imread('image.png',0)
cv2.putText(image, text='40', org=(10,10),
fontFace= cv2.FONT_HERSHEY_DUPLEX, fontScale=0.2, color=(0,0,0),
thickness=2, lineType=cv2.LINE_AA)
called before the growl notification and I get this error:
File "/usr/local/lib/python3.9/site-packages/gntp/notifier.py", line 133, in notify
if icon:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I realize now that OpenCV converts this to some kind of array. How do I 'convert' this image back to a PNG etc. that growl is expecting. I am looking to NOT save the dynamic image each time but I can if that's the only way.
I am sure this is probably trivial but its not obvious to me with my beginners opencv and python knowledge. Also the solution does not need to be OpenCV based. It was just the first one I found.
Upvotes: 0
Views: 396
Reputation: 352
In this line of your growl.notify
call:
icon = image,
image
is expected to be an icon URL path.
However, it looks like the image
you create is actually an array, and Python doesn't know how to handle that when trying to see whether it is "true" or not here.
Upvotes: 0