Ejemplo n.º 1
0
        private void UpdateDisplayImage()
        {
            RBSK rbsk = MouseService.GetStandardMouseRules();

            rbsk.Settings.GapDistance     = GapDistance;
            rbsk.Settings.BinaryThreshold = BinaryThreshold;
            PointF[] result = RBSKService.RBSK(CurrentImage, rbsk);
            using (Image <Bgr, Byte> img = CurrentImage.Clone())
            {
                //if (!ROI.IsEmpty)
                //{
                //    img.ROI = ROI;
                //}

                if (result != null)
                {
                    foreach (PointF point in result)
                    {
                        img.Draw(new CircleF(point, 2), new Bgr(Color.Yellow), 2);
                    }
                }

                DisplayImage = ImageService.ToBitmapSource(img);
            }
        }
Ejemplo n.º 2
0
        private void UpdateGapDistance()
        {
            if (CurrentResult != null)
            {
                CurrentResult.GapDistance = GapDistance;
            }

            RBSK rbsk = MouseService.GetStandardMouseRules();

            rbsk.Settings.GapDistance     = GapDistance;
            rbsk.Settings.BinaryThreshold = BinaryThreshold;
            PointF[] result = RBSKService.RBSK(CurrentImage, rbsk);
            using (Image <Bgr, Byte> img = CurrentImage.Clone())
            {
                img.DrawPolyline(MotionTrack.Select(x => x.ToPoint()).ToArray(), false, new Bgr(Color.Blue), 2);

                if (result != null)
                {
                    foreach (PointF point in result)
                    {
                        img.Draw(new CircleF(point, 2), new Bgr(Color.Yellow), 2);
                    }
                }

                DisplayImage = ImageService.ToBitmapSource(img);
            }
        }
Ejemplo n.º 3
0
 public EditPicture(ShapeImage shapeImage)//Image shape,string imageUrl)
 {
     InitializeComponent();
     CurrentShapeImage = shapeImage;
     CurrentImage      = shapeImage.Image;
     CurrentImageOld   = (Image)CurrentImage.Clone();
     ImageUrl          = shapeImage.ImageUrl;
     InitImage();
 }
        private void TryPerformInference(bool reloadImages = true)
        {
            if (CurrentImage != null)
            {
                // Classify
                var angle = (float)RotationSlider.Value;
                var(labels, probabilities) = Classify(CurrentImage.Clone(), angle);

                // Render the classification and probabilities
                RenderInferenceResults(labels, probabilities);
            }
        }
Ejemplo n.º 5
0
    // Get an exact same object as this one.
    public override Component Clone()
    {
        BoxDescription boxDescription = BoxFactory.GetBoxDescription(Description.BackImage, Description.Size);
        HiddenObject   hiddenObject   = new HiddenObject {
            Image = HiddenObject.Image
        };
        BoxState boxState = new BoxState {
            State = State.State
        };
        ImageBinder imageBinder = new ImageBinder();
        BoxFactory  boxFactory  = BoxFactory.GetInstance();
        string      image       = (string)CurrentImage.Clone();

        return(new Box {
            Description = boxDescription, HiddenObject = hiddenObject,
            State = boxState, ImageBinder = imageBinder,
            BoxFactory = boxFactory, CurrentImage = image, Position = this.Position,
            IsEnabled = this.IsEnabled
        });
    }
Ejemplo n.º 6
0
        private void UpdateDisplayImage()
        {
            using (Image <Bgr, Byte> img = CurrentImage.Clone())
            {
                img.DrawPolyline(MotionTrack.Select(x => x.ToPoint()).ToArray(), false, new Bgr(Color.Blue), 2);
                img.DrawPolyline(CentroidMotionTrack.Select(x => x.ToPoint()).ToArray(), false, new Bgr(Color.Yellow), 2);

                if (SliderValue >= AnalyseStart && SliderValue <= AnalyseEnd)
                {
                    ISingleFrameResult frame = CurrentResult.Results[SliderValue];

                    if (!frame.HeadPoint.IsEmpty)
                    {
                        img.Draw(new CircleF(frame.HeadPoint, 2), new Bgr(Color.Red), 2);
                        img.Draw(new CircleF(frame.Centroid, 2), new Bgr(Color.Red), 2);
                    }
                }

                DisplayImage = ImageService.ToBitmapSource(img);
            }
        }
Ejemplo n.º 7
0
        protected override void DoProcess()
        {
            mUpdatePending = false;
            if (SourceImage != null)
            {
                try
                {
                    SetUIState(UIState.Processing);

                    CancelProcessingPending = false;

                    if (mProcessImageDuringUpdate)
                    {
                        // Checking if the stage is frozen or not and is there a frozen image.
                        if (FrozenAt == null || mFrozenImage == null)
                        {
                            CurrentImage = (IBitmapCore)SourceImage.Clone();

                            if (mZoomAfterPrescaleValue < 0.999 || mZoomAfterPrescaleValue > 1.001)
                            {
                                CurrentImage.ScaleFast(mZoomAfterPrescaleValue, delegate(double progress) {
                                    OnProgressMessageReport(true, progress, "Applying zoom (downscaling)...", false);
                                    return(!CancelProcessingPending);
                                });
                            }
                            if (ImageChanged != null)
                            {
                                ImageChanged(this, EventArgs.Empty);
                            }
                        }
                        else
                        {
                            CurrentImage = (IBitmapCore)mFrozenImage.Clone();
                            if (ImageChanged != null)
                            {
                                ImageChanged(this, EventArgs.Empty);
                            }
                        }

                        // Making the list of stage operations to apply
                        List <StageOperation> operationsToApply = new List <StageOperation>();
                        List <double>         efforts           = new List <double>();
                        double full_efforts = 0;

                        int start_index = 0;
                        if (FrozenAt != null && mFrozenImage != null)
                        {
                            start_index = StageQueue.IndexOf(FrozenAt) + 1;
                        }

                        for (int i = start_index; i < StageQueue.Count; i++)
                        {
                            if (StageQueue[i] != _EditingOperation)
                            {
                                // Don't add inactives
                                if (StageQueue[i].Active == false)
                                {
                                    continue;
                                }

                                StageOperation newOperation = CallStageOperationFactory(StageQueue[i]);
                                operationsToApply.Add(newOperation);
                                efforts.Add(newOperation.CalculateEfforts(CurrentImage));
                                full_efforts += efforts[efforts.Count - 1];

                                newOperation.ReportProgress += delegate(object sender, ReportStageOperationProgressEventArgs e) {
                                    double cur_eff = 0;
                                    int    j       = 0;
                                    while (operationsToApply[j] != (StageOperation)sender)
                                    {
                                        cur_eff += efforts[j];
                                        j++;
                                    }
                                    cur_eff += e.Progress * efforts[j];
                                    string desc = StageOperationDescriptionAttribute.GetName(sender.GetType());

                                    OnProgressMessageReport(true,
                                                            cur_eff / full_efforts,
                                                            "" + (j + 1) + " of " + efforts.Count + ": " + desc + "...", true);

                                    if (CancelProcessingPending)
                                    {
                                        e.Cancel = true;
                                    }
                                };
                            }
                            else
                            {
                                break;
                            }
                        }

                        // Executing
                        for (int k = 0; k < operationsToApply.Count; k++)
                        {
                            Console.WriteLine("AnalyzeImage Calling for " + operationsToApply[k].GetType().Name);
                            _Holders[operationsToApply[k].Parameters].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                            operationsToApply[k].OnDo(CurrentImage);
                            if (operationsToApply[k].Parameters == FrozenAt)
                            {
                                // After the frozen line is reached,
                                // setting the current frozen image
                                mFrozenImage = (IBitmapCore)CurrentImage.Clone();
                            }
                        }
                    }

                    if (_EditingOperation != null)
                    {
                        Console.WriteLine("AnalyzeImage Calling for " + _EditingOperation.GetType().Name);
                        _Holders[_EditingOperation].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                    }

                    OnImageUpdatingCompleted();
                    SetUIState(UIState.Idle);
                }
                catch (UserCancelException)
                {
                    // The user cancelled processing.
                    // Setting to idle state
                    SetUIState(UIState.Idle);
                    // Unset cancelling flag.
                    AskUpdate();
                }
            }
        }