public void SaveMacroPlanTest(string imagepath)
        {
            //assign
            var shapemodelpath = "filepath";
            var note = "note";
            var exportUnit = "mm";
            var image = new HImage(imagepath);

            var imageBinData = new Binary(ImageConventer.ConvertHalconImageToByteArray(image, false));

            var matchingParam = new MatchingParam();

            var matchingParamByteArray = ModelSerializer.DoSerialize(matchingParam);

            var matchingParamBinData = new Binary(matchingParamByteArray);

            BindingList<GeoDataGridViewModel> a = new BindingList<GeoDataGridViewModel>();
            a.Add(new GeoDataGridViewModel() { RecordID = "aaa" });

            var measureBinData = ModelSerializer.DoSerialize(a);
            //BindingList a;

            var ma = new MeasureAssistant();
            var maParam = ma.GetMeasureAssistantParam();
            var maParamBin = ModelSerializer.DoSerialize(maParam);

            LightChannel upper = new LightChannel() { Channel = "00", Intensity = 100, OnOff = LightSwitch.On };

            LightChannel bottom = new LightChannel() { Channel = "01", Intensity = 200, OnOff = LightSwitch.OFF };
            //act
            var success = SDMSRepo.SaveMacroPlan("Test", Guid.NewGuid().ToString(), shapemodelpath, note, imageBinData, exportUnit, matchingParamBinData, measureBinData, maParamBin, upper, bottom, new ShapeViewModel() { }, "system", "");

            //assert
            Assert.True(success);
        }
        /// <summary>
        /// Initializes flags, lists, and delegates to have a valid
        /// starting point to start the assistant.
        /// </summary>
        public MatchingAssistant(MatchingParam parSet)
        {
            parameterSet        = parSet;
            NotifyIconObserver  = new MatchingDelegate(dummy);
            NotifyParamObserver = new AutoParamDelegate(dummyS);
            homSc2D             = new HHomMat2D();
            TestImages          = new Hashtable(10);
            tResult             = new MatchingResult();

            contrastLowB    = 0;
            contrastUpB     = 255;
            scaleStepLowB   = 0.0;
            scaleStepUpB    = (double)19.0 / 1000.0;
            angleStepLowB   = 0.0;
            angleStepUpB    = (double)(112.0 / 10.0) * Math.PI / 180.0;
            pyramLevLowB    = 1;
            pyramLevUpB     = 6;
            minContrastLowB = 0;
            minContrastUpB  = 30;

            findAlways        = false;
            createNewModelID  = true;
            ModelID           = new HShapeModel();
            onExternalModelID = false;
        }
        /// <summary>Constructor</summary>
        /// <param name="mAss">MatchingAssistant that created this instance</param>
        /// <param name="mPars">Current set of matching parameters</param>
        public MatchingOptStatistics(MatchingAssistant mAss, MatchingParam mPars)
        {
            mAssistant = mAss;
            mParams = mPars;
            NotifyStatisticsObserver = new StatisticsDelegate(dummy);

            reset();
            tImageCount = mAssistant.TestImages.Count;
        }
        /// <summary>Constructor</summary>
        /// <param name="mAss">MatchingAssistant that created this instance</param>
        /// <param name="mPars">Current set of matching parameters</param>
        public MatchingOptStatistics(MatchingAssistant mAss, MatchingParam mPars)
        {
            mAssistant = mAss;
            mParams    = mPars;
            NotifyStatisticsObserver = new StatisticsDelegate(dummy);

            reset();
            tImageCount = mAssistant.TestImages.Count;
        }
        /// <summary>
        /// 砞 Matching 把计, 穝盎代家
        /// </summary>
        /// <param name="param"></param>
        public void ResetParam(MatchingParam param)
        {
            var notifyAutoList = param.GetDiffAutoParams();

            this.parameterSet = param;
            deterimineParamsAndInspectShapeModel();
            //for (int i = 0; i < notifyAutoList.Length; i++)
            //	NotifyParamObserver((string)notifyAutoList[i]);
        }
Exemple #6
0
        /// <summary>Constructor</summary>
        /// <param name="mAss">MatchingAssistant that created this instance</param>
        /// <param name="mPars">Current set of matching parameters</param>
        public MatchingOptSpeed(MatchingAssistant mAss, MatchingParam mPars)
        {
            mAssistant = mAss;
            mParams    = mPars;
            NotifyStatisticsObserver = new StatisticsDelegate(dummy);

            mScoreMinStep   = -10;
            mGreedinessStep = 10;
            reset();

            tImageCount = mAssistant.TestImages.Count;
        }
        /// <summary>Constructor</summary>
        /// <param name="mAss">MatchingAssistant that created this instance</param>
        /// <param name="mPars">Current set of matching parameters</param>
        public MatchingOptSpeed(MatchingAssistant mAss, MatchingParam mPars)
        {
            mAssistant	= mAss;
            mParams		= mPars;
            NotifyStatisticsObserver = new StatisticsDelegate(dummy);

            mScoreMinStep	= -10;
            mGreedinessStep	= 10;
            reset();

            tImageCount		= mAssistant.TestImages.Count;
        }
        /// <summary>
        /// Initializes flags, lists, and delegates to have a valid
        /// starting point to start the assistant.
        /// </summary>
        public MatchingAssistant(MatchingParam  parSet)
        {
            parameterSet	= parSet;
            NotifyIconObserver  = new MatchingDelegate(dummy);
            NotifyParamObserver = new AutoParamDelegate(dummyS);
            homSc2D    = new HHomMat2D();
            TestImages = new Hashtable(10);
            tResult	   = new MatchingResult();

            contrastLowB	= 0;
            contrastUpB		= 255;
            scaleStepLowB	= 0.0;
            scaleStepUpB	= (double)19.0/1000.0;
            angleStepLowB	= 0.0;
            angleStepUpB	= (double)(112.0/10.0)*Math.PI/180.0;
            pyramLevLowB	= 1;
            pyramLevUpB		= 6;
            minContrastLowB = 0;
            minContrastUpB	= 30;

            findAlways		 = false;
            createNewModelID = true;
            ModelID			  = new HShapeModel();
            onExternalModelID = false;
        }
        /// <summary> 
        /// Updates all model parameters to the initial settings of the GUI 
        /// components.  
        /// </summary>
        /// <param name="parSet">holds all necessary parameter values</param>
        private void Init(MatchingParam parSet)
        {
            this.PyramidLevelUpDown.Value = 5;
            this.MinContrastUpDown.Maximum = this.ContrastUpDown.Value;
            this.MinContrastTrackBar.Maximum = (int)this.ContrastUpDown.Value;
            this.MetricBox.SelectedIndex = 0;
            this.OptimizationBox.SelectedIndex = 0;
            this.SubPixelBox.SelectedIndex = 2;
            this.RecognRateComboBox.SelectedIndex = 0;

            parSet.mAngleExtent	  = (double)(AngleExtentUpDown.Value)*Math.PI/180.0;
            parSet.mAngleStep	  = ((double)AngleStepUpDown.Value /10.0)*Math.PI/180.0;
            parSet.mContrast      = (int) ContrastUpDown.Value;
            parSet.mMaxScale	  = (double)MaxScaleUpDown.Value/100.0;
            parSet.mMetric		  = (string)MetricBox.Items[MetricBox.SelectedIndex];
            parSet.mMinContrast   = (int) MinContrastUpDown.Value;
            parSet.mMinScale	  = (double)MinScaleUpDown.Value/100.0;
            parSet.mNumLevel      = (int)PyramidLevelUpDown.Value;
            parSet.mOptimization  = (string)OptimizationBox.Items[OptimizationBox.SelectedIndex];
            parSet.mScaleStep	  = (double)ScaleStepUpDown.Value/1000.0;
            parSet.mStartingAngle = (double)(StartingAngleUpDown.Value)*Math.PI/180.0;

            parSet.mMinScore		= (double)MinScoreUpDown.Value/100.0;
            parSet.mNumMatches		= (int)NumMatchesUpDown.Value;
            parSet.mGreediness		= (double)GreedinessUpDown.Value/100.0;
            parSet.mMaxOverlap		= (double)MaxOverlapUpDown.Value/100.0;
            parSet.mSubpixel		= (string)SubPixelBox.Items[SubPixelBox.SelectedIndex];
            parSet.mLastPyramidLevel= (int)LastPyrLevUpDown.Value;

            parSet.mRecogRateOpt		=  (int)RecognRateComboBox.SelectedIndex;
            parSet.mRecogRate			=  (int)recogRateUpDown.Value;
            parSet.mRecogSpeedMode		=  MatchingParam.RECOGM_MANUALSELECT;
            parSet.mRecogManualSel		=  (int)RecogNoManSelUpDown.Value;
            parSet.mInspectMaxNoMatch	=  (int)InspectMaxNoMatchUpDown.Value;

              string imPathValue = (string)(HSystem.GetSystem("image_dir").TupleSplit(";"));
            openFileDialog1.InitialDirectory = imPathValue;

            openFileDialog2.InitialDirectory = imPathValue;

            openFileDialog3.InitialDirectory =
            Environment.GetFolderPath(
            System.Environment.SpecialFolder.Personal);

            saveFileDialog1.InitialDirectory =
            Environment.GetFolderPath(
            System.Environment.SpecialFolder.Personal);
        }
        /// <summary>
        /// In the beginning, some initialization tasks are performed. 
        /// The control instances, like ROIController and WindowController,
        /// are initialized and registered with each other. Also, the
        /// delegates of the models are linked to update methods
        /// to get notified about changes.
        /// </summary>
        public MatchingForm()
        {
            InitializeComponent();

            mView = new HWndCtrl(viewPort);

            createModelWindowMode = Color.RoyalBlue;
            trainModelWindowMode  = Color.Chartreuse;

            roiController = new ROIController();
            mView.useROIController(roiController);

            roiController.setROISign(ROIController.MODE_ROI_POS);

            mView.NotifyIconObserver = new IconicDelegate(UpdateViewData);
            roiController.NotifyRCObserver = new IconicDelegate(UpdateViewData);

            mView.setViewState(HWndCtrl.MODE_VIEW_NONE);

            locked = true;
            parameterSet = new MatchingParam();
            Init(parameterSet);
            locked = false;

            mAssistant = new MatchingAssistant(parameterSet);
            mAssistant.NotifyIconObserver  = new MatchingDelegate(UpdateMatching);
            mAssistant.NotifyParamObserver = new AutoParamDelegate(UpdateButton);

            speedOptHandler		= new MatchingOptSpeed(mAssistant, parameterSet);
            speedOptHandler.NotifyStatisticsObserver = new  StatisticsDelegate(UpdateStatisticsData);

            inspectOptHandler	= new MatchingOptStatistics(mAssistant, parameterSet);
            inspectOptHandler.NotifyStatisticsObserver = new  StatisticsDelegate(UpdateStatisticsData);
        }
 /// <summary>
 /// ���] Matching �Ѽ�, �í��s�����ҫ�
 /// </summary>
 /// <param name="param"></param>
 public void ResetParam(MatchingParam param)
 {
     var notifyAutoList = param.GetDiffAutoParams();
     this.parameterSet = param;
     deterimineParamsAndInspectShapeModel();
     //for (int i = 0; i < notifyAutoList.Length; i++)
     //	NotifyParamObserver((string)notifyAutoList[i]);
 }