Tensorflow——用openpose进行人体骨骼检测

https://blog.csdn.net/eereere/article/details/80176007

参考资料
code:https://github.com/ildoonet/tf-pose-estimation
paper:https://arxiv.org/pdf/1611.08050.pdf
Mark的教学视频:https://www.youtube.com/watch?v=nUjGLjOmF7o
                         (视频里特别详细,从conda环境,安装tensorflow,到最后的run)

需要的软件
python3
tensorflow 1.3.0+(作者说要1.4.1,我的cuda是8.0,只能用1.3.0)
opencv3, protobuf, python3-tk
0)准备工作
下载code:https://github.com/ildoonet/tf-pose-estimation
activate 你的环境
打开 tf-pose-estimation-master文件夹

1)安装必要的requirements
pip3 install -r requirements.txt

在安装ast时会报错: FileNotFoundError: [Errno 2] No such file or directory: ‘C:\\Users…..
不用管,Python已经有ast了
所以把ast删掉,再pip install一遍
2)运行

检测图像:
python src/run.py –model=mobilenet_thin –resolution=432×368 –image=×××.jpg
①整个人都没有检测到

②左腿没有检测到

③整个人都检测到了

检测本地视频:

python src/run_video.py –model=mobilenet_thin –resolution=432×368 –video=child.mp4

加了几句代码就可以将视频保存到本地

     fourcc = cv2.VideoWriter_fourcc(‘M’, ‘P’, ‘4’, ‘2’)
        outVideo = cv2.VideoWriter(‘save.avi’,fourcc,fps,size)
     
        if (cap.isOpened()== False):
            print(“Error opening video stream or file”)
        while(cap.isOpened()):
            ret_val, image = cap.read()
     
     
            humans = e.inference(image)
            image = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)
     
            #logger.debug(‘show+’)
            cv2.putText(image,
                        “FPS: %f” % (1.0 / (time.time() – fps_time)),
                        (10, 10),  cv2.FONT_HERSHEY_SIMPLEX, 0.5,
                        (0, 255, 0), 2)
            cv2.imshow(‘tf-pose-estimation result’, image)
            outVideo.write(image)
            fps_time = time.time()
            if cv2.waitKey(1) == 27:
                break

从抖音上下载了一个短视频,下面是检测结果,视频检测的结果还是非常好的
但是事实检测FPS仍然有些慢
 

    原文作者:tensorflow
    原文地址: https://www.cnblogs.com/shuimuqingyang/p/10102872.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞