You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I have a C++ program for a Hikvision industrial camera. It calls the XOpenDisplay function of the X11 library to start a window and display the video stream of the camera. After compiling it, using ./Display or /bin/bash -c "/opt/MVS/Samples/aarch64/Display/Display" in the terminal can both start the window and see the video stream.
Next, I encapsulated it using the following Python code to provide an API for access. After starting the FastAPI service through the following command /usr/bin/python /root/main.py in the terminal, accessing this API can also normally start the window and see the video stream.
However, when I assign the task of starting the FastAPI web service to supervisor. After starting the web service normally, calling the API service prompts please run with screen environment. It can be found that an execution error occurs on the line of code dpy = XOpenDisplay(NIL);, which causes it to output the prompt.
Finally, what should I do to enable the Python application managed by supervisor to call the C++ compiled program normally using subprocess?
Attempts made:
Add environment variables, such as DISPLAY=:0.
Output the value of the current environment variable DISPLAY as :0 inside Dispaly.cpp to confirm that the environment variable is correct.
Ensure that the code for starting the Python script is a shell script and use the supervisor configuration of command=/bin/bash -c "/usr/bin/python /path/to/my/python/main.py", but it still doesn't work.
Use xhost + to allow all the user can connect to X server.
Operating system environment:
First, I have a C++ program for a Hikvision industrial camera. It calls the XOpenDisplay function of the X11 library to start a window and display the video stream of the camera. After compiling it, using
./Display
or/bin/bash -c "/opt/MVS/Samples/aarch64/Display/Display"
in the terminal can both start the window and see the video stream.Next, I encapsulated it using the following Python code to provide an API for access. After starting the FastAPI service through the following command
/usr/bin/python /root/main.py
in the terminal, accessing this API can also normally start the window and see the video stream.However, when I assign the task of starting the FastAPI web service to supervisor. After starting the web service normally, calling the API service prompts
please run with screen environment
. It can be found that an execution error occurs on the line of codedpy = XOpenDisplay(NIL);
, which causes it to output the prompt.Finally, what should I do to enable the Python application managed by supervisor to call the C++ compiled program normally using subprocess?
Attempts made:
Add environment variables, such as
DISPLAY=:0
.Output the value of the current environment variable
DISPLAY
as:0
inside Dispaly.cpp to confirm that the environment variable is correct.Ensure that the code for starting the Python script is a shell script and use the supervisor configuration of
command=/bin/bash -c "/usr/bin/python /path/to/my/python/main.py"
, but it still doesn't work.Use
xhost +
to allow all the user can connect to X server.The following is the FastAPI web code(main.py).
The following is the supervisor configuration.
The following is the Display C++ codes.
The text was updated successfully, but these errors were encountered: