Inheritance: NikonBase
示例#1
0
        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);
            }
        }
示例#2
0
 private void OnDeviceAdded(NikonManager sender, NikonDevice device)
 {
     if (_deviceAdded != null)
     {
         _deviceAdded(sender, device);
     }
 }
示例#3
0
 void OnDeviceRemoved(NikonManager sender, NikonDevice device)
 {
     if (_deviceRemoved != null)
     {
         _deviceRemoved(sender, device);
     }
 }
示例#4
0
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            if (_device == null)
            {
                // Save device
                _device = device;

                // Signal that we got a device
                _waitForDevice.Set();
            }
        }
示例#5
0
        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);
            }
        }
示例#6
0
        public Form1()
        {
            InitializeComponent();

            // Disable buttons
            ToggleButtons(false);

            // Initialize live view timer
            liveViewTimer = new Timer();
            liveViewTimer.Tick += new EventHandler(liveViewTimer_Tick);
            liveViewTimer.Interval = 1000 / 30;

            // Initialize Nikon manager
            manager = new NikonManager("Type0003.md3");
            manager.DeviceAdded += new DeviceAddedDelegate(manager_DeviceAdded);
            manager.DeviceRemoved += new DeviceRemovedDelegate(manager_DeviceRemoved);
        }
示例#7
0
        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);
            }
        }
示例#8
0
        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);
            }
        }
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            camera = device;

            // Set shooting mode to 'continuous, highspeed'
            NikonEnum shootingMode = camera.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode);
            shootingMode.Index = (int)eNkMAIDShootingMode.kNkMAIDShootingMode_CH;
            camera.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode, shootingMode);
        }
示例#10
0
        public Model()
        {
            _objects = new ObservableCollection<ObjectModel>();
            _managers = new List<NikonManager>();

            string[] md3s = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.md3", SearchOption.AllDirectories);

            if (md3s.Length == 0)
            {
                Log.GetInstance().WriteLine("Couldn't find any MD3 files in " + Directory.GetCurrentDirectory());
                Log.GetInstance().WriteLine("Download MD3 files from Nikons SDK website: https://sdk.nikonimaging.com/apply/");
            }

            foreach (string md3 in md3s)
            {
                const string requiredDllFile = "NkdPTP.dll";

                string requiredDllPath = Path.Combine(Path.GetDirectoryName(md3), requiredDllFile);

                if (!File.Exists(requiredDllPath))
                {
                    Log.GetInstance().WriteLine("Warning: Couldn't find " + requiredDllFile + " in " + Path.GetDirectoryName(md3) + ". The library will not work properly without it!");
                }

                Log.GetInstance().WriteLine("Opening " + md3);

                NikonManager manager = new NikonManager(md3);
                manager.DeviceAdded += new DeviceAddedDelegate(_manager_DeviceAdded);
                manager.DeviceRemoved += new DeviceRemovedDelegate(_manager_DeviceRemoved);

                _objects.Add(new ObjectModel(manager));
                _managers.Add(manager);
            }
        }
示例#11
0
        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);
            }
        }
 public void InitializeCameraFeed()
 {
     manager = new NikonManager("Type0003.md3");
     manager.DeviceAdded += new DeviceAddedDelegate(manager_DeviceAdded);
 }
示例#13
0
 void OnDeviceRemoved(NikonManager sender, NikonDevice device)
 {
     if (_deviceRemoved != null)
     {
         _deviceRemoved(sender, device);
     }
 }
示例#14
0
文件: Form1.cs 项目: osamu3/tackPic
        public Form1()
        {
            InitializeComponent();

            // Disable buttons
            ToggleButtons(false);

            // ライブビューのフレームレートをタイマーでセット
            _LiveViewTimer = new System.Windows.Forms.Timer();
            _LiveViewTimer.Tick += new System.EventHandler(liveViewTimer_Tick);
            _LiveViewTimer.Interval = 1000;//1秒間に1回 1000/30で 30フレーム/秒

            // Nikon managerオブジェクト作成しイベントハンドラを登録する。
            _Manager = new NikonManager("Type0011.md3");
            _Manager.DeviceAdded += new DeviceAddedDelegate(manager_DeviceAdded);
            _Manager.DeviceRemoved += new DeviceRemovedDelegate(manager_DeviceRemoved);

            // SignalR オブジェクト作成しHubのイベントハンドラを登録する。
            setHubConnection();
        }
示例#15
0
文件: Form1.cs 项目: osamu3/tackPic
        // カメラ接続終了時のイベントメソッド(コールバック)
        void manager_DeviceRemoved(NikonManager sender, NikonDevice device)
        {
            this._Device = null;

            // Stop live view timer
            _LiveViewTimer.Stop();

            // Clear device name
            label_name.Text = "No Camera";

            // Disable buttons
            ToggleButtons(false);

            // Clear live view picture
            picBoxPhotImage.Image = null;
        }
示例#16
0
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            this.device = device;

            // Set the device name
            label_name.Text = device.Name;

            // Enable buttons
            ToggleButtons(true);

            // Hook up device capture events
            device.ImageReady += new ImageReadyDelegate(device_ImageReady);
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);
        }
示例#17
0
 void _manager_DeviceAdded(NikonManager sender, NikonDevice device)
 {
     _objects.Add(new ObjectModel(device));
     OnPropertyChanged("NewestIndex");
 }
示例#18
0
        void _manager_DeviceRemoved(NikonManager sender, NikonDevice device)
        {
            ObjectModel deviceModelToRemove = null;

            foreach (ObjectModel deviceModel in _objects)
            {
                if (deviceModel.Object == device)
                {
                    deviceModelToRemove = deviceModel;
                }
            }

            _objects.Remove(deviceModelToRemove);
            OnPropertyChanged("NewestIndex");
        }
示例#19
0
文件: Form1.cs 项目: osamu3/tackPic
        // カメラ接続開始時のイベントメソッド(コールバック)
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            this._Device = device;

            // Set the device name
            label_name.Text = device.Name;

            // Enable buttons
            ToggleButtons(true);

            // 撮影画像のバッファへの転送完了イベント
            device.ImageReady += new ImageReadyDelegate(device_ImageReady);
            // 撮影完了時のイベント(トグルボタンOFF→ON)
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);
        }