private static void Main(string[] args) { // Validate Input Paramters if (args.Length == 0 || args[0] == null) { Console.WriteLine("Input File not specified."); // Wait for User Input Console.WriteLine("Press any key to continue."); Console.ReadKey(); Environment.Exit(-1); } string imagePath = args[0]; // Validate that the input file exists if (!File.Exists(imagePath)) { Console.WriteLine("Input File: " + imagePath + " does not exist."); Console.WriteLine("Unable to Process File"); // Wait for User Input Console.WriteLine("Press any key to continue."); Console.ReadKey(); Environment.Exit(-1); } Console.WriteLine("Processing File: " + imagePath); // Process Image ImageProcessor imageProcesser = new ImageProcessor(imagePath); FlirImage flirImage = imageProcesser.FlirImageData; // Generate JSON output objecdt string json = imageProcesser.ToJson(flirImage); // Save JSON file string diretoryPath = Path.GetDirectoryName(imagePath); string fileName = Path.GetFileNameWithoutExtension(imagePath); string outputFilePath = diretoryPath + "\\" + fileName + ".json"; File.WriteAllText(outputFilePath, json); Console.WriteLine("Data Saved to " + outputFilePath); // Wait for User Input Console.WriteLine("Press any key to continue."); Console.ReadKey(); Environment.Exit(0); }
public ImageProcessor(string imageFilePath) { FlirImageFile = new ThermalImageFile(imageFilePath); _flirImageData = ProcessImage(FlirImageFile); }
private FlirImage ProcessImage(ThermalImageFile thermalImage) { FlirImage flirImageData = new FlirImage { DateTaken = thermalImage.DateTaken, Description = thermalImage.Description, Height = thermalImage.Height, MaxSignalValue = thermalImage.MaxSignalValue, MinSignalValue = thermalImage.MinSignalValue, Precision = thermalImage.Precision, TemperatureUnit = (Enums.TemperatureUnit)Enum.Parse(typeof(Enums.TemperatureUnit), thermalImage.TemperatureUnit.ToString()), Width = thermalImage.Width, ThermalData = ExtractTemperatureReadings(thermalImage), Title = thermalImage.Title }; if (thermalImage.CameraInformation != null) { flirImageData.CameraInfo = new CameraInfo { Filter = thermalImage.CameraInformation.Filter, Fov = thermalImage.CameraInformation.Fov, Lens = thermalImage.CameraInformation.Lens, Model = thermalImage.CameraInformation.Model, RangeMax = thermalImage.CameraInformation.Range.Maximum, RangeMin = thermalImage.CameraInformation.Range.Minimum, SerialNumber = thermalImage.CameraInformation.SerialNumber } } ; if (thermalImage.CompassInformation != null) { flirImageData.CompassInfo = new Models.CompassInfo { Degrees = thermalImage.CompassInformation.Degrees, Pitch = thermalImage.CompassInformation.Pitch, Roll = thermalImage.CompassInformation.Roll } } ; if (thermalImage.GpsInformation != null) { flirImageData.GpsInfo = new GpsInfo { Altitude = thermalImage.GpsInformation.Altitude, Dop = thermalImage.GpsInformation.Dop, Latitude = thermalImage.GpsInformation.Latitude, Longitude = thermalImage.GpsInformation.Longitude, MapDatum = thermalImage.GpsInformation.MapDatum, Satellites = thermalImage.GpsInformation.Satellites } } ; if (thermalImage.ThermalParameters != null) { flirImageData.ThermalParameters = new ThermalParameters { AtmosphericTemperature = thermalImage.ThermalParameters.AtmosphericTemperature, Distance = thermalImage.ThermalParameters.Distance, Emissivity = thermalImage.ThermalParameters.Emissivity, ExternalOpticsTemperature = thermalImage.ThermalParameters.ExternalOpticsTemperature, ExternalOpticsTransmission = thermalImage.ThermalParameters.ExternalOpticsTransmission, ReferenceTemperature = thermalImage.ThermalParameters.ReferenceTemperature, ReflectedTemperature = thermalImage.ThermalParameters.ReflectedTemperature, RelativeHumidity = thermalImage.ThermalParameters.RelativeHumidity, Transmission = thermalImage.ThermalParameters.Transmission } } ; return(flirImageData); }
public string ToJson(FlirImage flirImageData) { return(JsonConvert.SerializeObject(flirImageData)); }