public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Hook up capture events _device.ImageReady += _device_ImageReady; _device.CaptureComplete += _device_CaptureComplete; // Capture _device.Capture(); // Wait for the capture to complete _waitForCaptureComplete.WaitOne(); // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }
public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Enable live view (required for manual focus) _device.LiveViewEnabled = true; // Get the current manual focus 'drive step' NikonRange driveStep = _device.GetRange(eNkMAIDCapability.kNkMAIDCapability_MFDriveStep); // Set the drive step to max driveStep.Value = driveStep.Max; _device.SetRange(eNkMAIDCapability.kNkMAIDCapability_MFDriveStep, driveStep); // Drive all the way to 'closest' DriveManualFocus(eNkMAIDMFDrive.kNkMAIDMFDrive_InfinityToClosest); // Set the drive step to something small driveStep.Value = 200.0; _device.SetRange(eNkMAIDCapability.kNkMAIDCapability_MFDriveStep, driveStep); // Drive manual focus towards infinity in small steps for (int i = 0; i < 10; i++) { DriveManualFocus(eNkMAIDMFDrive.kNkMAIDMFDrive_ClosestToInfinity); } // Disable live view _device.LiveViewEnabled = false; // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }
public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Hook up video events _device.VideoFragmentReady += _device_VideoFragmentReady; _device.VideoRecordingInterrupted += _device_VideoRecordingInterrupted; // Start video recording _device.LiveViewEnabled = true; _device.StartRecordVideo(); // Record for a while... Thread.Sleep(TimeSpan.FromSeconds(4.0)); // Stop video recording _device.StopRecordVideo(); _device.LiveViewEnabled = false; // Wait for the video download to complete _waitForVideoCompleted.WaitOne(); // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }
public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Set shooting mode to 'continuous, highspeed' NikonEnum shootingMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode); shootingMode.Index = (int)eNkMAIDShootingMode.kNkMAIDShootingMode_CH; _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode, shootingMode); // Set number of continuous captures - in this case we want 5 _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 5); // Hook up capture events _device.ImageReady += _device_ImageReady; _device.CaptureComplete += _device_CaptureComplete; // Capture _device.Capture(); // Wait for the capture to complete _waitForCaptureComplete.WaitOne(); // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }
public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Get 'info' struct for each supported capability NkMAIDCapInfo[] caps = _device.GetCapabilityInfo(); // Iterate through all supported capabilities foreach (NkMAIDCapInfo cap in caps) { // Print ID, description and type Console.WriteLine(string.Format("{0, -14}: {1}", "Id", cap.ulID.ToString())); Console.WriteLine(string.Format("{0, -14}: {1}", "Description", cap.GetDescription())); Console.WriteLine(string.Format("{0, -14}: {1}", "Type", cap.ulType.ToString())); // Try to get the capability value string value = null; // First, check if the capability is readable if (cap.CanGet()) { // Choose which 'Get' function to use, depending on the type switch (cap.ulType) { case eNkMAIDCapType.kNkMAIDCapType_Unsigned: value = _device.GetUnsigned(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_Integer: value = _device.GetInteger(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_String: value = _device.GetString(cap.ulID); break; case eNkMAIDCapType.kNkMAIDCapType_Boolean: value = _device.GetBoolean(cap.ulID).ToString(); break; // Note: There are more types - adding the rest is left // as an exercise for the reader. } } // Print the value if (value != null) { Console.WriteLine(string.Format("{0, -14}: {1}", "Value", value)); } // Print spacing between capabilities Console.WriteLine(); Console.WriteLine(); } // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }