Reputation: 89
Cannot show image via openCV. ex) imshow() here is my source code.
def show_captured_image(path):
img = cv2.imread(path, 1)
resize_img = cv2.resize(img, (480, 320))
xy_axis = cv2.flip(resize_img, -1)
cv2.imshow("img", xy_axis)
cv2.moveWindow("img", 0, 0)
cv2.waitKey(0)
(img:2984): Gtk-WARNING **: cannot open display:
occurs in this line.
please tell me the solution!
Upvotes: 5
Views: 17614
Reputation: 109
in this case, you may have a headless raspberry pi, which has no display. please check it, if true, it means rasppi is not able to show anything. you must it must show the display on your computer from which you are ssh'ing. for that you must disable the access control on your computer.
Upvotes: 1
Reputation: 9
Are you ssh'ing to the raspberry pi from another computer? If so you will have to set your display to the ip of that computer your ssh'ing from.
DISPLAY (IP Address):0; export DISPLAY
Upvotes: 0
Reputation: 153
Try executing export DISPLAY=":0"
from your ssh session just before running the script. It should set your display to the one connected to the raspberry pi.
Upvotes: 11