OpenCV on Jupyter Lab notebook on Nano

Does anyone ever try to run cv2.imshow(‘label’,‘filename’) on Jupyter on the Nano?
I am running the headless jupyter lab over wifi:

192.168.1.191:8888

I am getting kernel resets every time I run this code.

import cv2
image = cv2.imread('my_image.png')
cv2.startWindowThread()
cv2.imshow('face',image)
cv2.waitKey(0)
cv2.destroyAllWindows()

I have read exhaustively about this on stackoverflow but it seems like nothing solves it.
I have also restarted jupyter lab a few times to no avail.

Any insights are appreciated.

I think imshow only works on x11, but I don’t use Jupyter much so don’t quote me on that.

You can apparently use plt.imshow instead.

You can also proably use this to convert bgr to rgb instead of the numpy slicing. Not sure which would be faster, but you can test it.

Anyway, I wouldn’t expect any of it to perform very well in a browser and with the conversion in software, but ymmv. You migth have a look at how the JetBot notebooks display images.

You need to use ipywidgets to show an image in jupyter:

https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Basics.html

Just use the “image” widget. Alternatively matplotlib should also work, like @mdegans said.

Hey thanks guys.
I am testing now and will let you know what works.