2

I am trying to use the OpenCV imshow GUI from inside the docker container. I used the following to start the container I using nvidia-docker because, the container contains GPU version of Tensorflow

xhost +
nvidia-docker run \
--rm \
--name tf_keras \
--link mongodb_database:data_mongo \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $1:/abhijit_home \
-p 8888:8888 -p 6006:6006 \
tensorflow_gpu_v1

When I try to display am image using OpenCV I am just getting a blank screen. enter image description here

The Image I am trying to display is displayed using matplotlib. How can I correct this? Thanks

Abhijit Balaji
  • 1,870
  • 4
  • 17
  • 40
  • Jupyter notebooks have known issues displaying images with `cv2.imshow()`. The short of it is, don't use it inside a Jupyter notebook. Use another plotting library to show the image in-line. Alternatively, you can save the image and then display it inline with HTML or other Jupyter notebook features. However, there is possible workarounds using `cv2.startWindowThread()`. See [here](https://stackoverflow.com/a/29584090/5087436). – alkasm Nov 21 '18 at 19:52
  • Were you able to resolve this? I am having the same issue with OpenCV and Docker. – tgonzalez89 Mar 20 '20 at 21:27
  • Do you found any solution on this? I need to display a lot of image in line and cannot save it because performance – cflorenciav Jul 21 '20 at 00:13

1 Answers1

-2

This is probably related to matplotlib. Try

import matplotlib
matplotlib.use('Agg')
Sam Mason
  • 15,216
  • 1
  • 41
  • 60
susan
  • 1