采集卡bug修复

This commit is contained in:
Ray
2025-10-29 15:37:48 +08:00
parent 3a8873acc2
commit f0fc28d827
3 changed files with 33 additions and 6 deletions

View File

@@ -43,10 +43,18 @@ import cv2
import threading
import warnings
# 抑制OpenCV的警告信息
# 抑制OpenCV的警告信息(兼容不同版本)
import os
os.environ['OPENCV_LOG_LEVEL'] = 'ERROR'
cv2.setLogLevel(cv2.LOG_LEVEL_ERROR)
try:
if hasattr(cv2, 'setLogLevel'):
# OpenCV 4.x
if hasattr(cv2, 'LOG_LEVEL_ERROR'):
cv2.setLogLevel(cv2.LOG_LEVEL_ERROR)
elif hasattr(cv2, 'utils'):
cv2.utils.setLogLevel(0) # 0=ERROR级别
except Exception:
pass # 如果设置失败,继续执行
class GetImage:
def __init__(self, cam_index=0, width=1920, height=1080):