0

I got a python script supposed to load a video. My Pi set up in headless mode and I would like not to use any X server for displaying the video but instead having the video displayed to the hdmi port. When I execute the script I got this error:

(frame:739): Gtk-WARNING **: cannot open display:

Here's the test script:

import cv2

cap = cv2.VideoCapture('/media/Videos/Full.mp4')

speed = int(1000/23) #time in ms between two frames 23 is the number of fps

while True:
    ret,frame = cap.read()
    cv2.imshow('frame',frame)
    if cv2.waitKey(speed) & 0xFF ==ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

I installed these packages: raspberrypi.stackexchange.com/questions/43847/… to be able to execute the command startx, then I did export DISPLAY=:0 but still having the error message:

Gtk-WARNING **: cannot open display: :0.0

When I execute it on my laptop using pyCharm it works fine.

  • My bad, yes when I execute it on my laptop using pyCharm it works fine ! – Julien Blomme Sep 3 '18 at 8:49
  • I installed these packages: raspberrypi.stackexchange.com/questions/43847/… to be able to execute the command startx, then I did export DISPLAY=:0 but still having the error message: Gtk-WARNING **: cannot open display: :0.0 – Julien Blomme Sep 3 '18 at 9:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.