Ejemplo n.º 1
0
def calcCoeff():
	ret, nRow, nCol, ptx, pty = ptfile.loadPoints('data/all_pts.txt')
	if ret != 0:
		print 'calcCoeff() >> 读取数据失败'
		return
	
	nPoly = 2  # 抛物线
	rowCoeff = []
	colCoeff = []
	
	for i in xrange(nRow):
		coeff = fitPoly(ptx[i], pty[i], nPoly)
		plotFitResult(ptx[i], pty[i], coeff)
		rowCoeff.append(coeff)
		print i
	dfile.saveMatrix(rowCoeff, 'data/row_coeff.txt')
	
	ptx1 = -np.transpose(pty)
	pty1 = np.transpose(ptx)
	for i in xrange(nCol):
		coeff = fitPoly(ptx1[i], pty1[i], nPoly)
		plotFitResult(ptx1[i], pty1[i], coeff, 1)
		colCoeff.append(coeff)
		print i
	dfile.saveMatrix(colCoeff, 'data/col_coeff.txt')
	
	#plt.xlim(50, 650)
	#plt.ylim(-400, -150)
	plt.show()
Ejemplo n.º 2
0
def buildMap():
	ret, nRow, nCol, srcx, srcy = ptfile.loadPoints('data/true_pts.txt')
	if ret != 0:
		print 'buildMap() >> 读取数据失败'
		return
	scale = 50
	dstx = [ [j*scale for j in xrange(nCol)] for i in xrange(nRow) ]
	dsty = [ [i*scale for j in xrange(nCol)] for i in xrange(nRow) ]
	
	srcx = dim2To1(srcx)
	srcy = dim2To1(srcy)
	dstx = dim2To1(dstx)
	dsty = dim2To1(dsty)
	
	tfin = merge(dstx, dsty)
	tfout = merge(srcx, srcy)
	tfln(tfin, tfout)