Upcoming SlideShare
×

# Particle Filter Tracking in Python

15,271 views

Published on

4 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
15,271
On SlideShare
0
From Embeds
0
Number of Embeds
5,913
Actions
Shares
0
116
0
Likes
4
Embeds 0
No embeds

No notes for slide

### Particle Filter Tracking in Python

1. 1. Particle Filter Tracking in Python12 1 8
2. 2. About myself google it ➡ Kohta Ishikawa (a professional skier is not me)12 1 8
3. 3. Particle distribution empirical approximation12 1 8
4. 4. Filter movement estimation observation and Bayes update12 1 8
5. 5. Particle Filter particle movement observation and resampling12 1 8
6. 6. Tracking12 1 8
7. 7. Tracking12 1 8
8. 8. Tracking12 1 8
9. 9. Tracking12 1 8
10. 10. Code def filtration(svs,mv,systemModel,likelihood): # dim = len(svs[1]) N = len(svs) sigma = 2.0 rnorm = stats.norm.rvs(0,sigma,size=N*dim) ranges = zip([N*i for i in range(dim)], [N*i for i in (range(dim+1)[1:])]) ws = np.array([rnorm[p:q] for p,q in ranges]) ws = ws.transpose() # svs_predict = [systemModel.generate(sv,w) for sv,w in zip(svs,ws)] # normalization_factor = likelihood.normalization(svs_predict,mv) likelihood_weights = [likelihood.generate(sv,mv)/normalization_factor for sv in svs_predict] # svs_resampled = resampling(svs_predict,likelihood_weights) return(svs_resampled)12 1 8
11. 11. Code if(__name__=="__main__"): # img = Image() # sampleSize = 100 # systemModel = SystemModel(model_s) likelihood = Likelihood(model_l) # svs = initStateVectors(img.size,sampleSize) while(True): # showImage(svs,img) # img.create() # svs = filtration(svs,img,systemModel,likelihood)12 1 8
12. 12. Code (openCV Bundle) class Image: def __init__(self): self.capture = cv.CreateCameraCapture(0) self.image = cv.QueryFrame(self.capture) cv.ShowImage("Capture",self.image) self.size = (self.image.width,self.image.height) def create(self): self.image = cv.QueryFrame(self.capture) def getCol(self,sv): x = sv[0] y = sv[1] # if((x<0 or x>self.size[0]) or (y<0 or y>self.size[1])): return((0,0,0,0)) else: return(cv.Get2D(self.image,int(sv[1]),int(sv[0])))12 1 8
13. 13. Demo12 1 8
14. 14. NumPy/SciPy def model_s(sv,w): # # (x,y,vx,vy) F = np.matrix([[1,0,1,0], [0,1,0,1], [0,0,1,0], [0,0,0,1]]) return(np.array(np.dot(F,sv))[0]+w) def filtration(svs,mv,systemModel,likelihood): # dim = len(svs[1]) N = len(svs) sigma = 2.0 rnorm = stats.norm.rvs(0,sigma,size=N*dim) ranges = zip([N*i for i in range(dim)], [N*i for i in (range(dim+1)[1:])]) ws = np.array([rnorm[p:q] for p,q in ranges]) ws = ws.transpose()12 1 8
15. 15. References photo: By Dale Gillard from everystockphoto.com book: code: http://d.hatena.ne.jp/koh_ta/20110814 https://github.com/kohta/pftrack12 1 8