YOLO v5 Series - FFmpeg & (HTML5 + FLV.js ) & Python YOLOv5s Integrating

在这里插入图片描述
Obtain IPC List

(alpha) D:\anaconda3\envs\alpha\main5>wmic path Win32_PnPEntity where "Service='usbvideo'" get Name /value | findstr "Name="
Name=Integrated Camera
Name=HD USB Camera

Obtain IPC Resolution

(alpha) D:\anaconda3\envs\alpha\main5>ffprobe -loglevel quiet -f dshow -show_streams -i video="Integrated Camera" | findstr "coded_width | coded_height"
coded_width=1280
coded_height=720

(alpha) D:\anaconda3\envs\alpha\main5>ffprobe -loglevel quiet -f dshow -show_streams -i video="HD USB Camera" | findstr "coded_width | coded_height"
coded_width=3840
coded_height=2880

Checking

(alpha) D:\anaconda3\envs\alpha\main5>check
Input="Integrated Camera" Resolution=1280x720 Framerate=30
(alpha) D:\anaconda3\envs\alpha\main5>check "Integrated Camera" 800x600 25
Input="Integrated Camera" Resolution=800x600 Framerate=25
(alpha) D:\anaconda3\envs\alpha\main5>check "HD USB Camera" 1280x720 20
Input="HD USB Camera" Resolution=1280x720 Framerate=20

在这里插入图片描述
letterbox & scale_coords

if True:
    rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)  # YOLO需要RGB输入

    if True:
        stride = int(model.stride.max().item())
        img, ratio, pad = letterbox(rgb_frame, img_size, stride=stride)
        img = img.transpose(2, 0, 1)  # HWC to CHW
        img = torch.from_numpy(img).to(device).float()
        img /= 255.0  # 归一化
        if img.ndimension() == 3: img = img.unsqueeze(0)

        with torch.no_grad():
            pred = model(img)[0]
        # NMS
        pred = non_max_suppression(pred, conf_thres, iou_thres)

        if True:
            for det in pred:
                original_img = frame.copy()
                if len(det):
                    det[:, :4] = scale_coords(img.shape[:2], det[:, :4], rgb_frame.shape[:2], ratio_pad=(ratio, pad)).round()

                    for *xyxy, conf, cls in det:
                        label = f'{model.names[int(cls)]} {conf:.2f}'
                        plot_one_box(xyxy, original_img, label = label, color = colors[int(cls)])
                rgb_frame = original_img

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值