コード例 #1
0
 public MeasurementSymmetryLine(ROI roiOne, ROI roiTwo, MeasureAssistant mAssist)
     : base(null, mAssist)
 {
     var lineF = new MeasurementEdge(roiOne, mAssist);
     var lineS = new MeasurementEdge(roiTwo, mAssist);
     initialize(lineF.GetViewModel(), lineS.GetViewModel(), mAssist);
 }
コード例 #2
0
        public MeasurementDistanceY(ROI roiOne, ROI roiTwo, MeasureAssistant mAssist)
            : base(null, mAssist)
        {
            var lineF = new MeasurementEdge(roiOne, mAssist);
            var lineS = new MeasurementEdge(roiTwo, mAssist);

            initialize(lineF.GetViewModel(), lineS.GetViewModel(), mAssist);
        }
コード例 #3
0
        /// <summary>
        /// Factory method to create measure objects
        /// </summary>
        /// <param name="roi">Interactive ROI</param>
        /// <param name="parent">
        /// Reference to measure controller class
        /// </param>
        /// <returns>New measure object</returns>
        public static Measurement CreateMeasure(ROI roi, MeasureAssistant parent)
        {
            Measurement mMeasurement = null;

            switch (roi.ROIMeasureType)
            {
            case MeasureType.Circle:
                mMeasurement = new MeasurementCircle(roi, parent);
                break;

            case MeasureType.Line:
                if (_doFitLineAlgo)
                {
                    mMeasurement = new MeasurementFitLine(roi, parent);
                }
                else
                {
                    mMeasurement = new MeasurementEdge(roi, parent);
                }
                break;

            case MeasureType.Point:
                if (roi is ViewROI.SmartROIs.SmartPoint)
                {
                    mMeasurement = new SmartMeasurements.AutoFitPoint(roi, parent);
                }
                else
                {
                    mMeasurement = new MeasurementEdge(roi, parent);
                }
                break;

            default:
                mMeasurement = new MeasurementEdge(roi, parent);
                break;
            }
            //if (parent.mSelPair)
            //	return new MeasurementPair(roi, parent);
            //else if (roi.ROIMeasureType == MeasureType.Circle)
            //{
            //	return new MeasurementCircle(roi, parent);
            //}
            //else
            //	return new MeasurementEdge(roi, parent);
            return(mMeasurement);
        }
コード例 #4
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 772;
            hv_STD_Col = 1003;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_angle = 1.57;
            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Row = 317.88, f_ROI_Col = 1173.106;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //

            //第二個 線段 ROI
            HTuple s_angle = 1.57;
            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Row = 331.45, s_ROI_Col = 1248.75;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);
            //roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Col, 0, 13.3, 75.7);

            /**/

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, 46.466, 41.411);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, 47.496, 45.163);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = LineToLine(lineF, lineS);

            #endregion

            return mResult;
        }
コード例 #5
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 416.40625;
            HTuple f_ROI_Col = 752;
            HTuple f_angle = 0;
            HTuple f_ROI_Length1 = 56;
            HTuple f_ROI_Length2 = 256.25;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI
            HTuple s_ROI_Row = 435.638671875;
            HTuple s_ROI_Col = 1429.16339869281;
            HTuple s_angle = 0;
            HTuple s_ROI_Length1 = 49.8594771241831;
            HTuple s_ROI_Length2 = 241.6796875;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.LineToLine(lineF, lineS, this.hv_AllModelAngle, LineDirection.Horizontal);

            #endregion

            return mResult;
        }
コード例 #6
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 855.548828125;
            HTuple f_ROI_Col = 705.725490196078;
            HTuple f_angle = 1.5707963267949;
            HTuple f_ROI_Length1 = 40.498046875;
            HTuple f_ROI_Length2 = 26.5130718954247;

            HTuple f_angleOffset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //

            //第二個  ROI (點)

            HTuple s_ROI_Row = 944.1484375;
            HTuple s_ROI_Col = 752.929738562092;
            HTuple s_angle = 0;
            HTuple s_ROI_Length1 = 58.1683006535948;
            HTuple s_ROI_Length2 = 39.703125;

            HTuple s_angleOffset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);
            //roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Col, 0, 13.3, 75.7);

            //Angle

            /**/

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angleOffset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Point };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angleOffset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var pointS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.PointToLine(lineF, pointS, this.hv_AllModelAngle);

            #endregion

            return mResult;
        }
コード例 #7
0
        public MeasureViewModel GetMidLine()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            MeasureViewModel midLineModel = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            //HTuple f_ROI_Row = 528.01953125;
            //HTuple f_ROI_Col = 821.555555555556;
            //HTuple f_angle = 0;
            //HTuple f_ROI_Length1 = 20;
            //HTuple f_ROI_Length2 = 93;
            HTuple f_ROI_Row = 528.01953125;
            HTuple f_ROI_Col = 1067.82352941176;
            HTuple f_angle = 0;
            HTuple f_ROI_Length1 = 20.9019607843137;
            HTuple f_ROI_Length2 = 90.669921875;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI
            //HTuple s_ROI_Row = 528.03515625;
            //HTuple s_ROI_Col = 858.300653594771;
            //HTuple s_angle = 3.14159265358979;
            //HTuple s_ROI_Length1 = 20;
            //HTuple s_ROI_Length2 = 93;
            HTuple s_ROI_Row = 528.03515625;
            HTuple s_ROI_Col = 1102.59477124183;
            HTuple s_angle = 3.14159265358979;
            HTuple s_ROI_Length1 = 17.3856209150328;
            HTuple s_ROI_Length2 = 91.6015625;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.LineToLine(lineF, lineS, this.hv_AllModelAngle, LineDirection.Horizontal);

            var firstModel = lineF.GetViewModel();
            var secondModel = lineS.GetViewModel();
            if (firstModel != null && secondModel != null && firstModel.Distance != null && secondModel.Distance != null
                && firstModel.Distance.TupleLength() > 0 && secondModel.Distance.TupleLength() > 0)
            {
                //作線段
                var centerRow = (f_ROI_Cur_Row + s_ROI_Cur_Row) / 2.0;
                var centerCol = (f_ROI_Cur_Col + s_ROI_Cur_Col) / 2.0;

                midLineModel = DistanceHelper.MakeLine(centerRow, centerCol, hv_AllModelAngle, mResult.Distance / 2.0);
            }

            return midLineModel;
            #endregion
        }
コード例 #8
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 353.060546875;
            HTuple f_ROI_Col = 831.539215686274;
            HTuple f_angle = 1.5707963267949;
            HTuple f_ROI_Length1 = 43.041015625;
            HTuple f_ROI_Length2 = 176.091503267974;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI
            HTuple s_ROI_Row = 856.97265625;
            HTuple s_ROI_Col = 712.908496732026;
            HTuple s_angle = -1.5707963267949;
            HTuple s_ROI_Length1 = 34.48828125;
            HTuple s_ROI_Length2 = 51.6617647058824;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            /**/

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.LineToLine(lineF, lineS, this.hv_AllModelAngle, LineDirection.Vertical);

            #endregion

            return mResult;
        }
コード例 #9
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 341.21875;
            HTuple f_ROI_Col = 803.078431372549;
            HTuple f_angle = 1.5707963267949;
            HTuple f_ROI_Length1 = 77.5390625;
            HTuple f_ROI_Length2 = 148.705882352941;

            HTuple f_angleOffset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //

            //第二個 線段 ROI

            HTuple s_ROI_Row = 774.4765625;
            HTuple s_ROI_Col = 709.622549019608;
            HTuple s_angle = 0;
            HTuple s_ROI_Length1 = 45.2843137254902;
            HTuple s_ROI_Length2 = 30.15234375;

            HTuple s_angleOffset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angleOffset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Point };
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angleOffset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var pointS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.PointToLine(lineF, pointS, this.hv_AllModelAngle);

            #endregion

            return mResult;
        }
コード例 #10
0
        public MeasureViewModel GetMidLine()
        {
            #region 輸出結果
            LineResult mResult = null;
            MeasureViewModel midLineModel = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 528.064453125;
            HTuple f_ROI_Col = 802.751633986928;
            HTuple f_angle = 0;
            HTuple f_ROI_Length1 = 38.2679738562091;
            HTuple f_ROI_Length2 = 99.6328125;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI
            HTuple s_ROI_Row = 523.408203125;
            HTuple s_ROI_Col = 853.542483660131;
            HTuple s_angle = 3.14159265358979;
            HTuple s_ROI_Length1 = 27.4509803921568;
            HTuple s_ROI_Length2 = 105.341796875;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "bilinear";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "last";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.CalculateSymmetryLine(lineF.GetViewModel(), lineS.GetViewModel());
            //mResult = DistanceHelper.LineToLine(lineF, lineS, this.hv_AllModelAngle, LineDirection.Horizontal);

            midLineModel = new MeasureViewModel()
            {
                Row1 = mResult.Row1,
                Row2 = mResult.Row2,
                Col1 = mResult.Col1,
                Col2 = mResult.Col2,
                Distance = mResult.Distance,
            };

            //var firstModel = lineF.GetViewModel();
            //var secondModel = lineS.GetViewModel();
            //if (firstModel != null && secondModel != null && firstModel.Distance != null && secondModel.Distance != null
            //	&& firstModel.Distance.TupleLength() > 0 && secondModel.Distance.TupleLength() > 0)
            //{
            //	//作線段
            //	var centerRow = (f_ROI_Cur_Row + s_ROI_Cur_Row) / 2.0;
            //	var centerCol = (f_ROI_Cur_Col + s_ROI_Cur_Col) / 2.0;

            //	midLineModel = DistanceHelper.MakeLine(centerRow, centerCol, hv_AllModelAngle, mResult.Distance / 2.0);
            //}

            return midLineModel;
            #endregion
        }
コード例 #11
0
        public MeasureResult Action()
        {
            #region 輸出結果
            AngleResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            HTuple f_ROI_Row = 620.423828125;
            HTuple f_ROI_Col = 707.352941176471;
            HTuple f_angle = 0;
            HTuple f_ROI_Length1 = 95.3725490196078;
            HTuple f_ROI_Length2 = 75.3515625;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI

            HTuple s_ROI_Row = 712.1015625;
            HTuple s_ROI_Col = 717.392156862745;
            HTuple s_angle = 0.771695764653512;
            HTuple s_ROI_Length1 = 99.5523647589937;
            HTuple s_ROI_Length2 = 75.8343543141117;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            /**/

            #region Measure

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.AngleLineToLine(lineF, lineS);

            #endregion

            return mResult;
        }
コード例 #12
0
        public MeasureResult Action()
        {
            #region 輸出結果
            LineResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            //HTuple f_ROI_Row = 341.21875;
            //HTuple f_ROI_Col = 803.078431372549;
            //HTuple f_angle = 1.5707963267949;
            //HTuple f_ROI_Length1 = 77.5390625;
            //HTuple f_ROI_Length2 = 148.705882352941;
            HTuple f_ROI_Row = 357.08984375;
            HTuple f_ROI_Col = 816.555555555556;
            HTuple f_angle = 1.5707963267949;
            HTuple f_ROI_Length1 = 69.8359375;
            HTuple f_ROI_Length2 = 122.277777777778;

            HTuple f_angleOffset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //兩線段交點
            HTuple p1_ROI_Row = 715.40234375;
            HTuple p1_ROI_Col = 744.222222222222;
            HTuple p1_angle = 0.764250656215704;
            HTuple p1_ROI_Length1 = 68.0072446324003;
            HTuple p1_ROI_Length2 = 105.756749157524;

            HTuple p1_angleOffset = p1_angle - hv_Img_Rotate_Angle;
            HTuple p1_ROI_Cur_Row, p1_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , p1_ROI_Row, p1_ROI_Col, out p1_ROI_Cur_Row, out p1_ROI_Cur_Col);

            HTuple p2_ROI_Row = 794.64453125;
            HTuple p2_ROI_Col = 702.888888888889;
            HTuple p2_angle = 0;
            HTuple p2_ROI_Length1 = 100;
            HTuple p2_ROI_Length2 = 50;
            HTuple p2_angleOffset = p2_angle - hv_Img_Rotate_Angle;
            HTuple p2_ROI_Cur_Row, p2_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , p2_ROI_Row, p2_ROI_Col, out p2_ROI_Cur_Row, out p2_ROI_Cur_Col);

            #region Measure
            var cROIController = new ROIController();
            var cAssistant = new MeasureAssistant(cROIController);

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var p1Line = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            p1Line.MakeROI(p1_ROI_Cur_Row, p1_ROI_Cur_Col, p1_angleOffset, p1_ROI_Length1, p1_ROI_Length2);

            var p2Line = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            p2Line.MakeROI(p2_ROI_Cur_Row, p2_ROI_Cur_Col, p2_angleOffset, p2_ROI_Length1, p2_ROI_Length2);

            var p1F = new MeasurementEdge(p1Line, cAssistant);
            var p2S = new MeasurementEdge(p2Line, cAssistant);
            var angleResult = DistanceHelper.AngleLineToLine(p1F, p2S);

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angleOffset, f_ROI_Length1, f_ROI_Length2);
            var lineF = new MeasurementEdge(roiF, cAssistant);

            if (angleResult != null && lineF != null)
            {
                var pointViewModel = new MeasureViewModel()
                {
                    Row1 = angleResult.Row,
                    Col1 = angleResult.Col,
                };
                var lineViewModel = lineF.GetViewModel();
                var distance = DistanceHelper.PointToLine(lineViewModel, pointViewModel);
                mResult = new LineResult()
                {
                    Row1 = lineViewModel.Row2,
                    Col1 = lineViewModel.Col2,
                    Row2 = pointViewModel.Row1,
                    Col2 = pointViewModel.Col1,
                    Distance = distance,
                };
            }

            #endregion

            return mResult;
        }
コード例 #13
0
        public MeasureResult Action()
        {
            #region 輸出結果
            DistanceResult mResult = null;
            #endregion

            HTuple hv_STD_Row;
            HTuple hv_STD_Col, hv_Img_Row, hv_Img_Col, hv_Img_Rotate_Angle;
            HTuple hv_OffsetRow, hv_OffsetCol;
            HOperatorSet.SetSystem("border_shape_models", "false");

            //STD 中心點
            hv_STD_Row = 839.5;
            hv_STD_Col = 1046.5;

            //目前圖形 中心點
            hv_Img_Row = hv_AllModelRow.Clone();
            hv_Img_Col = hv_AllModelColumn.Clone();

            //目前圖形 Rotate Angle
            hv_Img_Rotate_Angle = hv_AllModelAngle.Clone();

            //目前圖形偏移量
            hv_OffsetRow = hv_Img_Row - hv_STD_Row;
            hv_OffsetCol = hv_Img_Col - hv_STD_Col;

            //第一個 線段 ROI
            //HTuple f_ROI_Row = 1247.3671875;
            //HTuple f_ROI_Col = 686.519607843137;
            //HTuple f_angle = 0;
            //HTuple f_ROI_Length1 = 70.8529411764706;
            //HTuple f_ROI_Length2 = 112.958984375;

            HTuple f_ROI_Row = 1233.203125;
            HTuple f_ROI_Col = 712;
            HTuple f_angle = 0;
            HTuple f_ROI_Length1 = 116;
            HTuple f_ROI_Length2 = 56.0546875;

            HTuple f_angle_offset = f_angle - hv_Img_Rotate_Angle;
            HTuple f_ROI_Cur_Row, f_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol, f_ROI_Row, f_ROI_Col, out f_ROI_Cur_Row, out f_ROI_Cur_Col);

            //第二個 線段 ROI
            //HTuple s_ROI_Row = 1247.3671875;
            //HTuple s_ROI_Col = 1418.66666666667;
            //HTuple s_angle = 3.14159265358979;
            //HTuple s_ROI_Length1 = 76.1013071895425;
            //HTuple s_ROI_Length2 = 126.09375;
            HTuple s_ROI_Row = 1233.203125;
            HTuple s_ROI_Col = 1400;
            HTuple s_angle = 3.14159265358979;
            HTuple s_ROI_Length1 = 84;
            HTuple s_ROI_Length2 = 60.05859375;

            HTuple s_angle_offset = s_angle - hv_Img_Rotate_Angle;
            HTuple s_ROI_Cur_Row, s_ROI_Cur_Col;
            PositionLocater.ReLocater(hv_STD_Row, hv_STD_Col, hv_AllModelAngle, hv_OffsetRow, hv_OffsetCol
                    , s_ROI_Row, s_ROI_Col, out s_ROI_Cur_Row, out s_ROI_Cur_Col);

            /**/

            #region Measure

            var hImage = ho_Image as HImage;
            cAssistant.setImage(hImage);

            /*參數值*/
            cAssistant.mThresh = 40.0;
            cAssistant.mSigma = 1.0;
            cAssistant.mRoiWidth = 10;
            cAssistant.mInterpolation = "nearest_neighbor";
            cAssistant.mSelPair = false;
            cAssistant.mTransition = "all";
            cAssistant.mPosition = "all";
            cAssistant.mDispEdgeLength = 30;
            cAssistant.mDispROIWidth = true;
            cAssistant.setUnit("cm");

            cAssistant.mInitThresh = 40.0;
            cAssistant.mInitSigma = 1.0;
            cAssistant.mInitRoiWidth = 10;

            var roiF = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiF.MakeROI(416, 998, 0, 26.5, 71.2);
            roiF.MakeROI(f_ROI_Cur_Row, f_ROI_Cur_Col, f_angle_offset, f_ROI_Length1, f_ROI_Length2);

            var roiS = new ROIRectangle2() { ROIMeasureType = MeasureType.Line };
            //roiS.MakeROI(400, 1041, 0, 13.3, 75.7);
            roiS.MakeROI(s_ROI_Cur_Row, s_ROI_Cur_Col, s_angle_offset, s_ROI_Length1, s_ROI_Length2);

            var lineF = new MeasurementEdge(roiF, cAssistant);
            var lineS = new MeasurementEdge(roiS, cAssistant);
            mResult = DistanceHelper.LineToLine(lineF, lineS, this.hv_AllModelAngle, LineDirection.Horizontal);

            #endregion

            return mResult;
        }
コード例 #14
0
 /// <summary>
 /// Factory method to create measure objects
 /// </summary>
 /// <param name="roi">Interactive ROI</param>
 /// <param name="parent">
 /// Reference to measure controller class
 /// </param>
 /// <returns>New measure object</returns>
 public static Measurement CreateMeasure(ROI roi, MeasureAssistant parent)
 {
     Measurement mMeasurement = null;
     switch (roi.ROIMeasureType)
     {
         case MeasureType.Circle:
             mMeasurement = new MeasurementCircle(roi, parent);
             break;
         case MeasureType.Line:
             if (_doFitLineAlgo)
                 mMeasurement = new MeasurementFitLine(roi, parent);
             else
                 mMeasurement = new MeasurementEdge(roi, parent);
             break;
         case MeasureType.Point:
             if (roi is ViewROI.SmartROIs.SmartPoint)
             {
                 mMeasurement = new SmartMeasurements.AutoFitPoint(roi, parent);
             }
             else
             {
                 mMeasurement = new MeasurementEdge(roi, parent);
             }
             break;
         default:
             mMeasurement = new MeasurementEdge(roi, parent);
             break;
     }
     //if (parent.mSelPair)
     //	return new MeasurementPair(roi, parent);
     //else if (roi.ROIMeasureType == MeasureType.Circle)
     //{
     //	return new MeasurementCircle(roi, parent);
     //}
     //else
     //	return new MeasurementEdge(roi, parent);
     return mMeasurement;
 }