While running the following shell command (via pyhtonanywhere bash):
cv2.imshow('Mask',mask)
I get the error message:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/teki/.virtualenvs/bup/lib/python3.9/site-packages/cv2/qt/plugins" ev
en though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
As suggested in this forum (see example) I unistall opencv-python and installed then opencv-python-headless, message raised the gollowing error message:
pythonanywhete cv2.error: OpenCV(4.6.0) /io/opencv/modules/highgui/src/window.cpp:1267: error: (-2:Unspecified error) The function is not implemented. R ebuild 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 'cvShowImage'
Comments on this forum suggest to uninstall opencv-python-headless and to install opencv-python...which brings me back to my initial problem.
Any tip on this problem would be highly appreciated.
PS- in case it helps, here's the full script:
# import required libraries
import cv2
import numpy as np
# read input image
img = cv2.imread('car.jpg')
# Convert BGR to HSV
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# define range of blue color in HSV
lower_yellow = np.array([15,50,180])
upper_yellow = np.array([40,255,255])
# Create a mask. Threshold the HSV image to get only yellow colors
mask = cv2.inRange(hsv, lower_yellow, upper_yellow)
# Bitwise-AND mask and original image
result = cv2.bitwise_and(img,img, mask= mask)
# display the mask and masked image
cv2.imshow('Mask',mask) #my script runs well till this line.
cv2.waitKey(0)
cv2.imshow('Masked Image',result)
cv2.waitKey(0)
cv2.destroyAllWindows()