gui+opencv实现视频行人识别

本文介绍如何结合GUI界面和OpenCV库来实现视频中的行人识别。通过搭建用户界面,用户可以实时预览并处理视频流,运用OpenCV的行人检测算法,如Haar级联分类器,来标记和跟踪画面中的行人。该方法对于智能监控和安全应用具有重要意义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

from tkinter import *
import cv2
from PIL import Image, ImageTk
from imutils.object_detection import non_max_suppression
from imutils import paths
import numpy as np
import argparse
import imutils
import cv2


hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())


def video_loop():
    success, img = camera.read()  # 从摄像头读取照片
    if success:
        image = img
        print(type(image))
        image = imutils.resize(image, width=min(400, image.shape[1]))
        print(type(image))

        # 检测图像中的人
        (rects, weights) = hog.detectMultiScale(image, winStride=(4, 4),
                                                padding=(8, 8), scale=1.05)
        print(hog.detectMultiScale(image, winStride=(4, 4),
                                   padding=(8, 8), scale=1.05))

        # 绘制原始边界框
        for (x, y, w, h) in rects:
            cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)

       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值