コード例 #1
0
ファイル: Form1.cs プロジェクト: andrewHolsaeter/CameraApp
        void liveViewTimer_Tick(object sender, EventArgs e)
        {
            if (timeLapseActive)
            {
                return;
            }
            //clear picture box
            NikonLiveViewImage image = null;

            //Get live view image
            try
            {
                image = device.GetLiveViewImage();
            }
            catch
            {
                liveViewTimer.Stop();
            }

            // Set live view image on picture box
            if (image != null)
            {
                MemoryStream stream = new MemoryStream(image.JpegBuffer);
                pictureBox1.Image    = Image.FromStream(stream);
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
        }
        void liveViewTimer_Tick(object sender, EventArgs e)
        {
            if (device == null)
            {
                return;
            }
            // Get live view image
            NikonLiveViewImage image = null;

            //niko

            try
            {
                image = device.GetLiveViewImage();
            }
            catch (NikonException)
            {
                liveViewTimer.Stop();
            }

            // Set live view image on picture box
            if (image != null)
            {
                MemoryStream stream = new MemoryStream(image.JpegBuffer);
                pictureBox1.Image = getlife_pic(System.Drawing.Image.FromStream(stream));
            }
        }
コード例 #3
0
ファイル: DrawingForm.cs プロジェクト: gIsaak/SlappingApp
        void liveViewTimer_Tick(object sender, EventArgs e)
        {
            // Get live view image
            NikonLiveViewImage image = null;

            try
            {
                image = device.GetLiveViewImage();
            }
            catch (NikonException)
            {
                liveViewTimer.Stop();
            }

            // Set live view image on picture box
            if (image != null)
            {
                MemoryStream stream = new MemoryStream(image.JpegBuffer);
                // Uncomment to directly display memory stream on pictureBox (NOT imageBox)
                //pictureBox.Image = Image.FromStream(stream);

                //inputImage type is System.Drawing.Image
                Bitmap bitmapImage = new Bitmap(Image.FromStream(stream));

                Rectangle  rectangle = new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height);                                           //System.Drawing
                BitmapData bmpData   = bitmapImage.LockBits(rectangle, ImageLockMode.ReadWrite, bitmapImage.PixelFormat);                    //System.Drawing.Imaging

                Image <Bgr, byte> outputImage = new Image <Bgr, byte>(bitmapImage.Width, bitmapImage.Height, bmpData.Stride, bmpData.Scan0); //(IntPtr)

                imageBox.Image = outputImage;
            }
        }
コード例 #4
0
ファイル: NikonController.cs プロジェクト: mcauzzi/Cupola
        public NikonLiveViewImage GetLiveView( )
        {
            NikonLiveViewImage image = null;

            try
            {
                image = dev.GetLiveViewImage();
            }
            catch (NikonException)
            {
                Console.WriteLine("Errore LiveView");
            }

            return(image);
        }
コード例 #5
0
        void liveViewTimer_Tick(object sender, EventArgs e)
        {
            // Get live view image
            NikonLiveViewImage image = null;

            try
            {
                image = _camera.GetLiveViewImage();
            }
            catch (NikonException ex)
            {
                Logger.WriteTraceMessage("Failed to get live view image: " + ex.ToString());
                _lvCapture = false;
                liveViewTimer.Stop();
            }

            if (image == null)
            {
                liveViewTimer.Stop();
                return;
            }


            ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
            {
                Logger.WriteTraceMessage("Reading Memory Stream");
                MemoryStream stream = new MemoryStream(image.JpegBuffer);
                Logger.WriteTraceMessage("Converting to Bitimap");
                var Evf_BmpTMP = new Bitmap(Image.FromStream(stream));
                Bitmap Evf_Bmp = Evf_BmpTMP.Clone(new Rectangle(0, 0, Evf_BmpTMP.Width, Evf_BmpTMP.Height), PixelFormat.Format24bppRgb);
                Logger.WriteTraceMessage("Grabbing the Sizes");
                if (LvFrameHeight == 0 || LvFrameWidth == 0)
                {
                    LvFrameWidth  = Evf_Bmp.Width;
                    LvFrameHeight = Evf_Bmp.Height;
                }
                if (LiveViewImageReady != null && _lvCapture)
                {
                    Logger.WriteTraceMessage("Sending to Array");
                    LiveViewImageReady(this, new LiveViewImageReadyEventArgs(Evf_Bmp));
                    _lvCapture = false;
                }
            }));
        }
コード例 #6
0
        void _timer_Tick(object sender, EventArgs e)
        {
            NikonDevice device = _object as NikonDevice;

            Debug.Assert(device != null);

            NikonLiveViewImage liveViewImage = null;

            try
            {
                liveViewImage = device.GetLiveViewImage();
            }
            catch (NikonException ex)
            {
                Log.GetInstance().WriteLine("Failed to get live view image: " + ex.ToString());
            }

            if (liveViewImage == null)
            {
                _timer.Stop();
                return;
            }

            // Note: Decode the live view jpeg image on a seperate thread to keep the UI responsive

            ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
            {
                Debug.Assert(liveViewImage != null);

                JpegBitmapDecoder decoder = new JpegBitmapDecoder(
                    new MemoryStream(liveViewImage.JpegBuffer),
                    BitmapCreateOptions.None,
                    BitmapCacheOption.OnLoad);

                Debug.Assert(decoder.Frames.Count > 0);
                BitmapFrame frame = decoder.Frames[0];

                Dispatcher.CurrentDispatcher.Invoke((Action)(() =>
                {
                    SetLiveViewImage(frame);
                }));
            }));
        }
コード例 #7
0
        public void liveViewTimer_Tick(object sender, EventArgs e)
        {
            // Get live view image
            NikonLiveViewImage image = null;

            try
            {
                image = Device.GetLiveViewImage();
            }
            catch (NikonException)
            {
                liveViewTimer.Stop();
            }

            // Set live view image on picture box
            if (image != null)
            {
                LiveImage.Source = photostrip.LoadWindowsControlImage(image.JpegBuffer);
            }
        }
コード例 #8
0
ファイル: SlappingForm.cs プロジェクト: gIsaak/SlappingApp
        void liveViewTimer_Tick(object sender, EventArgs e)
        {
            // Get live view image
            NikonLiveViewImage image = null;

            try
            {
                image = device.GetLiveViewImage();
            }
            catch (NikonException)
            {
                liveViewTimer.Stop();
            }
            // Set live view image on picture box
            if (image != null)
            {
                MemoryStream stream = new MemoryStream(image.JpegBuffer);
                pictureBox.Image = Image.FromStream(stream);
            }
        }
コード例 #9
0
        void DriveManualFocus(eNkMAIDMFDrive direction)
        {
            // Start driving the manual focus motor
            _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_MFDrive, (uint)direction);

            // Keep looping here until drive is complete
            bool isDriving;

            do
            {
                // Get the most recent live view image
                NikonLiveViewImage image = _device.GetLiveViewImage();

                // NOTE: For Type0003.md3, the drive state flag is located at index 30 - this might
                //       not be the case for other MD3 files. Please double check your SDK documentation.
                const int driveStateIndex = 30;

                isDriving = (image.HeaderBuffer[driveStateIndex] > 0);
            }while (isDriving);
        }