Skip to content

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

@zhangjinnan

Description

@zhangjinnan

使用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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions