參考資料
(視頻裏特別詳細,從conda環境,安裝tensorflow,到最後的run)
需要的軟件
python3
tensorflow 1.3.0+(作者說要1.4.1,我的cuda是8.0,只能用1.3.0)
opencv3, protobuf, python3-tk
0)準備工作
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=432x368 --image=×××.jpg
①整個人都沒有檢測到
②左腿沒有檢測到
③整個人都檢測到了
檢測本地視頻:
python src/run_video.py --model=mobilenet_thin --resolution=432x368 --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仍然有些慢