報(bào)錯(cuò)內(nèi)容:
The function is not implemented. Rebuild the library with Windows,
GTK+ 2.x or Cocoa support.
版本出錯(cuò)應(yīng)該是不太可能的,于是我試著安裝一下OpenCV的拓展開(kāi)發(fā)包也就是.
- opencv-contrib
- 沒(méi)想到,折騰好久的問(wèn)題,最后一行命令解決問(wèn)題了
pip install --user opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn
總結(jié):遇到這個(gè)報(bào)錯(cuò),請(qǐng)執(zhí)行以上命令
附上測(cè)試代碼文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-513240.html
import cv2
import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
hands = mp_hands.Hands(
static_image_mode=False,
max_num_hands=2,
min_detection_confidence=0.75,
min_tracking_confidence=0.75)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = cv2.flip(frame, 1)
results = hands.process(frame)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
if results.multi_handedness:
for hand_label in results.multi_handedness:
print(hand_label)
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_landmarks:
print('hand_landmarks:', hand_landmarks)
mp_drawing.draw_landmarks(
frame, hand_landmarks, mp_hands.HAND_CONNECTIONS)
cv2.imshow('MediaPipe Hands', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
注意,直接copy官網(wǎng)的代碼測(cè)試會(huì)報(bào)錯(cuò),別問(wèn)我是怎么知道的。報(bào)錯(cuò)是API的使用方式變了。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-513240.html
到了這里,關(guān)于OpenCV使用cv2.imshow()報(bào)錯(cuò)的解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!