На WinPC я установил Visual Studio Code вместе с расширением Remote-SSH, которое позволяет мне писать и выполнить простое "
Код: Выделить всё
Hello World
Однако я написал скрипт Python camera.py, используя cv2 пакет, открывающий окно просмотра в реальном времени с камеры, которое можно закрыть нажатием клавиши Esc:
Код: Выделить всё
import cv2
# Open the camera
cap = cv2.VideoCapture(0)
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if not ret:
break
# Display the resulting frame
cv2.imshow('Live Camera View', frame)
# Break the loop on 'Esc' key press
if cv2.waitKey(1) & 0xFF == 27: # 27 is the ASCII code for Esc
break
# Release the camera and close all OpenCV windows
cap.release()
cv2.destroyAllWindows()
Когда я выполняю этот сценарий локально на RPi, он работает отлично. Однако когда я запускаю сценарий через удаленный SSH с WinPC, он терпит неудачу. Ниже приведено сообщение об ошибке:
Код: Выделить всё
(.venv) master@raspberrypi:~/Desktop/ObjectDetection $ python camera.py
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/master/Desktop/ObjectDetection/.venv/lib/python3.11/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
Aborted
(.venv) master@raspberrypi:~/Desktop/ObjectDetection $

Дистрибутивы Python:
Ниже приведен список всех дистрибутивов Python, установленных на RPi.
Код: Выделить всё
Package Version
--------------------- -----------
absl-py 2.1.0
astunparse 1.6.3
certifi 2024.8.30
charset-normalizer 3.4.0
colorama 0.4.6
contourpy 1.3.0
cycler 0.12.1
flatbuffers 24.3.25
fonttools 4.54.1
gast 0.6.0
google-pasta 0.2.0
h5py 3.12.1
idna 3.10
kiwisolver 1.4.7
libclang 18.1.1
matplotlib 3.9.2
ml-dtypes 0.4.1
numpy 2.1.2
opencv-camera 2023.1.7
opencv-contrib-python 4.10.0.84
opencv-python 4.10.0.84
opt_einsum 3.4.0
packaging 24.1
pillow 11.0.0
pip 23.0.1
protobuf 4.25.5
pyparsing 3.2.0
python-dateutil 2.9.0.post0
PyYAML 6.0.2
remote-plot 1.2.1
requests 2.32.3
setuptools 66.1.1
six 1.16.0
termcolor 2.5.0
tk 0.1.0
typing_extensions 4.12.2
urllib3 2.2.3
wheel 0.44.0

Подробнее здесь: https://stackoverflow.com/questions/791 ... spberry-pi