Closed johnholman closed 2 years ago
@Tobias-Fischer
I'm not even sure that cv.samples.findFile("jurassic_park.png")
works. It doesn't on linux. We don't ship the examples.
It does if you put the image file in the same directory as the script though. For example it works on windows and on the pi (linux-aarch64) if you install opencv-python with pip rather than the conda-forge package.
But apologise for the unnecessary findFile() etc! Simplified version below produces the same error:
import cv2 as cv img = cv.imread("jurassic_park.png") print(f'image size {img.shape}') cv.imshow("Display window", img) k = cv.waitKey(0)
I'm sorry to ask. Can you provide the correctly named image. This is just to make it easier for others to help you
Do you have the equivalent of these packages installed
https://github.com/conda-forge/opencv-feedstock/blob/main/recipe/yum_requirements.txt
On the image - don't know what copyright situation is for the jurassic one but any image will do - I'll look for something and attach in a moment.
On the mesa-libGL requirement - if that is a conda package I don't think I have it installed. I just tried running "mamba install mesa-libgl" and it said nothing provides it. Can you advise on the right incantation - I can see lots of different related packages with "mamba search mesa-libgl"
Revised example with image attached:
import cv2 as cv img = cv.imread("bosch_shredder.jpg") print(f'image size {img.shape}') cv.imshow("Display window", img) k = cv.waitKey(0)
It should be a package you install with apt or yum.
It provides OpenGL by the operating system
apt list mesa --installed shows
libegl-mesa0/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed,automatic] libgl1-mesa-dri/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed] libglapi-mesa/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed,automatic] libgles2-mesa/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed] libglx-mesa0/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed,automatic] mesa-va-drivers/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed,automatic] mesa-vdpau-drivers/stable,now 20.3.5-1+rpt3+rpi1 arm64 [installed,automatic]
Does that look sufficient? (Maybe this is is a raspberry pi specific thing?)
I think qt5 is working on this platform. After also installing pyqt a simple qt application works:
from PyQt5.QtWidgets import QApplication, QWidget import sys app = QApplication(sys.argv) window = QWidget() window.show() app.exec()
I can also use imshow() from matplotlib using the qt backend:
import cv2 as cv import matplotlib.pyplot as plt import matplotlib as mpl
img = cv.imread("bosch_shredder.jpg") img = cv.cvtColor(img, cv.COLOR_BGR2RGB) mpl.use('QtAgg') plt.imshow(img) plt.show()
but calling imshow() from opencv still fails.
NOTE (added to first comment as well)
Even simpler test which doesn't require a test image:
import cv2 cv2.waitKey(0)
which produces similar error:
cv2.error: OpenCV(4.5.5) /home/conda/feedstock_root/build_artifacts/libopencv_1647515468288/work/modules/highgui/src/window.cpp:1334: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
Looks like WITH_QT is being set to 0 on these builds: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=476367&view=logs&j=696704cc-6fef-57a3-ea36-f27779b8cd5e&t=ed2e6513-0a06-519f-13f9-1e5619642f2a&l=2318
Could be due to target_platform "linux-aarch64" failing this check https://github.com/conda-forge/opencv-feedstock/blob/main/recipe/build.sh#L26 and getting disabled.
Try installing in an hour or two.
Many thanks - this works now
Thank you for helping debug so much!
Thanks both - my bad for missing to change the build.sh
as well!
Solution to issue cannot be found in the documentation.
Issue
Trying to use opencv on 8GB raspberry pi 4 running PIOS 64 bit (Debian bullseye). Installed using mamba-forge as
Running simple test script that reads an image file and then attempts to display it with imshow():
Result:
I hoped this would work as https://github.com/conda-forge/opencv-feedstock/pull/301 suggests that qt support has been merged but perhaps I misunderstand. I did notice that qt was not installed as a dependency hence the explicit installation.
NOTE (added next day) Still simpler test which doesn't require a test image is
import cv2 cv2.waitKey(0)
which produces similar error:
cv2.error: OpenCV(4.5.5) /home/conda/feedstock_root/build_artifacts/libopencv_1647515468288/work/modules/highgui/src/window.cpp:1334: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
Installed packages
Environment info