Example #1
0
	def process_file(self, filePath):
		
		self.update_result_text("    - Setup\n");
		
		try:
			minE = float(self.minEastingEntry.get());
			minN = float(self.minNorthingEntry.get());
			blkS = int(self.blkSizeEntry.get());
			outR = int(self.outResEntry.get());
			zThr = float(self.htThresholdEntry.get());
			zmax = float(self.bbbEntry.get())
		
			result = Bio_module.setup(filePath, self.outDirEntry.get(), minE, minN, blkS, outR, zThr, zmax)
		except:
			self.handle_exception(sys.exc_info())
			return
		
		if self.computeBiometrics.get() == 1 :
			
			self.update_result_text("    - Biometrics\n")
			try:
				Bio_module.bio()
			except:
				self.handle_exception(sys.exc_info())
				return
			
		if self.computeLhq.get() == 1 : 
			
			self.update_result_text("    - LHQ\n")
			try:
				Bio_module.lhq()
			except:
				self.handle_exception(sys.exc_info())
				return
			
		if self.computeCcf.get() == 1 :
			
			self.update_result_text("    - CCF\n")
			try:
				Bio_module.ccf()
			except:
				self.handle_exception(sys.exc_info())
				return
				
		self.update_result_text("    - Teardown\n")
		
		Bio_module.teardown()
		
		return result;
Example #2
0
	def execute(self):
		
		try:
			pointFile    = self.pointFileEntry.get()
			centEasting  = self.centEastEntry.get()
			centNorthing = self.centNorthEntry.get()
			
			#
			# ensure valid input
			#
			if pointFile == "":
				if centEasting == "" or centNorthing == "":
					self.update_message_text("Error: Must specify a centroid or input file.\n\n")
					return
			
			if self.pointDirEntry.get() == "" or self.outFileEntry.get() == "":
				self.update_message_text("Error: Must specify input CHM directory and output directory.\n\n")
			   	return
			   	
			if self.radiusBound.get() == 0 and self.boxBound.get() == 0:
				self.update_message_text("Error: Must specify bounding region.\n\n")
			   	return
					
			if self.minEastingEntry.get() == ""  or self.minNorthingEntry.get() == "" or \
			   self.blockSizeEntry.get() == "" or self.htThresholdEntry.get() == "":
			   	
				self.update_message_text("Error: Missing input.\n\n")
			   	return
			
			points = []
		
			if not(pointFile == ""):
			
				pointFile = open(pointFile, "r")
				
				line = pointFile.readline()
				
				while not(line == ""):
					
					self.update_message_text("line:"+line)
					line  = line.strip()
					self.update_message_text("strip:"+line + "\n")
					point = line.split()
					
					if len(point) != 2:
						self.update_message_text("Error: Input centroid points file format error. " + str(len(point)) + "\n\n")
						return
					
					points.append( [ float(point[0]), float(point[1]) ] )
					
					line = pointFile.readline()
		
			else:
				easting  = float(self.centEastEntry.get())
				northing = float(self.centNorthEntry.get())
				
				points.append([easting, northing])
						
			curPoint  = 1
			numPoints = len(points)
			
			self.write_centroid_header(self.outFileEntry.get())
			
			for point in points:
				
				centroidEasting  = point[0]
				centroidNorthing = point[1]
				minEasting 	 = float(self.minEastingEntry.get())
				minNorthing 	 = float(self.minNorthingEntry.get())
				blockSize 	 = int(self.blockSizeEntry.get())
				zThreshold 	 = int(self.htThresholdEntry.get())
				chmDir 		 = self.pointDirEntry.get()
				outFile 	 = self.outFileEntry.get()
				
				self.update_message_text("Point " + str(curPoint) + " of " + str(numPoints))
				self.update_message_text("   (" + str(centroidEasting) + ", " + str(centroidNorthing) + ")\n")
				
				if self.radiusBound.get() == 1:
					
					radius = int(self.radiusEntry.get())
					Bio_module.computeBiometricsAroundCentroid(curPoint, centroidEasting, centroidNorthing, minEasting, minNorthing, radius, blockSize, zThreshold, chmDir, outFile)
	
					
				else:
					
					length = int(self.boxEntry.get())
					Bio_module.computeBiometricsInBoundingBox(curPoint, centroidEasting, centroidNorthing, minEasting, minNorthing, length, blockSize, zThreshold, chmDir, outFile)
				
				curPoint = curPoint + 1
				
			self.update_message_text("Complete.\n\n")
			
		except:
			self.handle_exception(sys.exc_info())
Example #3
0
	def generate_random_points(self):
		
		try:
			if self.numPointsEntry.get() == "":
				self.update_message_text("Error. Must specify the number of points to generate.\n\n")
				return
				
			if self.minEastingRangeEntry.get() == "" or self.maxEastingRangeEntry.get() == "" or\
			   self.minNorthingRangeEntry.get() == "" or self.maxNorthingRangeEntry.get() == "":
				self.update_message_text("Error. Must specify range of the random numbers to generate.\n\n")
				return
				
			numPoints   = int(self.numPointsEntry.get())
			minEasting  = float(self.minEastingRangeEntry.get())
			maxEasting  = float(self.maxEastingRangeEntry.get())
			minNorthing = float(self.minNorthingRangeEntry.get())
			maxNorthing = float(self.maxNorthingRangeEntry.get())
			
			self.update_message_text("Generating " + str(numPoints) + " random points...\n")
			
			eRange = maxEasting - minEasting
			nRange = maxNorthing - minNorthing
			
			randPoints = []
			
			for i in range(numPoints):
				
				x = random.random()
				x = x * eRange
				x = x + minEasting
				y = random.random()
				y = y * nRange
				y = y + minNorthing
				randPoints.append([x,y])
			
			if self.processLater.get() == 1:
				
				f = open(self.randFileEntry.get(), "w")
				
				self.update_message_text("Writing points to " + self.randFileEntry.get() + "...\n")
				
				#write to file
				for point in randPoints:
					f.write(str(point[0]) + ' ' + str(point[1]) + '\n')
				
				f.close()
				
				self.update_message_text("Complete!\n")
					
			else:
				
				#process all the points
				if self.pointDirEntry.get() == "" or self.outFileEntry.get() == "":
					self.update_message_text("Error: Must specify input CHM directory and output directory.\n\n")
					return
				
				if self.minEastingEntry.get() == ""  or self.minNorthingEntry.get() == "" or \
			           self.blockSizeEntry.get() == ""   or self.htThresholdEntry.get() == "":
			           	   self.update_message_text("Error: Missing input.\n\n")
			           	   return
				
				if self.radiusBound.get() == 0 and self.boxBound.get() == 0:
					self.update_message_text("Error: Must specify bounding region.\n\n")
					return
				
				minE = float(self.minEastingEntry.get())
				minN = float(self.minNorthingEntry.get())
				blkS = int(self.blockSizeEntry.get())
				zThr = int(self.htThresholdEntry.get())
				chmD = self.pointDirEntry.get()
				outF = self.outFileEntry.get()
				
				self.write_centroid_header(outF)
				
				pointIdx = 1
				numPoints = len(randPoints)
				
				for point in randPoints:
					
					cntE = point[0]
					cntN = point[1]
					
					self.update_message_text("Point " + str(pointIdx) + " of " + str(numPoints))
					self.update_message_text("   (" + str(cntE) + ", " + str(cntN) + ")\n")
					
					if self.radiusBound.get() == 1:
						
						radius = int(self.radiusEntry.get())
						Bio_module.computeBiometricsAroundCentroid(pointIdx, cntE, cntN, minE, minN, radius, blkS, zThr, chmD, outF)
					else:
						
						length = int(self.boxEntry.get())
						Bio_module.computeBiometricsInBoundingBox(pointIdx, cntE, cntN, minE, minN, length, blkS, zThr, chmD, outF)
					
					pointIdx = pointIdx + 1
				
				self.update_message_text("Complete.\n\n")
		except:
			self.handle_exception(sys.exc_info())
Example #4
0
	def execute_rename(self):

		if self.inRenameEntry.get() == "":
			self.update_result_text("Must select an input directory.\n\n")
			return

		if self.outRenameEntry.get() == "":
			self.update_result_text("Must select an ouput directory.\n\n")
			return
			
		if self.outputAsText.get() == 0 and self.outputAsBin.get() == 0:
			self.update_result_text("Must selexct output file type.\n\n")
			return

		self.update_result_text("Renaming files...\n")
		self.update_result_text("  From : " + self.inRenameEntry.get() + "\n")
		self.update_result_text("  To   : " + self.outRenameEntry.get() + "\n")
		self.update_result_text("Running file...\n")
		
		try:
			minE = float(self.minEastingEntry.get())
			minN = float(self.minNorthingEntry.get());
			blkS = int(self.blkSizeEntry.get());
			bDir = self.inRenameEntry.get();
			outDir = self.outRenameEntry.get()
			zThr = float(self.bbbEntry.get())
			outTxt = self.outputAsText.get()
			outBin = self.outputAsBin.get()
			
			if outTxt == 1:
				if not(os.path.isdir(outDir + "/text")):
					os.makedirs(outDir + "/text")
					
			if outBin == 1:
				if not(os.path.isdir(outDir + "/bin")):
					os.makedirs(outDir + "/bin")
			
			logFile = open(outDir + "/log.txt", "w");
			self.update_result_text(str(logFile) + "\n")
                
			dirList  = os.listdir(self.inRenameEntry.get())
			badFiles = []
			
			for fname in dirList:
				if not(fname.endswith(".bin")):
					badFiles.append(fname)
			
			for badFile in badFiles:
				dirList.remove(badFile)
				
			fileCount = len(dirList)
			currIndex = 1
				
			for fname in dirList:
					
				self.update_result_text("   - " + str(currIndex) + " of " + str(fileCount) + "\n")
				
				try:
					outFile = Bio_module.rename(bDir + "/" + fname, outDir, minE, minN, blkS, zThr, outTxt, outBin)
					logFile.write(bDir + "/" + fname + " " + outFile + "\n")
				except:
					self.update_result_text("Error renaming file " + fname + ".\n")
					
				currIndex = currIndex + 1
			
			logFile.close()
		except:
			self.handle_exception(sys.exc_info())

		self.update_result_text("Complete.\n\n")