How to display images/movies from Docker

Asked 2 years ago, Updated 2 years ago, 82 views

After building Opnecv with the Docker container up,

import numpy as np
import cv2

cap=cv2.VideoCapture('video_name.mp4')
while(cap.isOpened()):

 ret, frame=cap.read()

      gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

      cv2.imshow('frame',gray)
      if cv2.waitKey(1)&0xFF==ord('q'):
          break

cap.release()
cv2.destroyAllWindows()

and
(frame:309):Gtk-WARNING**:cannot open display:
Error similar to

I put ffmpeg in when building with opencv, so I think I can load the video, but how do I display the images and videos from docker?

python ubuntu opencv docker

2022-09-30 12:02

1 Answers

The Docker does not have a GUI installed, so cannot open display appears.Installing the X Window System is one way.

Another way is to install the Jupiter Notebook and run cv2 on the Jupiter notebook.This one is easier.

Official Manual
https://docs.opencv.org/3.1.0/dc/d2e/tutorial_py_image_display.html
Japanese Reference
https://qiita.com/fukuit/items/7fe137ac07654556cf87


2022-09-30 12:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.