Beispiel #1
0
 public static WaitForm GetInstance()
 {
     if (_instance == null)
     {
         lock (lockHelper)
         {
             if (_instance == null)
             {
                 _instance = new WaitForm();
             }
         }
     }
     return _instance;
 }
Beispiel #2
0
        //private static void HandleMutiCapture(Image<Bgr, Byte> img, XCamera cam)
        //{
        //    try
        //    {
        //        if (_captureState == CaptureState.MULT_CAPTURE_TRIGGER_ON)
        //        {
        //            if (_captureCnt < cam.CapturePara.MutiCaptureCount)
        //            {
        //                SaveImageToDefaultPath(img, cam);
        //                _captureState = CaptureState.MULT_CAPTURE_TRIGGER_OFF;
        //                _captureCnt++;
        //            }
        //            else
        //            {
        //                //_timerMutiCapture.Enabled = false;
        //                _timerMutiCapture.Stop();
        //                _captureState = CaptureState.NO_CAPTURE;
        //                _captureCnt = 0;
        //            }
        //        }
        //    }
        //    catch (System.Exception ex)
        //    {
        //        _logger.Error(ex.Message);
        //    }
        //}

        private static void HandleFluCapture(Image <Bgr, Byte> img, XCamera cam)
        {
            try
            {
                if (_captureState == CaptureState.FLU_START_CAPTURE)
                {
                    WaitForm.GetInstance().Show();
                    _captureImage = new Image <Bgr, int>(img.Cols, img.Rows);
                    for (int row = 0; row < _captureImage.Rows; row++)
                    {
                        for (int col = 0; col < _captureImage.Cols; col++)
                        {
                            _captureImage.Data[row, col, 0] = img.Data[row, col, 0];
                            _captureImage.Data[row, col, 1] = img.Data[row, col, 1];
                            _captureImage.Data[row, col, 2] = img.Data[row, col, 2];
                        }
                    }

                    if (cam.CapturePara.FluModeAccuFrameCnt == 1)
                    {
                        _captureState = CaptureState.FLU_STOP_CAPTURE;
                    }
                    else
                    {
                        _captureState = CaptureState.FLU_CAPTURING;
                    }
                    _captureCnt++;

                    WaitForm.GetInstance().Description = "进度:1/" + cam.CapturePara.FluModeAccuFrameCnt.ToString();
                }
                if (_captureState == CaptureState.FLU_CAPTURING)
                {
                    if (_frameCnt % cam.CapturePara.FluModeFrameStep != 0)
                    {
                        return;
                    }
                    if (_captureCnt <= cam.CapturePara.FluModeAccuFrameCnt)
                    {
                        for (int row = 0; row < _captureImage.Rows; row++)
                        {
                            for (int col = 0; col < _captureImage.Cols; col++)
                            {
                                _captureImage.Data[row, col, 0] += img.Data[row, col, 0];
                                _captureImage.Data[row, col, 1] += img.Data[row, col, 1];
                                _captureImage.Data[row, col, 2] += img.Data[row, col, 2];
                            }
                        }
                        _captureCnt++;
                        WaitForm.GetInstance().Description = "进度:" + _captureCnt.ToString() + " /" + cam.CapturePara.FluModeAccuFrameCnt.ToString();
                    }
                    else
                    {
                        _captureState = CaptureState.FLU_STOP_CAPTURE;
                        _captureCnt   = 0;
                    }
                }
                if (_captureState == CaptureState.FLU_STOP_CAPTURE)
                {
                    WaitForm.GetInstance().Description = "保存中...";
                    _captureImage = _captureImage.Mul(1.0 / cam.CapturePara.FluModeAccuFrameCnt);
                    Image <Bgr, Byte> img2Save     = _captureImage.Convert <Bgr, Byte>();
                    string            fullFileName = SaveImageToDefaultPath(img2Save, cam);
                    _captureState = CaptureState.NO_CAPTURE;
                    WaitForm.GetInstance().Description = "";
                    WaitForm.GetInstance().Close();
                }
            }
            catch (System.Exception ex)
            {
                _logger.Error(ex.Message);
                _captureState = CaptureState.NO_CAPTURE;
                WaitForm.GetInstance().Description = "";
                WaitForm.GetInstance().Close();
            }
        }