示例#1
0
        public bool SelectGoImgProc(ComImgInfo _comImgInfo, CancellationToken _token)
        {
            bool bRst = true;

            switch (_comImgInfo.CurImgName)
            {
            case ComInfo.IMG_NAME_EDGE_DETECTION:
                EdgeDetection edge = (EdgeDetection)m_imgProc;
                bRst = edge.GoImgProc(_token);
                break;

            case ComInfo.IMG_NAME_GRAY_SCALE:
                GrayScale gray = (GrayScale)m_imgProc;
                bRst = gray.GoImgProc(_token);
                break;

            case ComInfo.IMG_NAME_BINARIZATION:
                Binarization binarization = (Binarization)m_imgProc;
                binarization.Thresh = _comImgInfo.BinarizationInfo.Thresh;
                bRst = binarization.GoImgProc(_token);
                break;

            case ComInfo.IMG_NAME_GRAY_SCALE_2DIFF:
                GrayScale2Diff gray2Diff = (GrayScale2Diff)m_imgProc;
                bRst = gray2Diff.GoImgProc(_token);
                break;

            case ComInfo.IMG_NAME_COLOR_REVERSAL:
                ColorReversal colorReversal = (ColorReversal)m_imgProc;
                bRst = colorReversal.GoImgProc(_token);
                break;

            case ComInfo.IMG_NAME_GRAY_SCALE_DIFF:
                GrayScaleDiff grayDiff = (GrayScaleDiff)m_imgProc;
                bRst = grayDiff.GoImgProc(_token);
                break;

            default:
                break;
            }

            return(bRst);
        }
        /// <summary>
        /// ビデオ描画
        /// </summary>
        /// <param name="sender">オブジェクト</param>
        /// <param name="eventArgs">NewFrameEventのデータ</param>
        private async void VideoRendering(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();

            if (checkBoxImgProcOn.Checked == true)
            {
                EdgeDetection proc    = new EdgeDetection(bitmap);
                bool          bResult = await Task.Run(() => proc.GoImgProc());

                if (bResult)
                {
                    pictureBox.Image = proc.BitmapAfter;
                }
            }
            else
            {
                pictureBox.Image = bitmap;
            }

            return;
        }