コード例 #1
0
	def _get_cv_frame(self):
		frame = CameraInputProvider.get_frame(self)

		dst = cv.cvCreateImage(cv.cvSize(self.capture_dims[0],self.capture_dims[1]),frame.depth,frame.nChannels)
		cv.cvWarpPerspective( frame, dst, self.matrix)

		return dst
コード例 #2
0
	def __init__(self,cam_num,capture_dims) :
		#Call CameraInputProvider constructor
		CameraInputProvider.__init__(self,cam_num,capture_dims)
		print self.scale

		self.image_dims=tuple((int(dim) for dim in self.capture_dims))

		self.storage = cvCreateMemStorage(0);

		self.color_thresh = 230
		self.grid = (7,7)

		self.n_points = self.grid[0]*self.grid[1]

		self.object_points = cv.cvCreateMat(self.n_points,3,cv.CV_32F)
		self.image_points = cv.cvCreateMat(self.n_points,2,cv.CV_32F)
コード例 #3
0
	def _calibrate_camera(self) :
		source = CameraInputProvider.get_frame(self)

		success, corners = cv.cvFindChessboardCorners(source, cv.cvSize(self.grid[0],self.grid[1]))
		n_points = self.grid[0]*self.grid[1]

		grid_x = self.capture_dims[0]/self.grid[0]
		grid_y = self.capture_dims[1]/self.grid[1]
		dest = []
		for i in range(0,self.grid[0]) :
			for j in range(0,self.grid[1]) :
				dest.append((j*grid_x,i*grid_y))

		self.dest = dest

		s = cv.cvCreateMat(n_points,2,cv.CV_32F)
		d = cv.cvCreateMat(n_points,2,cv.CV_32F)
		p = cv.cvCreateMat(3,3,cv.CV_32F)

		for i in range(n_points):
			s[i,0] = corners[i].x
			s[i,1] = corners[i].y

			d[i,0] = dest[i][0]
			d[i,1] = dest[i][1]

		results = cv.cvFindHomography(s,d,p)

		self.matrix = p