黑马程序员技术交流社区

标题: 【上海校区】python ubuntu dlib 人脸识别11-物体追踪 [打印本页]

作者: 梦缠绕的时候    时间: 2018-12-17 09:33
标题: 【上海校区】python ubuntu dlib 人脸识别11-物体追踪
1. 从文件夹中读取图片文件,这步可以结合ffmpeg来完成,将视频流切图命令为(但需要再写个脚本定期清理旧图片,比如10分钟前):

ffmpeg -i myfile.avi -r 1000 -f image2 image-%07d.png
2.读取图片并圈出识别出的物体:


import os
import glob

import dlib

# Path to the video frames
video_folder = os.path.join("./video_frames")

# Create the correlation tracker - the object needs to be initialized
# before it can be used
tracker = dlib.correlation_tracker()

win = dlib.image_window()
# We will track the frames as we load them off of disk
for k, f in enumerate(sorted(glob.glob(os.path.join(video_folder, "*.jpg")))):
    print("Processing Frame {}".format(k))
    img = dlib.load_rgb_image(f)

    # We need to initialize the tracker on the first frame
    if k == 0:
        # Start a track on the juice box. If you look at the first frame you
        # will see that the juice box is contained within the bounding
        # box (74, 67, 112, 153).
        tracker.start_track(img, dlib.rectangle(74, 67, 112, 153))
    else:
        # Else we just attempt to track from the previous frame
        tracker.update(img)

    win.clear_overlay()
    win.set_image(img)
    win.add_overlay(tracker.get_position())
    dlib.hit_enter_to_continue()

---------------------
作者:_iorilan
来源:CSDN
原文:https://blog.csdn.net/lan_liang/article/details/84717301
版权声明:本文为博主原创文章,转载请附上博文链接!


作者: 不二晨    时间: 2018-12-18 17:48
奈斯




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2