コード例 #1
0
ファイル: TakePhoto.cs プロジェクト: mnabaci/DreamBox
        public TakePhoto(ImageCollection image, NikonDevice device)
        {
            InitializeComponent();
            Cursor.Hide();
            this.DoubleBuffered = true;

            CenterComponents();
            // Hook up device capture events
            this.device             = device;
            device.ImageReady      += new ImageReadyDelegate(device_ImageReady);
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);

            counter = new Counter();
            Image   = image;
            this.BackgroundImage = new Bitmap(Image.BackgroundImage);
            printImage           = new Bitmap(Image.BackgroundImage);
            timer          = new System.Timers.Timer(1000);
            timer.Elapsed += new ElapsedEventHandler(CountDown);

            closingTimer = new System.Timers.Timer(6000);

            CounterItem cItem = counter.CountDown();

            pictureBox1.Image = cItem.Number;
            pictureBox2.Image = cItem.Smile;
            timer.Start();
        }
コード例 #2
0
ファイル: NikonCamera.cs プロジェクト: daleghent/NINA
 private void Camera_ImageReady(NikonDevice sender, NikonImage image)
 {
     Logger.Debug("Image ready");
     _memoryStream = new MemoryStream(image.Buffer);
     Logger.Debug("Setting Download Exposure Task to complete");
     _downloadExposure.TrySetResult(null);
 }
コード例 #3
0
        void device_ThumbnailReady(NikonDevice sender, NikonThumbnail thumbnail)
        {
            // We're expecting to get RGB24 data, make sure that the format is correct
            if (thumbnail.Stride / thumbnail.Width < 3)
            {
                return;
            }

            // Note: Thumbnail pixels are uncompressed RGB24 - here's an example of how to jpeg encode it

            JpegBitmapEncoder encoder = new JpegBitmapEncoder();

            encoder.QualityLevel = 90;

            BitmapSource source = BitmapFrame.Create(
                thumbnail.Width,
                thumbnail.Height,
                96.0,
                96.0,
                System.Windows.Media.PixelFormats.Rgb24,
                null,
                thumbnail.Pixels,
                thumbnail.Stride);

            BitmapFrame frame = BitmapFrame.Create(source);

            encoder.Frames.Add(frame);

            MemoryStream stream = new MemoryStream();

            encoder.Save(stream);

            Save(stream.GetBuffer(), "thumbnail.jpg");
        }
コード例 #4
0
        private void Mgr_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            NikonManager tmpManager = _activeNikonManager;

            var connected = false;

            try
            {
                _activeNikonManager = sender;
                _activeNikonManager.DeviceRemoved += Mgr_DeviceRemoved;

                Logger.WriteTraceMessage("NikonManager starting device init: " + _activeNikonManager.Name);
                Init(device);
                Name = _camera.Name;

                if (Name == "")
                {
                    _activeNikonManager = tmpManager;
                }

                connected = true;
            }
            catch (Exception ex)
            {
                Logger.WriteTraceMessage(ex.ToString());
            }
            finally
            {
                Connected = connected;
                _cameraConnected.TrySetResult(Connected);
            }
        }
コード例 #5
0
 private void Camera_ImageReady(NikonDevice sender, NikonImage image)
 {
     Logger.WriteTraceMessage("Image ready");
     Save(image.Buffer, "image" + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef"));
     Logger.WriteTraceMessage("Setting Download Exposure Taks to complete");
     _downloadExposure.TrySetResult(null);
 }
        void device_ImageReady(NikonDevice sender, NikonImage image)
        {
            if (single_path_tb.Text == string.Empty)
            {
                MessageBox.Show("Select save path");
                return;
            }



            string path = single_path_tb.Text + page_no_lbl.Text + ".jpg";

            if (click_no == 2)
            {
                transfre_to_storage(path, image);
            }
            else
            {
                using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
                {
                    stream.Write(image.Buffer, 0, image.Buffer.Length);
                }
            }
            LoadImageSync_forStrip(single_path_tb.Text + page_no_lbl.Text + ".jpg", page_no_lbl.Text);
            if (page_in_range((Convert.ToDecimal(page_no_lbl.Text) + 1).ToString()))
            {
                page_no_lbl.Text = (Convert.ToDecimal(page_no_lbl.Text) + 1).ToString();
            }
            else
            {
                MessageBox.Show("أخر صفحة فى المهمة");
            }
        }
コード例 #7
0
ファイル: MainScreen.cs プロジェクト: mnabaci/DreamBox
 private void MainScreen_FormClosing(object sender, FormClosingEventArgs e)
 {
     manager.DeviceAdded   -= new DeviceAddedDelegate(manager_DeviceAdded);
     manager.DeviceRemoved -= new DeviceRemovedDelegate(manager_DeviceRemoved);
     manager.Shutdown();
     device  = null;
     manager = null;
 }
コード例 #8
0
ファイル: NikonController.cs プロジェクト: mcauzzi/Cupola
 private void DeviceImageReady(NikonDevice sender, NikonImage image)
 {
     Console.WriteLine("Immagine Ricevuta!");
     if (SaveToPc)
     {
         SaveToFile(image.Buffer);
     }
     OnReceived(image);
 }
コード例 #9
0
        private static void PrintCapabilities(NikonDevice device)
        {
            Console.WriteLine("Capabilities:");

            // 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($"{"Id",-14}: {cap.ulID.ToString()}");
                Console.WriteLine($"{"Description",-14}: {cap.GetDescription()}");
                Console.WriteLine($"{"Type",-14}: {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($"{"Value",-14}: {value}");
                }

                // Print spacing between capabilities
                Console.WriteLine();
                Console.WriteLine();
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 private void manager_DeviceAdded(NikonManager sender, NikonDevice device)
 {
     Device = device;
     // Wire device events
     Device.ImageReady += new ImageReadyDelegate(device_ImageReady);
     // Enable buttons
     button_takePicture.IsEnabled = true;
     button_takePicture.Content   = "Start";
     ToggleLiveView();
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: RITMechArch/MechArch
        void _device_ImageReady(NikonDevice sender, NikonImage image)
        {
            // Save captured image to disk
            string filename = "image" + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef");

            using (FileStream s = new FileStream(filename, FileMode.Create, FileAccess.Write))
            {
                s.Write(image.Buffer, 0, image.Buffer.Length);
            }
        }
コード例 #13
0
        public Capabilities(NikonBase obj, NkMAIDCapInfo cap)
        {
            _object = obj;
            _cap    = cap;
            NikonDevice device = _object as NikonDevice;

            if (device != null)
            {
                device.CapabilityValueChanged += new CapabilityChangedDelegate(device_CapabilityValueChanged);
            }
        }
コード例 #14
0
ファイル: LiveView.cs プロジェクト: gmacintyre/Photobooth
        public void Start(NikonDevice device)
        {
            for (var i = 0; i < 5; i++)
            {
                device.LiveViewEnabled = true;

                CurrentImage.Source = LoadImage(device.GetLiveViewImage().JpegBuffer);

                device.LiveViewEnabled = false;
            }
        }
コード例 #15
0
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            if (_device == null)
            {
                // Save device
                _device = device;

                // Signal that we got a device
                _waitForDevice.Set();
            }
        }
コード例 #16
0
ファイル: SlappingForm.cs プロジェクト: gIsaak/SlappingApp
 void manager_DeviceAdded(NikonManager sender, NikonDevice device)
 {
     this.device = device;
     // Set the device name
     cameraLabel.Text = device.Name;
     // Enable buttons
     ToggleCameraButtons(true);
     // Hook up device capture events
     device.ImageReady      += new ImageReadyDelegate(device_ImageReady);
     device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);
 }
コード例 #17
0
ファイル: SlappingForm.cs プロジェクト: gIsaak/SlappingApp
 void manager_DeviceRemoved(NikonManager sender, NikonDevice device)
 {
     this.device = null;
     // Stop live view timer
     liveViewTimer.Stop();
     // Clear device name
     cameraLabel.Text = "No Camera";
     // Disable buttons
     ToggleCameraButtons(false);
     // Clear live view picture
     pictureBox.Image = null;
 }
コード例 #18
0
ファイル: DrawingForm.cs プロジェクト: gIsaak/SlappingApp
        void manager_DeviceRemoved(NikonManager sender, NikonDevice device)
        {
            this.device = null;

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

            // Disable buttons
            ToggleButtons(false);

            // Clear live view picture
            imageBox.Image = null;
        }
コード例 #19
0
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            Console.WriteLine("=> {0}, {1}", sender.Id, sender.Name);

            if (_device == null)
            {
                // Save device
                _device = device;

                // Signal that we got a device
                _waitForDevice.Set();
            }
        }
コード例 #20
0
        void device_CaptureComplete(NikonDevice sender, int data)
        {
            // Re-enable buttons when the capture completes
            not_tasweer_design(true);

            if (device.LiveViewEnabled)
            {
                live_now_1.Visible = true;
                live_now_2.Visible = true;
            }

            pic_count_tb.Text = get_pic_count().ToString();
        }
コード例 #21
0
        public void Init(NikonDevice cam)
        {
            Logger.WriteTraceMessage("Initializing Nikon camera '" + cam.Name + "'");
            _camera                  = cam;
            _camera.ImageReady      += Camera_ImageReady;
            _camera.CaptureComplete += _camera_CaptureComplete;


            //Set to shoot in RAW
            Logger.WriteTraceMessage("Setting compression to RAW");
            var compression = _camera.GetEnum(eNkMAIDCapability.kNkMAIDCapability_CompressionLevel);

            for (int i = 0; i < compression.Length; i++)
            {
                var val = compression.GetEnumValueByIndex(i);
                if (val.ToString() == "RAW")
                {
                    compression.Index = i;
                    _camera.SetEnum(eNkMAIDCapability.kNkMAIDCapability_CompressionLevel, compression);
                    break;
                }
            }

            //Ensure camera is in Manual mode

            /*var exposureMode = _camera.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ExposureMode);
             * if (exposureMode.Index != (int)eNkMAIDExposureMode.kNkMAIDExposureMode_Manual)
             * {
             *  Logger.WriteTraceMessage("Camera not set to Manual mode. Switching now.");
             *  exposureMode.Index = (int)eNkMAIDExposureMode.kNkMAIDExposureMode_Manual;
             *  _camera.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ExposureMode, exposureMode);
             * }*/
            //Changed to function
            SetCameraToManual();

            GetIsoList();
            GetShutterSpeeds();
            GetCapabilities();


            /* Setting SaveMedia when supported, to save images via SDRAM and not to the internal memory card */
            if (Capabilities.ContainsKey(eNkMAIDCapability.kNkMAIDCapability_SaveMedia) && Capabilities[eNkMAIDCapability.kNkMAIDCapability_SaveMedia].CanSet())
            {
                _camera.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_SaveMedia, (uint)eNkMAIDSaveMedia.kNkMAIDSaveMedia_SDRAM);
            }
            else
            {
                Logger.WriteTraceMessage("Setting SaveMedia Capability not available. This has to be set manually or is not supported by this model.");
            }
        }
コード例 #22
0
 public void Disconnect()
 {
     Connected = false;
     liveViewTimer.Stop();
     _lvCapture = false;
     _camera.LiveViewEnabled = false;
     _camera = null;
     _activeNikonManager?.Shutdown();
     _nikonManagers?.Clear();
     _nikonManagers      = null;
     _activeNikonManager = null;
     //_camera.ImageReady -= Camera_ImageReady;
     //_camera.CaptureComplete -= _camera_CaptureComplete;
 }
コード例 #23
0
        void _device_ImageReady(NikonDevice sender, NikonImage image)
        {
            string dts      = DateTime.Now.ToString("HHmmss");
            string filename = string.Format("{0}_image{1}", dts, ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef"));

            Console.WriteLine("save {0}", filename);
            // Save captured image to disk
            //string filename = "image" + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef");

            using (FileStream s = new FileStream(filename, FileMode.Create, FileAccess.Write))
            {
                s.Write(image.Buffer, 0, image.Buffer.Length);
            }
        }
コード例 #24
0
        void manager_DeviceAdded(NikonManager sender, NikonDevice device)
        {
            this.device = device;

            // Set the device name
            label_name.Text = device.Name;
            device.SaveMedia(1);
            // Enable buttons
            not_tasweer_design(true);

            // Hook up device capture events
            device.ImageReady      += new ImageReadyDelegate(device_ImageReady);
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);
        }
コード例 #25
0
ファイル: NikonCamera.cs プロジェクト: daleghent/NINA
        public void Init(NikonDevice cam)
        {
            Logger.Debug("Initializing Nikon camera");
            _camera                  = cam;
            _camera.ImageReady      += Camera_ImageReady;
            _camera.CaptureComplete += _camera_CaptureComplete;

            GetCapabilities();

            if (Capabilities.TryGetValue(eNkMAIDCapability.kNkMAIDCapability_CompressionLevel, out var compressionCapability))
            {
                if (compressionCapability.CanGet() && compressionCapability.CanSet())
                {
                    //Set to shoot in RAW
                    Logger.Debug("Setting compression to RAW");
                    var compression = _camera.GetEnum(eNkMAIDCapability.kNkMAIDCapability_CompressionLevel);
                    for (int i = 0; i < compression.Length; i++)
                    {
                        var val = compression.GetEnumValueByIndex(i);
                        if (val.ToString() == "RAW")
                        {
                            compression.Index = i;
                            _camera.SetEnum(eNkMAIDCapability.kNkMAIDCapability_CompressionLevel, compression);
                            break;
                        }
                    }
                }
                else
                {
                    Logger.Trace($"Cannot set compression level: CanGet {compressionCapability.CanGet()} - CanSet {compressionCapability.CanSet()}");
                }
            }
            else
            {
                Logger.Trace("Compression Level capability not available");
            }

            GetShutterSpeeds();

            /* Setting SaveMedia when supported, to save images via SDRAM and not to the internal memory card */
            if (Capabilities.ContainsKey(eNkMAIDCapability.kNkMAIDCapability_SaveMedia) && Capabilities[eNkMAIDCapability.kNkMAIDCapability_SaveMedia].CanSet())
            {
                _camera.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_SaveMedia, (uint)eNkMAIDSaveMedia.kNkMAIDSaveMedia_SDRAM);
            }
            else
            {
                Logger.Trace("Setting SaveMedia Capability not available. This has to be set manually or is not supported by this model.");
            }
        }
コード例 #26
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");
        }
コード例 #27
0
ファイル: SlappingForm.cs プロジェクト: gIsaak/SlappingApp
        void device_ImageReady(NikonDevice sender, NikonImage image)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = (image.Type == NikonImageType.Jpeg) ?
                            "Jpeg Image (*.jpg)|*.jpg" :
                            "Nikon NEF (*.nef)|*.nef";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream stream = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write))
                {
                    stream.Write(image.Buffer, 0, image.Buffer.Length);
                }
            }
        }
コード例 #28
0
 private void device_ImageReady(NikonDevice sender, NikonImage image)
 {
     Console.WriteLine("Image Ready");
     photostrip.Push(image);
     //fill dat strip
     LiveImage.Source = photostrip.LoadWindowsControlImage(image.Buffer);
     if (photostrip.Pictures.Count() != photostrip.Max)
     {
         TakePicture();
     }
     else
     {
         photostrip.DrawStrip();
     }
 }
コード例 #29
0
ファイル: TakePhoto.cs プロジェクト: mnabaci/DreamBox
 void device_CaptureComplete(NikonDevice sender, int data)
 {
     if (ClosingTimerStarted)
     {
         closingTimer.Elapsed -= new ElapsedEventHandler(CloseForm);
         closingTimer.Stop();
         ClosingTimerStarted = false;
     }
     test                 = new GreenBox(Image, Position.BottomLeft);
     test.Hue             = 2;
     printImage           = test.CImage;
     this.BackgroundImage = new Bitmap(printImage);
     pictureBox1.Image    = null;
     Print(printImage);
 }
コード例 #30
0
ファイル: Form1.cs プロジェクト: andrewHolsaeter/CameraApp
        void device_ImageReady(NikonDevice sender, NikonImage image)
        {
            //save preview
            if (image.Type == NikonImageType.Jpeg)
            {
                using (FileStream stream = new FileStream(temppath, FileMode.Create, FileAccess.Write))
                {
                    stream.Write(image.Buffer, 0, image.Buffer.Length);
                }
                //preview the jpeg image
                pictureBox1.ImageLocation = temppath;
                pictureBox1.SizeMode      = PictureBoxSizeMode.StretchImage;
            }

            if (image.Type == NikonImageType.Raw)
            {
                bool saveImage = false;
                if (timeLapseActive)
                {
                    saveImage = true;    //want to automatically save timelapse photos so message box doesn't appear every time
                    timelapseAppender++; //append to keep track and avoid overwrite
                    savePath = "timelapse-" + timelapseAppender.ToString();
                }
                //prompt to save image if not timelapse
                else
                {
                    if (MessageBox.Show("Would you like to save this image?", "caption", MessageBoxButtons.YesNo)
                        == DialogResult.Yes)
                    {
                        saveImage = true;
                        captureAppender++; //append to keep track and avoid overwrite
                        savePath = "capture-" + captureAppender.ToString();
                    }
                }
                if (saveImage == true)
                {
                    //set savepath
                    string currentPath = rawpath + savePath + ((image.Type == NikonImageType.Raw) ? ".NEF" : ".jpg");
                    //save photo
                    using (FileStream stream = new FileStream(currentPath, FileMode.Create, FileAccess.Write))
                    {
                        stream.Write(image.Buffer, 0, image.Buffer.Length);
                    }
                }
            }
            string elapseTime = timer.Elapsed.TotalSeconds.ToString(); //for seeing how long this took since capture method was fired
            // MessageBox.Show(String.Format(@"Time it took to process {0}, was {1} seconds", image.Type.ToString(), elapseTime));
        }