Pynq for zcu104 display error

I use the pynq_v2.5 on ZCU104. I got the following error when I use opencv namedWindow and imshow function by c++. And I use ssh to control the ZCU104 by mobaxterm.

error message:
Unable to init server: Could not connect: Connection refused

(My Camera Feed:6862) : Gtk-Warning **: 13:09:38.837: cannot open display:

Does anyone know how to solve the error?

export DISPLAY=:0.0

I tried. But it doesn’t work.

Do you have a monitor connected to the DP port? Do you have a camera connected?

Yes. But it still has the same error.
Does the error result from the opencv version?
And what is the opencv lib path?
Can I install another version of opencv?

I don’t think that is the problem of the opencv version. For that error, I usually just put

export DISPLAY=:0.0

in the terminal, and then I can run program in terminal. If you are using Jupyter notebook, you need to put

!export DISPLAY=:0.0

in one of your notebook cells.

If you really want to explore opencv, you can find opencv version by

import cv2

to check its version (image v2.5 comes with 3.2). You can use the following to purge opencv

sudo apt-get autoremove -y libopencv* opencv-data python-opencv python3-opencv

Then use the cmake flow to build opencv from source. The removal and installation can take long time. I don’t recommend to you do that.

I am not using python. I use the opencv with c++.
Does the error result from the programming language I used?

How do you connect to your board? Through terminal, or SSH session? I think this might be just a normal system usage issue, not pynq-specific, so you can find something helpful on the web. e.g.