Exemple #1
0
	def read_once(self, limb, unit='meter', Nx3_cloud=False, clean=None):
		while True:
			try:
				if limb=='right':
					camera = RemoteCamera(RIGHT_CAMERA_IP, 30000)
				elif limb=='left':
					camera = RemoteCamera(LEFT_CAMERA_IP, 30000)
				else:
					raise Exception('Unrecognized limb '+str(limb))
				color, cloud, depth_uv, color_uv = camera.read()
				camera.close()
				break
			except:
				print 'Camera Connection Error. Retry in 1 second...'
				time.sleep(1)
		print 'image taken'
		if unit in ['meter', 'm']:
			cloud /= 1000
		elif unit in ['centimeter', 'centi-meter', 'cm']:
			cloud = cloud
		else:
			raise Exception('Unrecognized unit '+str(unit))
		if Nx3_cloud:
			cloud = cloud.reshape(-1, 3)
		if Nx3_cloud:
			assert clean is not None, 'clean must be a boolean when Nx3_cloud is True'
			if clean:
				keep_idxs = np.where(cloud[:,2].flatten()!=0)[0]
				cloud = cloud[keep_idxs,:]
		return color, cloud, depth_uv, color_uv
	def read_average_depth(self, ite=10, unit='meter'):
		camera = RemoteCamera('10.236.66.147', 30000)
		all_depth = np.zeros((480, 640, ite))
		for i in xrange(ite):
			all_depth[:,:,i] = camera.read()[1][:,:,2] # [1] to index cloud, [:,:,2] to index z axis
		camera.close()
		all_depth[all_depth==0]=np.nan
		depth_avg = np.nanmean(all_depth, axis=2)
		print 'Shape of average depth is', depth_avg.shape
		if unit in ['meter', 'm']:
			depth_avg /= 1000
		elif unit in ['centimeter', 'centi-meter', 'cm']:
			depth_avg = depth_avg
		else:
			raise Exception('Unrecognized unit '+str(unit))
		return depth_avg
	def read_once(self, unit='meter', Nx3_cloud=False, clean=None):
		camera = RemoteCamera('10.236.66.147', 30000)
		color, cloud, depth_uv, color_uv = camera.read()
		camera.close()
		if unit in ['meter', 'm']:
			cloud /= 1000
		elif unit in ['centimeter', 'centi-meter', 'cm']:
			cloud = cloud
		else:
			raise Exception('Unrecognized unit '+str(unit))
		if Nx3_cloud:
			cloud = cloud.reshape(-1, 3)
		if Nx3_cloud:
			assert clean is not None, 'clean must be a boolean when Nx3_cloud is True'
			if clean:
				keep_idxs = np.where(cloud[:,2].flatten()!=0)[0]
				cloud = cloud[keep_idxs,:]
		return color, cloud, depth_uv, color_uv
Exemple #4
0
	def read_once(self, limb, unit='meter', Nx3_cloud=False, clean=None, index=None):
		while True:
			try:
				if limb=='right':
					camera = RemoteCamera(RIGHT_CAMERA_IP, 30000)
				elif limb=='left':
					camera = RemoteCamera(LEFT_CAMERA_IP, 30000)
				elif limb == None:

					if index == None:
						raise Exception('Limb cannot be none when camera index is also none')
					else:
						#print 'Camera IP is ', CAMERA_IP[index]
						camera = RemoteCamera(CAMERA_IP[index], 30000)
					
				else:
					raise Exception('Unrecognized limb '+str(limb))
				color, cloud, depth_uv, color_uv = camera.read()
				camera.close()
				#print 'camera closed'
				break
			except Exception, err:
				print err
				print 'Camera Connection Error. Retry in 1 second...'
				time.sleep(1)
	def read_cloud_avg(self, ite=10, unit='meter', Nx3_cloud=False, clean=None):
		camera = RemoteCamera('10.236.66.147', 30000)
		all_cloud = np.zeros((480, 640, 3, ite))
		for i in xrange(ite):
			all_cloud[:,:,:,i] = camera.read()[1] # [1] to index cloud
		camera.close()
		all_cloud[all_cloud==0]=np.nan
		cloud_avg = np.nanmean(all_cloud, axis=3)
		print 'Shape of average cloud is', cloud_avg.shape
		if unit in ['meter', 'm']:
			cloud_avg /= 1000
		elif unit in ['centimeter', 'centi-meter', 'cm']:
			cloud_avg = cloud_avg
		else:
			raise Exception('Unrecognized unit '+str(unit))
		if Nx3_cloud:
			cloud_avg = cloud_avg.reshape(-1, 3)
		if Nx3_cloud:
			assert clean is not None, 'clean must be a boolean when Nx3_cloud is True'
			if clean:
				keep_idxs = np.where(cloud_avg[:,2].flatten()!=np.nan)[0]
				cloud_avg = cloud_avg[keep_idxs,:]
		return cloud_avg