private void button1_Click(object sender, EventArgs e) { AdvRecorder recorder = new AdvRecorder(); // First set the values of the standard file metadata recorder.FileMetaData.RecorderName = "Genika"; recorder.FileMetaData.RecorderVersion = "x.y.z"; recorder.FileMetaData.RecorderTimerFirmwareVersion = "a.b.c"; recorder.FileMetaData.CameraModel = "Flea3 FL3-FW-03S3M"; recorder.FileMetaData.CameraSerialNumber = "10210906"; recorder.FileMetaData.CameraVendorNumber = "Point Grey Research"; recorder.FileMetaData.CameraSensorInfo = "Sony ICX414AL (1/2\" 648x488 CCD)"; recorder.FileMetaData.CameraSensorResolution = "648x488"; recorder.FileMetaData.CameraFirmwareVersion = "1.22.3.0"; recorder.FileMetaData.CameraFirmwareBuildTime = "Mon Dec 28 20:15:45 2009"; recorder.FileMetaData.CameraDriverVersion = "2.2.1.6"; // Then define additional metadata, if required recorder.FileMetaData.AddUserTag("TELESCOPE-NAME", "Large Telescope"); recorder.FileMetaData.AddUserTag("TELESCOPE-FL", "8300"); recorder.FileMetaData.AddUserTag("TELESCOPE-FD", "6.5"); recorder.FileMetaData.AddUserTag("CAMERA-DIGITAL-SAMPLIG", "xxx"); recorder.FileMetaData.AddUserTag("CAMERA-HDR-RESPONSE", "yyy"); recorder.FileMetaData.AddUserTag("CAMERA-OPTICAL-RESOLUTION", "zzz"); if (cbxLocationData.Checked) { recorder.LocationData.LongitudeWgs84 = "150*38'27.7\""; recorder.LocationData.LatitudeWgs84 = "-33*39'49.3\""; recorder.LocationData.AltitudeMsl = "284.4M"; recorder.LocationData.MslWgs84Offset = "22.4M"; recorder.LocationData.GpsHdop = "0.7"; } // Define the image size and bit depth byte dynaBits = 16; if (rbPixel16.Checked) { dynaBits = 16; } else if (rbPixel12.Checked) { dynaBits = 12; } else if (rbPixel8.Checked) { dynaBits = 8; } byte cameraDepth = 16; if (rbCamera16.Checked) { cameraDepth = 16; } else if (rbCamera12.Checked) { cameraDepth = 12; } else if (rbCamera8.Checked) { cameraDepth = 8; } recorder.ImageConfig.SetImageParameters(640, 480, cameraDepth, dynaBits); // By default no status section values will be recorded. The user must enable the ones they need recorded and // can also define additional status parameters to be recorded with each video frame recorder.StatusSectionConfig.RecordGain = true; recorder.StatusSectionConfig.RecordGamma = true; int customTagIdCustomGain = recorder.StatusSectionConfig.AddDefineTag("EXAMPLE-GAIN", AdvTagType.UInt32); int customTagIdMessages = recorder.StatusSectionConfig.AddDefineTag("EXAMPLE-MESSAGES", AdvTagType.List16OfAnsiString255); string fileName = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + @"\Filename.adv"); recorder.StartRecordingNewFile(fileName); AdvStatusEntry status = new AdvStatusEntry(); status.AdditionalStatusTags = new object[2]; int imagesCount = GetTotalImages(); bool useCompression = cbxCompress.Checked; for (int i = 0; i < imagesCount; i++) { // NOTE: Moking up some test data uint exposure = GetCurrentImageExposure(i); DateTime timestamp = GetCurrentImageTimeStamp(i); status.Gain = GetCurrentImageGain(i); status.Gamma = GetCurrentImageGamma(i); status.AdditionalStatusTags[customTagIdMessages] = GetCurrentExampleMassages(i); status.AdditionalStatusTags[customTagIdCustomGain] = GetCurrentExampleCustomGain(i); if (rb16BitUShort.Checked) { ushort[] imagePixels = GetCurrentImageBytesIn16(i, dynaBits); recorder.AddVideoFrame( imagePixels, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } else if (rb16BitByte.Checked) { byte[] imageBytes = GetCurrentImageBytes(i, dynaBits); recorder.AddVideoFrame( imageBytes, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvImageData.PixelDepth16Bit, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } else if (rb8BitByte.Checked) { byte[] imageBytes = GetCurrentImageBytes(i, dynaBits); recorder.AddVideoFrame( imageBytes, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvImageData.PixelDepth8Bit, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } } recorder.StopRecording(); MessageBox.Show(string.Format("'{0}' has been created.", fileName)); }
private void button1_Click(object sender, EventArgs e) { AdvRecorder recorder = new AdvRecorder(); // First set the values of the standard file metadata recorder.FileMetaData.RecorderName = "Genika"; recorder.FileMetaData.RecorderVersion = "x.y.z"; recorder.FileMetaData.RecorderTimerFirmwareVersion = "a.b.c"; recorder.FileMetaData.CameraModel = "Flea3 FL3-FW-03S3M"; recorder.FileMetaData.CameraSerialNumber = "10210906"; recorder.FileMetaData.CameraVendorNumber = "Point Grey Research"; recorder.FileMetaData.CameraSensorInfo = "Sony ICX414AL (1/2\" 648x488 CCD)"; recorder.FileMetaData.CameraSensorResolution = "648x488"; recorder.FileMetaData.CameraFirmwareVersion = "1.22.3.0"; recorder.FileMetaData.CameraFirmwareBuildTime = "Mon Dec 28 20:15:45 2009"; recorder.FileMetaData.CameraDriverVersion = "2.2.1.6"; // Then define additional metadata, if required recorder.FileMetaData.AddUserTag("TELESCOPE-NAME", "Large Telescope"); recorder.FileMetaData.AddUserTag("TELESCOPE-FL", "8300"); recorder.FileMetaData.AddUserTag("TELESCOPE-FD", "6.5"); recorder.FileMetaData.AddUserTag("CAMERA-DIGITAL-SAMPLIG", "xxx"); recorder.FileMetaData.AddUserTag("CAMERA-HDR-RESPONSE", "yyy"); recorder.FileMetaData.AddUserTag("CAMERA-OPTICAL-RESOLUTION", "zzz"); if (cbxLocationData.Checked) { recorder.LocationData.LongitudeWgs84 = "150*38'27.7\""; recorder.LocationData.LatitudeWgs84 = "-33*39'49.3\""; recorder.LocationData.AltitudeMsl = "284.4M"; recorder.LocationData.MslWgs84Offset = "22.4M"; recorder.LocationData.GpsHdop = "0.7"; } // Define the image size and bit depth byte dynaBits = 16; if (rbPixel16.Checked) dynaBits = 16; else if (rbPixel12.Checked) dynaBits = 12; else if (rbPixel8.Checked) dynaBits = 8; byte cameraDepth = 16; if (rbCamera16.Checked) cameraDepth = 16; else if (rbCamera12.Checked) cameraDepth = 12; else if (rbCamera8.Checked) cameraDepth = 8; recorder.ImageConfig.SetImageParameters(640, 480, cameraDepth, dynaBits); // By default no status section values will be recorded. The user must enable the ones they need recorded and // can also define additional status parameters to be recorded with each video frame recorder.StatusSectionConfig.RecordGain = true; recorder.StatusSectionConfig.RecordGamma = true; int customTagIdCustomGain = recorder.StatusSectionConfig.AddDefineTag("EXAMPLE-GAIN", AdvTagType.UInt32); int customTagIdMessages = recorder.StatusSectionConfig.AddDefineTag("EXAMPLE-MESSAGES", AdvTagType.List16OfAnsiString255); string fileName = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + @"\Filename.adv"); recorder.StartRecordingNewFile(fileName); AdvStatusEntry status = new AdvStatusEntry(); status.AdditionalStatusTags = new object[2]; int imagesCount = GetTotalImages(); bool useCompression = cbxCompress.Checked; for (int i = 0; i < imagesCount; i++) { // NOTE: Moking up some test data uint exposure = GetCurrentImageExposure(i); DateTime timestamp = GetCurrentImageTimeStamp(i); status.Gain = GetCurrentImageGain(i); status.Gamma = GetCurrentImageGamma(i); status.AdditionalStatusTags[customTagIdMessages] = GetCurrentExampleMassages(i); status.AdditionalStatusTags[customTagIdCustomGain] = GetCurrentExampleCustomGain(i); if (rb16BitUShort.Checked) { ushort[] imagePixels = GetCurrentImageBytesIn16(i, dynaBits); recorder.AddVideoFrame( imagePixels, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } else if (rb16BitByte.Checked) { byte[] imageBytes = GetCurrentImageBytes(i, dynaBits); recorder.AddVideoFrame( imageBytes, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvImageData.PixelDepth16Bit, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } else if (rb8BitByte.Checked) { byte[] imageBytes = GetCurrentImageBytes(i, dynaBits); recorder.AddVideoFrame( imageBytes, // NOTE: Use with caution! Using compression is slower and may not work at high frame rates // i.e. it may take longer to compress the data than for the next image to arrive on the buffer useCompression, AdvImageData.PixelDepth8Bit, AdvTimeStamp.FromDateTime(timestamp), exposure, status); } } recorder.StopRecording(); MessageBox.Show(string.Format("'{0}' has been created.", fileName)); }