Beispiel #1
0
        public Bitmap ProcessFrame(Bitmap measurementFrame)
        {
            // if we have an updated list, then apply it the next itteration
            if (NewFunctionList != null)
            {
                FunctionList    = NewFunctionList;
                NewFunctionList = null;
            }

            // apply video processing functions
            if (FunctionList != null)
            {
                var count = FunctionList.Count;
                for (int i = 0; i < count; i++)
                {
                    var f = FunctionList[i];
                    if (!f.Enabled)
                    {
                        continue;
                    }
                    switch (f.Method)
                    {
                    case AForgeMethod.Grayscale:
                        GrayscaleFunc(ref measurementFrame);
                        break;

                    case AForgeMethod.ContrastStretch:
                        Contrast_scretchFunc(ref measurementFrame);
                        break;

                    case AForgeMethod.KillColor:
                        KillColor_Func(ref measurementFrame, f.parameter_double, f.R, f.G, f.B);
                        break;

                    case AForgeMethod.KeepColor:
                        KeepColor_Func(ref measurementFrame, f.parameter_double, f.R, f.G, f.B);
                        break;

                    case AForgeMethod.Invert:
                        InvertFunct(ref measurementFrame);
                        break;

                    case AForgeMethod.Zoom:
                        Meas_ZoomFunc(ref measurementFrame, f.parameter_double);
                        break;

                    case AForgeMethod.EdgeDetect1:
                        Edge_detectFunc(ref measurementFrame, 1);
                        break;

                    case AForgeMethod.EdgeDetect2:
                        Edge_detectFunc(ref measurementFrame, 2);
                        break;

                    case AForgeMethod.EdgeDetect3:
                        Edge_detectFunc(ref measurementFrame, 3);
                        break;

                    case AForgeMethod.EdgeDetect4:
                        Edge_detectFunc(ref measurementFrame, 4);
                        break;

                    case AForgeMethod.NoiseReduction1:
                        NoiseReduction_Funct(ref measurementFrame, 1);
                        break;

                    case AForgeMethod.NoiseReduciton2:
                        NoiseReduction_Funct(ref measurementFrame, 2);
                        break;

                    case AForgeMethod.NoiseReduction3:
                        NoiseReduction_Funct(ref measurementFrame, 3);
                        break;

                    case AForgeMethod.Threshold:
                        ThresholdFunct(ref measurementFrame, f.parameter_double);
                        break;

                    case AForgeMethod.Histogram:
                        HistogramFunct(ref measurementFrame);
                        break;

                    case AForgeMethod.CameraExposure:
                        videoCapture.SetExposure((int)f.parameter_double);
                        break;

                    case AForgeMethod.VideoBrightness:
                        videoCapture.SetBrightness((int)f.parameter_double);
                        break;
                    }
                }
            }


            // flip the measurement displayFrame so it looks the same as the display displayFrame XXX not sure why this is (?)
            if (videoCapture.IsUp())
            {
                new Mirror(false, true).ApplyInPlace(measurementFrame);
            }
            return(measurementFrame);
        }