google-coral / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
340 stars 138 forks source link

How can I display the video feed from a USB camera connected to the Coral Dev Board while controlling it with WSL on Windows 10? #138

Open loiswen opened 6 months ago

loiswen commented 6 months ago

Description

Within the WSL environment accessing the Mendel environment on the Coral dev board, when using code python3 test.py access the camera, Code 1 encounters an error and cannot run successfully. Code 2 runs, and the camera indicator lights up, but the video information window does not display.

code1: `import cv2

capture = cv2.VideoCapture(1) while capture.isOpened(): retval, image = capture.read() cv2.imshow("Video", image) key = cv2.waitKey(1) if key == 32: break

capture.release() cv2.destroyAllWindows()`

error: `qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mendel/.local/lib/python3.7/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`

code2: `import cv2 import matplotlib.pyplot as plt

capture = cv2.VideoCapture(1)

while capture.isOpened(): retval, image = capture.read()

if retval:
    # 使用 Matplotlib 显示图像
    plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
    plt.show()

key = cv2.waitKey(1)

if key == 32:
    break

capture.release() cv2.destroyAllWindows()`

Click to expand! ### Issue Type _No response_ ### Operating System _No response_ ### Coral Device _No response_ ### Other Devices _No response_ ### Programming Language _No response_ ### Relevant Log Output ```shell code1: import cv2 capture = cv2.VideoCapture(1) while capture.isOpened(): retval, image = capture.read() cv2.imshow("Video", image) key = cv2.waitKey(1) if key == 32: break capture.release() cv2.destroyAllWindows() error: `qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mendel/.local/lib/python3.7/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` code2: import cv2 import matplotlib.pyplot as plt capture = cv2.VideoCapture(1) while capture.isOpened(): retval, image = capture.read() if retval: # 使用 Matplotlib 显示图像 plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) plt.show() key = cv2.waitKey(1) if key == 32: break capture.release() cv2.destroyAllWindows() ```