computer version_Methods
1 introducion
从事计算机视觉,不得不补充一下计算机视觉的基础知识
some traditonal and machine learning methods about computer version.
2 基础知识
2.1 相机参数
相机参数模型
https://www.cnblogs.com/majiale/p/9293499.html
3 traditional methods
3.1 model fitting and transform
3.1.1 RANSAC
import numpy as np
import math
import matplotlib.pyplot as plt
import random
def fit_line_by_ransac(x,y,sigma,iters=10000,p=0.99):
n=len(x)
best_a=0
best_b=0
pretotal=0
for i in range(iters):
sample_index=random.sample(range(n),2)
x_1,y_1=x[sample_index[0]],y[sample_index[0]]
x_2,y_2=x[sample_index[1]],y[sample_index[1]]
a=(y_2-y_1)/(x_2-x_1)
b=y_1-a*x_1
total_inlier=0
for index in range(n):
y_estmate=a*x[index]+b
if abs(y_estmate-y[index])<sigma:
total_inlier=total_inlier+1
if total_inlier>pretotal:
iters=np.log(1-p)/np.log(1-pow(total_inlier/(n),2))
pretotal=total_inlier
best_a=a
best_b=b
if total_inlier>n/1.5:
print(i,total_inlier)
break
return best_a,best_b
if __name__=="__main__":
n=100
a0=1
b0=1
x=np.linspace(0,10,n)
y=a0*x+b0+np.random.rand(n)*1
random_x,random_y=[],[]
for i in range(n):
random_x.append(x[i]+np.random.random()*1)
random_y.append(y[i]+np.random.random()*1)
a,b=fit_line_by_ransac(np.array(random_x),np.array(random_y),sigma=3)
y_=a*x+b
plt.scatter(x,y_)
plt.scatter(random_x,random_y)
plt.show()
3.2 multiview
if you want to learn this section,slam 14 is a good work