Beispiel #1
0
        private void PhotoCaptured(PhotoCapturedEventArgs eventArgs)
        {
            _tl.LogMessage("Photo captured filename", eventArgs.FileName);

            string fileName = GetFileNameForDownload(eventArgs);

            if (!Directory.Exists(Path.GetDirectoryName(fileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            }

            eventArgs.CameraDevice.TransferFile(eventArgs.Handle, fileName);

            SensorTemperature = GetSensorTemperature(fileName);

            string newFilePath = RenameFile(fileName, _duration, _startTime);

            ImageReady?.Invoke(this, new ImageReadyEventArgs(newFilePath));

            if ((File.Exists(newFilePath)) && (SaveFile == false))
            {
                File.Delete(newFilePath);
            }

            eventArgs.CameraDevice.IsBusy = false;
        }
Beispiel #2
0
 public YouTube(ProcessFinished processFinished, ImageReady imageReady)
 {
     _processFinished = processFinished;
     _imageReady = imageReady;
     _webClient = new WebClient {Proxy = null}; //Make connection smooth
     _webClient.DownloadDataCompleted += WebClientDownloadDataCompleted;
 }
Beispiel #3
0
        void Save(byte[] buffer, string file)
        {
            Logger.WriteTraceMessage("Saving: " + StorePath);

            if (!Directory.Exists(StorePath))
            {
                Directory.CreateDirectory(StorePath);
            }
            try
            {
                using (FileStream stream = new FileStream(StorePath + "/" + file, FileMode.Create, FileAccess.Write))
                {
                    stream.Write(buffer, 0, buffer.Length);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteTraceMessage("Failed to save file: " + StorePath + ", " + ex.Message);
            }


            string downloadedFilePath = Path.Combine(StorePath, file);

            SensorTemperature = GetSensorTemperature(downloadedFilePath);

            string newFilePath = RenameFile(downloadedFilePath, _duration, _startTime);

            ImageReady?.Invoke(this, new ImageReadyEventArgs(newFilePath));

            if ((File.Exists(newFilePath)) && (SaveFile == false))
            {
                File.Delete(newFilePath);
            }
        }
Beispiel #4
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            int index = EditingIndex;
            int final;

            if (SingleImage)
            {
                final = index;
            }
            else
            {
                final = ApplyAllCheck.Checked ? InputPaths.Length - 1 : EditingIndex;
            }
            for (int i = index; i <= final; i++)
            {
                if (i > index)
                {
                    ProcessNextImage(true);
                }
                if (CurrentImage == null)
                {
                    return;
                }
                bool dithered = AllowDither && DitherChecked;
                var  settings = new MapCreationSettings(CurrentImage, (int)WidthInput.Value, (int)HeightInput.Value, GetInterpolationMode(), dithered, StretchChecked);
                ImageReady?.Invoke(this, settings);
            }
            EditingIndex = final;
            ProcessNextImage(false);
        }
Beispiel #5
0
 public YouTube(ProcessFinished processFinished, ImageReady imageReady)
 {
     _processFinished = processFinished;
     _imageReady      = imageReady;
     _webClient       = new WebClient {
         Proxy = null
     };                                         //Make connection smooth
     _webClient.DownloadDataCompleted += WebClientDownloadDataCompleted;
 }
Beispiel #6
0
        public async Task StartAcquisition(int frameCount)
        {
            var errorCode = Acquisition_DefineDestBuffers(m_AcqDesc, m_ImageData, frameCount, m_ImageHeight, m_ImageWidth);

            CheckError(errorCode);
            errorCode = Acquisition_Acquire_Image(m_AcqDesc, frameCount, 0, HIS_SEQ_AVERAGE, m_OffsetMap, m_GainMap, m_PixelMap);
            CheckError(errorCode);
            await LoopFramesAsync(frameCount);

            ImageReady?.Invoke(this, new ImageEventArgs(m_ImageData, m_ImageWidth, m_ImageHeight, m_ImagePitch));
        }
Beispiel #7
0
        private void MainCamera_DownloadReady(EOSDigital.API.Camera sender, DownloadInfo Info)
        {
            if (!Directory.Exists(StorePath))
            {
                Directory.CreateDirectory(StorePath);
            }
            sender.DownloadFile(Info, StorePath);

            string downloadedFilePath = Path.Combine(StorePath, Info.FileName);

            SensorTemperature = GetSensorTemperature(downloadedFilePath);

            string newFilePath = RenameFile(downloadedFilePath, _duration, _startTime);

            ImageReady?.Invoke(this, new ImageReadyEventArgs(newFilePath));
        }
Beispiel #8
0
        /// <summary>
        /// 取图
        /// </summary>
        public void OnMVImageReadyEventCallback()
        {
            lock (obj)
            {
                try
                {
                    byte[] buffer      = new byte[SizeMax.Width * SizeMax.Height * 3];
                    IntPtr pData       = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
                    uint   nDataLen    = 0;
                    var    stFrameInfo = new MyCamera.MV_FRAME_OUT_INFO();
                    //  stFrameInfo = new MyCamera.MV_FRAME_OUT_INFO_EX();
                    //超时获取一帧,超时时间为1秒

                    var nRet = GetOneFrame(pData, ref nDataLen, (uint)SizeMax.Width * (uint)SizeMax.Height * 3, ref stFrameInfo);

                    // nRet = GetImageBGR(pData, (uint)SizeMax.Width * (uint)SizeMax.Height * 3, ref stFrameInfo);

                    if (MyCamera.MV_OK == nRet)
                    {
                        if (m_bitmap != null)
                        {
                            /* Update the bitmap with the image data. */
                            UpdateBitmap(m_bitmap, buffer, stFrameInfo.nWidth, stFrameInfo.nHeight, false);
                            /* To show the new image, request the display control to update itself. */
                        }
                        else /* A new bitmap is required. */
                        {
                            CreateBitmap(ref m_bitmap, stFrameInfo.nWidth, stFrameInfo.nHeight, false);
                            UpdateBitmap(m_bitmap, buffer, stFrameInfo.nWidth, stFrameInfo.nHeight, false);
                            //* Provide the display control with the new bitmap. This action automatically updates the display. */
                        }
                        bitmapInfo.Bitmap = (Bitmap)m_bitmap.Clone();
                        ImageReady?.Invoke(bitmapInfo);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }
        }
Beispiel #9
0
        private void ConfirmUntil(int final_index)
        {
            int index = EditingIndex;

            for (int i = index; i <= final_index; i++)
            {
                if (i > index)
                {
                    ProcessNextImage(true);
                }
                if (CurrentImage == null)
                {
                    return;
                }
                bool dithered = ApproximateColorOptions && DitherChecked;
                var  settings = new MapCreationSettings(CurrentImage, (int)WidthInput.Value, (int)HeightInput.Value, GetInterpolationMode(), dithered, StretchChecked, GetAlgorithm());
                ImageReady?.Invoke(this, settings);
            }
            EditingIndex = final_index;
            ProcessNextImage(false);
        }
Beispiel #10
0
 protected virtual void OnImages(object sender, ImageEventArgs eventArgs)
 {
     ImageReady.DispatchOnContext <ImageEventArgs>(this, EventContext, eventArgs);
 }
Beispiel #11
0
 private void OnImageReady(Bitmap image)
 {
     ImageReady?.Invoke(image);
 }