Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通过推流的方式集成Hydra #7

Open
zhangjinnan opened this issue Nov 2, 2024 · 0 comments
Open

通过推流的方式集成Hydra #7

zhangjinnan opened this issue Nov 2, 2024 · 0 comments

Comments

@zhangjinnan
Copy link
Contributor

使用Yawcam将本地摄像头推流成网络摄像头

from XEdu.hub import Workflow as wf
import cv2
import numpy as np
import urllib.request

# 初始化手势检测模型
det = wf(task='det_hand')  # 实例化检测模型
hand = wf(task='pose_hand21')  # 实例化关键点检测模型

url = 'http://127.0.0.1:8888/out.jpg'  # Yawcam 的默认 JPEG URL(注意需要确保该 URL 有效)

while True:
    # 从 URL 获取图像数据
    img_resp = urllib.request.urlopen(url)
    img_np = np.array(bytearray(img_resp.read()), dtype=np.uint8)
    frame = cv2.imdecode(img_np, -1)

    # 手势检测
    bboxs = det.inference(data=frame, thr=0.3)
    img = frame

    for i in bboxs:
        keypoints, img = hand.inference(data=frame, img_type='cv2', bbox=i)

    # 显示结果
    cv2.imshow('video', img)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant