行人检测(3)——数据集

1. HOG+SVM使用的行人识别数据集

  • (1) INRIA Person Dataset(INRIA行人数据库)——可见光数据集,样本大小128*64

2. 红外行人数据集:KAIST Multispectral Pedestrain Detection Benchmark

  • github地址:https://github.com/SoonminHwang/rgbt-ped-detection 
  • 这个是多光谱图像:对齐的RGB+热像仪图像,640×480像素,手动注释所有人,骑自行车的人。注释包括边界框(如Caltech Pedestrian Dataset)之间的时间对应。
  • 许多人也在努力提高我们的基准行人检测性能,如:
  • 其他研究人员也采用多模态的方法,Also, another researches to employ multi-modality are presented.

    • Image-to-image translation [Arxiv '17]
    • Calibrations

3. 南方科技大学的红外数据集:SCUT_FIR_Pedestrian_Dataset

  • 执行之前,先运行一下starup,将所有的文件夹加入当前路径,才能方便的调用其他函数
  •  extract_img_anno_scut
  • dbExtract_scut 从数据库seq提取images,同时提取annotations到Txt files
  • 从pth的annatation里面load ground truth,即annatations文件夹要放在pth的路径下面
  • 然后将提取到的Images放在tDir的images文件夹下面
  • seq文件要放在pth的videos文件夹下面。
  • 然后运行 extract_img_anno_scut函数即可

得到的结果如下:

import cv2
import os
import sys
import glob
from PIL import Image

# VEDAI 图像存储位置
src_img_dir = "F:\\pedestrain detection benchmark\\SCUT_FIR_Pedestrian_Dataset-master\\train02\\images\\"
# VEDAI 图像的 ground truth 的 txt 文件存放位置
src_txt_dir = "F:\\pedestrain detection benchmark\\SCUT_FIR_Pedestrian_Dataset-master\\train02\\annotations\\"
# 所有的图像名称
img_Lists = glob.glob(src_img_dir + '/*.jpg')

img_basenames = []  # e.g. 100.jpg
for item in img_Lists:
    img_basenames.append(os.path.basename(item))

img_names = []  # e.g. 100
for item in img_basenames:
    temp1, temp2 = os.path.splitext(item)
    img_names.append(temp1)

for img in img_names:
    # open the crospronding txt file
    with open(src_txt_dir + '/' + img + '.txt',"r") as f:
        line_count = 0
        for line in f.readlines():
            if line_count == 0:
                line_count += 1
                continue
            line = line.strip('\n')
            spt = line.split(' ')
            cat_name = str(spt[0])
            x_min = int(spt[1])
            y_min = int(spt[2])
            bbox_wid = int(spt[3])
            bbox_hei = int(spt[4])

            if cat_name == "people" or cat_name == "walk person":
                if bbox_hei >= 10 and bbox_hei <= 30:
                    bbox_hei_new = 2*bbox_wid
                    if y_min+bbox_hei > 576:
                        y_min = 576-bbox_hei_new
                    else:
                        y_min = y_min-(bbox_hei_new-bbox_hei)/2

                    # 确保尺寸为1:2,扩充为原来的1.5倍
                    '''
                    bbox_wid_new = int(bbox_wid)
                    bbox_hei_new = int(2 * bbox_wid_new)
                    # 防止越界
                    if y_min >= 0.25*bbox_hei and y_min + bbox_hei_new< 576:
                        y_min = y_min - 0.25*bbox_hei
                    elif y_min < 0.25*bbox_hei:
                        y_min = 0
                    else:
                        y_min = 576 - bbox_hei_new

                    if x_min >= 0.25 * bbox_wid and x_min + bbox_wid_new < 720:
                        x_min = x_min - 0.25 * bbox_wid
                    elif y_min < 0.25 * bbox_wid:
                        x_min = 0
                    else:
                        x_min = 720 - bbox_wid_new
                    '''

                    # 读入图像
                    img_data = cv2.imread((src_img_dir + '/' + img + '.jpg'), cv2.IMREAD_UNCHANGED)
                    cropped = img_data[int(y_min):int(y_min+bbox_hei_new),int(x_min):int(x_min+bbox_wid)]  # y为高度,x为宽度
                    cv2.imwrite("G:\\scut_pedestrain_crop\\train\\" + "test_" + str(img) + ".jpg", cropped)
                    # cv2.rectangle(img_data, (x_min, y_min), (x_min+bbox_wid, y_min+bbox_hei), (255, 0, 0), 2)
                    # cv2.imshow('label', img_data)
                    # cv2.waitKey(0)


        '''
    # gt = open(src_txt_dir + '/gt_' + img + '.txt').read().splitlines()

    # write the region of image on xml file
    for img_each_label in gt:
        spt = img_each_label.split(' ')  # 这里如果txt里面是以逗号‘,’隔开的,那么就改为spt = img_each_label.split(',')。


        xml_file.write('        <name>' + str(spt[4]) + '</name>\n')
        xml_file.write('        <pose>Unspecified</pose>\n')
        xml_file.write('        <truncated>0</truncated>\n')
        xml_file.write('        <difficult>0</difficult>\n')
        xml_file.write('        <bndbox>\n')
        xml_file.write('            <xmin>' + str(spt[0]) + '</xmin>\n')
        xml_file.write('            <ymin>' + str(spt[1]) + '</ymin>\n')
        xml_file.write('            <xmax>' + str(spt[2]) + '</xmax>\n')
        xml_file.write('            <ymax>' + str(spt[3]) + '</ymax>\n')
        xml_file.write('        </bndbox>\n')
        xml_file.write('    </object>\n')


# 获取路径下的所有txt格式的文件名
def file_name(file_dir):
    File_Name=[]
    img_dir = "F:\\pedestrain detection benchmark\\SCUT_FIR_Pedestrian_Dataset-master\\train02\\images\\"
    for files in os.listdir(file_dir):
        if os.path.splitext(files)[1] == '.txt':
            img_dir += files[:-3]+"jpg"
            # File_Name.append(files)
            # 以原格式读入图像,原图像为灰度图
            img = cv2.imread(img_dir,cv2.IMREAD_UNCHANGED)
            # 需要读入标签信息



    return File_Name
txt_file_name=file_name("F:\\pedestrain detection benchmark\\SCUT_FIR_Pedestrian_Dataset-master\\train02\\annotations\\")
print("txt_file_name",txt_file_name)
        '''

 

 

  • 2
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
行人检测数据集 YOLO 是一种用于行人检测的图像数据集。它是基于 YOLO (You Only Look Once) 算法构建的,用于训练和评估计算机视觉模型以检测图像中的行人。 YOLO 是一种实时目标检测算法,它将图像划分为网格,并在每个网格中预测对象边界框和类别概率。因此,YOLO 可以在单个前向传递中检测和定位图像中的多个对象,包括行人行人检测数据集 YOLO 包含了大量带有标注的图像,这些图像中标注了行人的位置和边界框。这些标注信息是由人工标注员进行手动标注的,确保了数据集的准确性和可靠性。 使用行人检测数据集 YOLO,我们可以训练计算机视觉模型来自动检测图像中的行人。通过将这些图像输入到模型中进行训练,模型将学习到行人的特征和位置,并能够在新的未见图像中准确地检测和定位行人行人检测数据集 YOLO 对于行人检测算法的研究和开发非常有价值。准确的行人检测在许多应用中都非常重要,比如自动驾驶、视频监控和智能交通系统等。通过使用行人检测数据集 YOLO,我们可以改进和优化行人检测算法,提高其在实际场景中的性能和鲁棒性。 总之,行人检测数据集 YOLO 是一种用于训练和评估行人检测算法的图像数据集,可以帮助我们研究和开发准确、高效的行人检测算法,以应用于各种计算机视觉应用中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值