public static IFrameStream OpenFile(string fileName, out AdvFileMetadataInfo fileMetadataInfo, out GeoLocationInfo geoLocation) { fileMetadataInfo = new AdvFileMetadataInfo(); geoLocation = new GeoLocationInfo(); try { IFrameStream rv = new AstroDigitalVideoStreamV2(fileName, ref fileMetadataInfo, ref geoLocation); TangraContext.Current.RenderingEngine = fileMetadataInfo.Engine == "AAV" ? "AstroAnalogueVideo" : "AstroDigitalVideo"; if (fileMetadataInfo.Engine == "AAV") { UsageStats.Instance.ProcessedAavFiles++; } else { UsageStats.Instance.ProcessedAdvFiles++; } UsageStats.Instance.Save(); return(rv); } catch (ADVFormatException ex) { MessageBox.Show(ex.Message, "Error opening ADV/AAV file", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
private void CheckAdvFileFormat(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { AdvFile advFile = AdvFile.OpenFile(fileName); CheckAdvFileFormatInternal(advFile); fileMetadataInfo.Recorder = advFile.AdvFileTags["RECORDER"]; fileMetadataInfo.Camera = advFile.AdvFileTags["CAMERA-MODEL"]; fileMetadataInfo.Engine = advFile.AdvFileTags["FSTF-TYPE"]; engine = fileMetadataInfo.Engine; if (engine == "ADV") { advFile.AdvFileTags.TryGetValue("ADVR-SOFTWARE-VERSION", out fileMetadataInfo.AdvrVersion); if (string.IsNullOrWhiteSpace(fileMetadataInfo.AdvrVersion)) { advFile.AdvFileTags.TryGetValue("RECORDER-SOFTWARE-VERSION", out fileMetadataInfo.AdvrVersion); } advFile.AdvFileTags.TryGetValue("HTCC-FIRMWARE-VERSION", out fileMetadataInfo.HtccFirmareVersion); fileMetadataInfo.SensorInfo = advFile.AdvFileTags["CAMERA-SENSOR-INFO"]; advFile.AdvFileTags.TryGetValue("OBJNAME", out fileMetadataInfo.ObjectName); advFile.AdvFileTags.TryGetValue("LONGITUDE-WGS84", out geoLocation.Longitude); advFile.AdvFileTags.TryGetValue("LATITUDE-WGS84", out geoLocation.Latitude); advFile.AdvFileTags.TryGetValue("ALTITUDE-MSL", out geoLocation.Altitude); advFile.AdvFileTags.TryGetValue("MSL-WGS84-OFFSET", out geoLocation.MslWgs84Offset); if (!string.IsNullOrEmpty(geoLocation.MslWgs84Offset) && !geoLocation.MslWgs84Offset.StartsWith("-")) { geoLocation.MslWgs84Offset = "+" + geoLocation.MslWgs84Offset; } advFile.AdvFileTags.TryGetValue("GPS-HDOP", out geoLocation.GpsHdop); } else if (engine == "AAV") { advFile.AdvFileTags.TryGetValue("OCR-ENGINE", out OcrEngine); string sCorr; int iCorr; if (advFile.AdvFileTags.TryGetValue("CAPHNTP-TIMING-CORRECTION", out sCorr) && int.TryParse(sCorr, out iCorr)) { fileMetadataInfo.HasNTPTimeStamps = true; } advFile.AdvFileTags.TryGetValue("OBJECT", out fileMetadataInfo.ObjectName); } this.geoLocation = new GeoLocationInfo(geoLocation); }
public static IFrameStream OpenFile(string fileName, out AdvFileMetadataInfo fileMetadataInfo, out GeoLocationInfo geoLocation) { fileMetadataInfo = new AdvFileMetadataInfo(); geoLocation = new GeoLocationInfo(); try { int version = TangraCore.ADV2GetFormatVersion(fileName); IFrameStream rv; if (version == 1) { var adv1 = new AstroDigitalVideoStream(fileName, ref fileMetadataInfo, ref geoLocation); if (adv1.IsStatusChannelOnly) { TangraContext.Current.CustomRenderer = new AavStatusChannelOnlyRenderer(adv1); return(null); } rv = adv1; } else { rv = AstroDigitalVideoStreamV2.OpenFile(fileName, out fileMetadataInfo, out geoLocation); } TangraContext.Current.RenderingEngine = fileMetadataInfo.Engine == "AAV" ? "AstroAnalogueVideo" : "AstroDigitalVideo"; if (fileMetadataInfo.Engine == "AAV") { UsageStats.Instance.ProcessedAavFiles++; } else { UsageStats.Instance.ProcessedAdvFiles++; } UsageStats.Instance.Save(); return(rv); } catch (ADVFormatException ex) { MessageBox.Show(ex.Message, "Error opening ADV/AAV file", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
private AstroDigitalVideoStream(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { CheckAdvFileFormat(fileName, ref fileMetadataInfo, ref geoLocation); m_FileName = fileName; var fileInfo = new AdvFileInfo(); TangraCore.ADVOpenFile(fileName, ref fileInfo); m_FirstFrame = 0; m_CountFrames = fileInfo.CountFrames; m_BitPix = fileInfo.Bpp; m_Width = fileInfo.Width; m_Height = fileInfo.Height; m_Aav16NormVal = fileInfo.Aav16NormVal; m_FrameRate = fileInfo.FrameRate; // Get the last frame in the video and read the Almanac Offset and Almanac Status so they are applied // to the frames that didn't have Almanac Status = Updated if (m_CountFrames > 0) { GetPixelmap(m_FirstFrame + m_CountFrames - 1); m_AlamanacOffsetLastFrameIsGood = m_CurrentFrameInfo.AlmanacStatusIsGood; m_AlmanacOffsetLastFrame = m_CurrentFrameInfo.GetSignedAlamancOffset(); } else { m_AlamanacOffsetLastFrameIsGood = false; m_AlmanacOffsetLastFrame = 0; } m_Engine = fileMetadataInfo.Engine; m_CameraModel = fileMetadataInfo.Camera; m_UsesNtpTimestamps = fileMetadataInfo.HasNTPTimeStamps; if (m_Engine == "AAV") { m_VideoStandard = GetFileTag("NATIVE-VIDEO-STANDARD"); double.TryParse(GetFileTag("NATIVE-FRAME-RATE"), out m_NativeFrameRate); int.TryParse(GetFileTag("OSD-FIRST-LINE"), out m_OsdFirstLine); int.TryParse(GetFileTag("OSD-LAST-LINE"), out m_OsdLastLine); if (m_OsdLastLine > m_Height) { m_OsdLastLine = m_Height; } if (m_OsdFirstLine < 0) { m_OsdFirstLine = 0; } m_IntegratedAAVFrames = -1; if (double.TryParse(GetFileTag("EFFECTIVE-FRAME-RATE"), out m_EffectiveFrameRate) && m_NativeFrameRate != 0) { m_IntegratedAAVFrames = (int)Math.Round(m_NativeFrameRate / m_EffectiveFrameRate); } int.TryParse(GetFileTag("FRAME-STACKING-RATE"), out m_StackingRate); if (m_StackingRate == 1) { m_StackingRate = 0; // Video stacked at x1 is a non-stacked video } } else { m_OsdFirstLine = 0; m_OsdLastLine = 0; } m_OcrDataAvailable = null; }
private AstroDigitalVideoStreamV2(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { //CheckAdvFileFormat(fileName, ref fileMetadataInfo, ref geoLocation); m_FileName = fileName; m_AdvFile = new AdvFile2(fileName); m_FirstFrame = 0; m_CountFrames = m_AdvFile.MainSteamInfo.FrameCount; m_BitPix = m_AdvFile.DataBpp; m_Width = m_AdvFile.Width; m_Height = m_AdvFile.Height; m_MaxPixelValue = (uint)m_AdvFile.MaxPixelValue; m_FrameRate = 0; m_Engine = "ADV2"; fileMetadataInfo.Recorder = GetFileTag("RECORDER-SOFTWARE"); CameraModel = fileMetadataInfo.Camera = GetFileTag("CAMERA-MODEL"); fileMetadataInfo.Engine = GetFileTag("FSTF-TYPE"); fileMetadataInfo.AdvrVersion = GetFileTag("RECORDER-SOFTWARE-VERSION"); fileMetadataInfo.SensorInfo = GetFileTag("CAMERA-SENSOR-INFO"); fileMetadataInfo.ObjectName = GetFileTag("OBJNAME"); int aavVersion; if (int.TryParse(GetFileTag("AAV-VERSION"), out aavVersion)) { m_AAVVersion = aavVersion; m_VideoStandard = GetFileTag("NATIVE-VIDEO-STANDARD"); double.TryParse(GetFileTag("NATIVE-FRAME-RATE"), NumberStyles.Float, CultureInfo.InvariantCulture, out m_NativeFrameRate); int.TryParse(GetFileTag("OSD-FIRST-LINE"), out m_OsdFirstLine); int.TryParse(GetFileTag("OSD-LAST-LINE"), out m_OsdLastLine); if (m_OsdLastLine > m_Height) { m_OsdLastLine = m_Height; } if (m_OsdFirstLine < 0) { m_OsdFirstLine = 0; } m_IntegratedAAVFrames = -1; if (double.TryParse(GetFileTag("EFFECTIVE-FRAME-RATE"), NumberStyles.Float, CultureInfo.InvariantCulture, out m_EffectiveFrameRate) && m_NativeFrameRate != 0) { m_IntegratedAAVFrames = (int)Math.Round(m_NativeFrameRate / m_EffectiveFrameRate); m_FrameRate = m_EffectiveFrameRate; // This is important for OCR-ing as the frame rate is used to derive the frame exposure } int.TryParse(GetFileTag("FRAME-STACKING-RATE"), out m_StackingRate); if (m_StackingRate == 1) { m_StackingRate = 0; // Video stacked at x1 is a non-stacked video } m_Engine = string.Format("AAV{0}", aavVersion); } this.geoLocation = new GeoLocationInfo() { //TODO }; geoLocation = this.geoLocation; }
private void CheckAdvFileFormat(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { AdvFile advFile = AdvFile.OpenFile(fileName); CheckAdvFileFormatInternal(advFile); fileMetadataInfo.Recorder = advFile.AdvFileTags["RECORDER"]; fileMetadataInfo.Camera = advFile.AdvFileTags["CAMERA-MODEL"]; fileMetadataInfo.Engine = advFile.AdvFileTags["FSTF-TYPE"]; engine = fileMetadataInfo.Engine; if (engine == "ADV") { advFile.AdvFileTags.TryGetValue("ADVR-SOFTWARE-VERSION", out fileMetadataInfo.AdvrVersion); if (string.IsNullOrWhiteSpace(fileMetadataInfo.AdvrVersion)) advFile.AdvFileTags.TryGetValue("RECORDER-SOFTWARE-VERSION", out fileMetadataInfo.AdvrVersion); advFile.AdvFileTags.TryGetValue("HTCC-FIRMWARE-VERSION", out fileMetadataInfo.HtccFirmareVersion); fileMetadataInfo.SensorInfo = advFile.AdvFileTags["CAMERA-SENSOR-INFO"]; advFile.AdvFileTags.TryGetValue("OBJNAME", out fileMetadataInfo.ObjectName); advFile.AdvFileTags.TryGetValue("LONGITUDE-WGS84", out geoLocation.Longitude); advFile.AdvFileTags.TryGetValue("LATITUDE-WGS84", out geoLocation.Latitude); advFile.AdvFileTags.TryGetValue("ALTITUDE-MSL", out geoLocation.Altitude); advFile.AdvFileTags.TryGetValue("MSL-WGS84-OFFSET", out geoLocation.MslWgs84Offset); if (!string.IsNullOrEmpty(geoLocation.MslWgs84Offset) && !geoLocation.MslWgs84Offset.StartsWith("-")) { geoLocation.MslWgs84Offset = "+" + geoLocation.MslWgs84Offset; } advFile.AdvFileTags.TryGetValue("GPS-HDOP", out geoLocation.GpsHdop); } else if (engine == "AAV") { advFile.AdvFileTags.TryGetValue("OCR-ENGINE", out OcrEngine); string sCorr; int iCorr; if (advFile.AdvFileTags.TryGetValue("CAPHNTP-TIMING-CORRECTION", out sCorr) && int.TryParse(sCorr, out iCorr)) { fileMetadataInfo.HasNTPTimeStamps = true; } advFile.AdvFileTags.TryGetValue("OBJECT", out fileMetadataInfo.ObjectName); } this.geoLocation = new GeoLocationInfo(geoLocation); }
public static IFrameStream OpenFile(string fileName, out AdvFileMetadataInfo fileMetadataInfo, out GeoLocationInfo geoLocation) { fileMetadataInfo = new AdvFileMetadataInfo(); geoLocation = new GeoLocationInfo(); try { int version = TangraCore.ADV2GetFormatVersion(fileName); IFrameStream rv; if (version == 1) rv = new AstroDigitalVideoStream(fileName, ref fileMetadataInfo, ref geoLocation); else rv = AstroDigitalVideoStreamV2.OpenFile(fileName, out fileMetadataInfo, out geoLocation); TangraContext.Current.RenderingEngine = fileMetadataInfo.Engine == "AAV" ? "AstroAnalogueVideo" : "AstroDigitalVideo"; if (fileMetadataInfo.Engine == "AAV") UsageStats.Instance.ProcessedAavFiles++; else UsageStats.Instance.ProcessedAdvFiles++; UsageStats.Instance.Save(); return rv; } catch(ADVFormatException ex) { MessageBox.Show(ex.Message, "Error opening ADV/AAV file", MessageBoxButtons.OK, MessageBoxIcon.Error); } return null; }
private AstroDigitalVideoStream(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { CheckAdvFileFormat(fileName, ref fileMetadataInfo, ref geoLocation); m_FileName = fileName; var fileInfo = new AdvFileInfo(); TangraCore.ADVOpenFile(fileName, ref fileInfo); m_FirstFrame = 0; m_CountFrames = fileInfo.CountFrames; m_BitPix = fileInfo.Bpp; m_Width = fileInfo.Width; m_Height = fileInfo.Height; m_Aav16NormVal = fileInfo.Aav16NormVal; m_FrameRate = fileInfo.FrameRate; // Get the last frame in the video and read the Almanac Offset and Almanac Status so they are applied // to the frames that didn't have Almanac Status = Updated if (m_CountFrames > 0) { GetPixelmap(m_FirstFrame + m_CountFrames - 1); m_AlamanacOffsetLastFrameIsGood = m_CurrentFrameInfo.AlmanacStatusIsGood; m_AlmanacOffsetLastFrame = m_CurrentFrameInfo.GetSignedAlamancOffset(); } else { m_AlamanacOffsetLastFrameIsGood = false; m_AlmanacOffsetLastFrame = 0; } m_Engine = fileMetadataInfo.Engine; m_CameraModel = fileMetadataInfo.Camera; m_UsesNtpTimestamps = fileMetadataInfo.HasNTPTimeStamps; if (m_Engine == "AAV") { m_VideoStandard = GetFileTag("NATIVE-VIDEO-STANDARD"); double.TryParse(GetFileTag("NATIVE-FRAME-RATE"), out m_NativeFrameRate); int.TryParse(GetFileTag("OSD-FIRST-LINE"), out m_OsdFirstLine); int.TryParse(GetFileTag("OSD-LAST-LINE"), out m_OsdLastLine); if (m_OsdLastLine > m_Height) m_OsdLastLine = m_Height; if (m_OsdFirstLine < 0) m_OsdFirstLine = 0; m_IntegratedAAVFrames = -1; if (double.TryParse(GetFileTag("EFFECTIVE-FRAME-RATE"), out m_EffectiveFrameRate) && m_NativeFrameRate != 0) { m_IntegratedAAVFrames = (int)Math.Round(m_NativeFrameRate / m_EffectiveFrameRate); } int.TryParse(GetFileTag("FRAME-STACKING-RATE"), out m_StackingRate); if (m_StackingRate == 1) m_StackingRate = 0; // Video stacked at x1 is a non-stacked video } else { m_OsdFirstLine = 0; m_OsdLastLine = 0; } m_OcrDataAvailable = null; }
private AstroDigitalVideoStreamV2(string fileName, ref AdvFileMetadataInfo fileMetadataInfo, ref GeoLocationInfo geoLocation) { //CheckAdvFileFormat(fileName, ref fileMetadataInfo, ref geoLocation); m_FileName = fileName; m_AdvFile = new AdvFile2(fileName); m_FirstFrame = 0; m_CountFrames = m_AdvFile.MainSteamInfo.FrameCount; m_BitPix = m_AdvFile.DataBpp; m_Width = m_AdvFile.Width; m_Height = m_AdvFile.Height; m_MaxPixelValue = (uint)m_AdvFile.MaxPixelValue; m_FrameRate = 0; m_Engine = "ADV2"; fileMetadataInfo.Recorder = GetFileTag("RECORDER-SOFTWARE"); CameraModel = fileMetadataInfo.Camera = GetFileTag("CAMERA-MODEL"); fileMetadataInfo.Engine = GetFileTag("FSTF-TYPE"); fileMetadataInfo.AdvrVersion = GetFileTag("RECORDER-SOFTWARE-VERSION"); fileMetadataInfo.SensorInfo = GetFileTag("CAMERA-SENSOR-INFO"); fileMetadataInfo.ObjectName = GetFileTag("OBJNAME"); int aavVersion; if (int.TryParse(GetFileTag("AAV-VERSION"), out aavVersion)) { m_AAVVersion = aavVersion; m_VideoStandard = GetFileTag("NATIVE-VIDEO-STANDARD"); double.TryParse(GetFileTag("NATIVE-FRAME-RATE"), out m_NativeFrameRate); int.TryParse(GetFileTag("OSD-FIRST-LINE"), out m_OsdFirstLine); int.TryParse(GetFileTag("OSD-LAST-LINE"), out m_OsdLastLine); if (m_OsdLastLine > m_Height) m_OsdLastLine = m_Height; if (m_OsdFirstLine < 0) m_OsdFirstLine = 0; m_IntegratedAAVFrames = -1; if (double.TryParse(GetFileTag("EFFECTIVE-FRAME-RATE"), out m_EffectiveFrameRate) && m_NativeFrameRate != 0) { m_IntegratedAAVFrames = (int)Math.Round(m_NativeFrameRate / m_EffectiveFrameRate); m_FrameRate = m_EffectiveFrameRate; // This is important for OCR-ing as the frame rate is used to derive the frame exposure } int.TryParse(GetFileTag("FRAME-STACKING-RATE"), out m_StackingRate); if (m_StackingRate == 1) m_StackingRate = 0; // Video stacked at x1 is a non-stacked video m_Engine = string.Format("AAV{0}", aavVersion); } this.geoLocation = new GeoLocationInfo() { //TODO }; geoLocation = this.geoLocation; }