Commit 72d90450 authored by jiajunjie's avatar jiajunjie

update file directory and model files

parent f8ea3b37
1、舵机角度控制参考如下: 版权归优波生命科技有限公司所有
https://www.yahboom.com/build.html?id=1992&cid=257
目录结构如下:
c++目录存放C++下的库文件、接口代码、使用可以查看readme及使用列子
python目录存放python实现代码,接口文件
models存放相关模型文件
image存放测试图片
1、舵机角度控制参考如下:
https://www.yahboom.com/build.html?id=1992&cid=257
2、安装python版本opencv
sudo pip install opencv-python
sudo pip install opnecv-contrib-python
3、测试
cd examples
python facesMutiTracker.py
import numpy as np
import cv2
import sys
import datetime
class item:
def __init__(self):
self.trackid = 0;
self.age = 0;
self.gender = 0;
self.list =[];
def CatVideo():
cv2.namedWindow("CaptureFace")
cap=cv2.VideoCapture(0)
classfier=cv2.CascadeClassifier("haarcascade_frontalface_alt2.xml")
tracker = cv2.MultiTracker_create()
isdetected = False
recordtime = datetime.datetime.now()
while cap.isOpened():
ok,frame=cap.read()
if not ok:
print('Failed to read video')
break
curtime = datetime.datetime.now()
if ( (curtime - recordtime).seconds >= 2):
isdetected = False
print("update date box")
if not isdetected:
grey=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faceRects = classfier.detectMultiScale(grey, scaleFactor = 1.2, minNeighbors = 3, minSize = (32, 32))
if len(faceRects) > 0:
for faceRect in faceRects:
x, y, w, h = faceRect
#cv2.rectangle(frame, (x - 10, y - 10), (x + w + 10, y + h + 10), (0,255,0), 3)
tracker = cv2.MultiTracker_create()
# Define an initial bounding box
bbox = (x, w, y, h)
#a= item()
#a.list.append(bbox)
#print("tst: "+len(a.list) )
ok = tracker.add(cv2.TrackerKCF_create(), frame, bbox)
isdetected = True
recordtime = curtime
# Start timer
timer = cv2.getTickCount()
# Update tracker
ok, boxes = tracker.update(frame)
print ok, boxes
# Calculate Frames per second (FPS)
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer);
# Draw bounding box
if ok:
# Tracking success
for newbox in boxes:
p1 = (int(newbox[0]), int(newbox[1]))
p2 = (int(newbox[0] + newbox[2]), int(newbox[1] + newbox[3]))
cv2.rectangle(frame, p1, p2, (200,0,0))
else :
# Tracking failure
cv2.putText(frame, "Tracking failure detected", (100,80), cv2.FONT_HERSHEY_SIMPLEX, 0.75,(0,0,255),2)
# Display FPS on frame
cv2.putText(frame, "FPS : " + str(int(fps)), (100,50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50,170,50), 2);
cv2.imshow("CaptureFace",frame)
if cv2.waitKey(10)&0xFF==ord('q'):
break
cap.release()
cv2.destroyAllWindows()
CatVideo()
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment