コード例 #1
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        /// <param name="x">x (=column) coordinate</param>
        /// <param name="y">y (=row) coordinate</param>
        /// <returns>
        /// Distance of the closest ROI handle.
        /// </returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double [] val = new double[NumHandles];

            midR = ((row2 - row1) / 2) + row1;
            midC = ((col2 - col1) / 2) + col1;

            val[0] = HMisc.DistancePp(y, x, row1, col1);             // upper left
            val[1] = HMisc.DistancePp(y, x, row1, col2);             // upper right
            val[2] = HMisc.DistancePp(y, x, row2, col2);             // lower right
            val[3] = HMisc.DistancePp(y, x, row2, col1);             // lower left
            val[4] = HMisc.DistancePp(y, x, midR, midC);             // midpoint

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for

            return(val[activeHandleIdx]);
        }
コード例 #2
0
        /// <summary>
        /// 计算鼠标到点的距离
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[NumHandles];
            val[0] = HMisc.DistancePp(y, x, Row11, Column11);                                    // 1upper left
            val[1] = HMisc.DistancePp(y, x, Row11, Column12);                                    // 1upper right
            val[2] = HMisc.DistancePp(y, x, Row12, Column12);                                    // 1lower right
            val[3] = HMisc.DistancePp(y, x, Row12, Column11);                                    // 1lower left
            val[4] = HMisc.DistancePp(y, x, Row11 / 2 + Row12 / 2, Column11 / 2 + Column12 / 2); // 1midpoint
            val[5] = HMisc.DistancePp(y, x, Row21, Column21);                                    // 2upper left
            val[6] = HMisc.DistancePp(y, x, Row21, Column22);                                    // 2upper right
            val[7] = HMisc.DistancePp(y, x, Row22, Column22);                                    // 2lower right
            val[8] = HMisc.DistancePp(y, x, Row22, Column21);                                    // 2lower left
            val[9] = HMisc.DistancePp(y, x, Row21 / 2 + Row22 / 2, Column21 / 2 + Column22 / 2); // 2midpoint
            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }// end of for

            return(val[activeHandleIdx]);
        }
コード例 #3
0
        /// <summary>
        /// 确定点是否被选中
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns>返回-1表示没有被选中</returns>
        public override int isSelected(double x, double y)
        {
            _operationing = -1;
            double max = 35;

            double[] value = new double[_operation_piont_number];

            value[0] = HMisc.DistancePp(y, x, this._row_y1, this._col_x1);
            value[1] = HMisc.DistancePp(y, x, this._row_y1, this._col_x2);
            value[2] = HMisc.DistancePp(y, x, this._row_y2, this._col_x1);
            value[3] = HMisc.DistancePp(y, x, this._row_y2, this._col_x2);
            value[4] = HMisc.DistancePp(y, x, this._mid_row_y, this._mid_col_x);

            for (int i = 0; i < _operation_piont_number; i++)
            {
                if (value[i] < max)
                {
                    max           = value[i];
                    _operationing = i;
                    break;
                }
            }

            return(_operationing);
        }
コード例 #4
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        /// <param name="x">x (=column) coordinate</param>
        /// <param name="y">y (=row) coordinate</param>
        /// <returns>
        /// Distance of the closest ROI handle.
        /// </returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[rows.Length];

            //midR = ((row2 - row1) / 2) + row1;
            //midC = ((col2 - col1) / 2) + col1;

            for (int i = 0; i < rows.Length; i++)
            {
                val[i] = HMisc.DistancePp(y, x, rows[i], cols[i]); // upper left
            }
            //////val[0] = HMisc.DistancePp(y, x, row1, col1); // upper left
            //////val[1] = HMisc.DistancePp(y, x, row1, col2); // upper right
            //////val[2] = HMisc.DistancePp(y, x, row2, col2); // lower right
            //////val[3] = HMisc.DistancePp(y, x, row2, col1); // lower left
            //////val[4] = HMisc.DistancePp(y, x, midR, midC); // midpoint
            //////val[5] = HMisc.DistancePp(y, x, (row1 + row2) / 2, col1);
            //////val[6] = HMisc.DistancePp(y, x, (row1 + row2) / 2, col2);
            //////val[7] = HMisc.DistancePp(y, x, row1, (col1 + col2) / 2);
            //////val[8] = HMisc.DistancePp(y, x, row2, (col1 + col2) / 2);

            for (int i = 0; i < rows.Length; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }// end of for

            return(val[activeHandleIdx]);
        }
コード例 #5
0
        /// <summary>Load camera calibration data from file</summary>
        /// <param name="file">Location of *.cal file</param>
        public void LoadCamParFile(string file)
        {
            exceptionText = "";
            try
            {
                mCamParameter = null;
                mCamParameter = HMisc.ReadCamPar(file);
            }
            catch (HOperatorException e)
            {
                mIsCalibValid = false;
                exceptionText = e.Message;
                throw (e);
            }

            if (mCamParameter == null || !(mCamParameter.Length > 0) || mCamPose == null || !(mCamPose.Length > 0))
            {
                mIsCalibValid = false;
            }
            else
            {
                mIsCalibValid = true;
            }

            if (mIsCalibValid)
            {
                UpdateExecute(ALL_ROI);
            }
        }
コード例 #6
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        /// <param name="x">x (=column) coordinate</param>
        /// <param name="y">y (=row) coordinate</param>
        /// <returns>
        /// Distance of the closest ROI handle.
        /// </returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            if (!_initPointsDone)
            {
                return(max);
            }

            double[] val = new double[NumHandles];
            for (int i = 0; i < NumHandles; i++)
            {
                val[i] = HMisc.DistancePp(y, x, rows[i].D, cols[i].D);
            }

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }
            return(val[activeHandleIdx]);
        }
コード例 #7
0
ファイル: ROIRectangle1.cs プロジェクト: chensen/WellsTools
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[NumHandles];

            midR = ((row2 - row1) / 2) + row1;
            midC = ((col2 - col1) / 2) + col1;

            val[0] = HMisc.DistancePp(y, x, midR, midC);              //0,mid
            val[1] = HMisc.DistancePp(y, x, row1, col1);              //1,up left
            val[2] = HMisc.DistancePp(y, x, row1, col2);              //2,up right
            val[3] = HMisc.DistancePp(y, x, row2, col2);              //3,down right
            val[4] = HMisc.DistancePp(y, x, row2, col1);              //4,down left
            val[5] = HMisc.DistancePp(y, x, row1, (col1 + col2) / 2); //5,up mid
            val[6] = HMisc.DistancePp(y, x, (row1 + row2) / 2, col2); //6,down mid
            val[7] = HMisc.DistancePp(y, x, row2, (col1 + col2) / 2); //7,down mid
            val[8] = HMisc.DistancePp(y, x, (row1 + row2) / 2, col1); //8,left mid

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }// end of for

            return(val[activeHandleIdx]);
        }
コード例 #8
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        /// <param name="x">x (=column) coordinate</param>
        /// <param name="y">y (=row) coordinate</param>
        /// <returns>
        /// Distance of the closest ROI handle.
        /// </returns>
        public override double distToClosestHandle(double x, double y, out int iHandleIndex)
        {
            double max = 10000;

            double [] val = new double[NumHandles];


            for (int i = 0; i < NumHandles; i++)
            {
                val[i] = HMisc.DistancePp(y, x, rows[i].D, cols[i].D);
            }

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }

            iHandleIndex = activeHandleIdx;

            return(val[activeHandleIdx]);
        }
コード例 #9
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            if (!_initPointsDone)
            {
                return(max);
            }
            double[] val = new double[NumHandles];

            val[0] = HMisc.DistancePp(y, x, midR, midC);                   // midpoint
            val[1] = HMisc.DistancePp(y, x, sizeR, sizeC);                 // border handle
            val[2] = HMisc.DistancePp(y, x, startR, startC);               // border handle
            val[3] = HMisc.DistancePp(y, x, extentR, extentC);             // border handle

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for
            return(val[activeHandleIdx]);
        }
コード例 #10
0
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        public override double distToClosestHandle(double x, double y)
        {
            double[] val = new double[NumHandles];

            val[0] = HMisc.DistancePp(y, x, _midR, _midC);             // midpoint
            var distance = (Math.Abs(_radius - val[0]) <= 5) ? 5 : val[0];

            return(distance < val[0] ? distance : val[0]);
        }
コード例 #11
0
 /// <summary>
 /// 載入 校正後的 CameraParam
 /// </summary>
 /// <param name="file"></param>
 public void ImportCameraInParam(string file)
 {
     if (!File.Exists(file))
     {
         Hanbo.Log.LogManager.Error("CameraInParam file does not exists");
         return;
     }
     CameraIn      = HMisc.ReadCamPar(file);
     mCamParameter = CameraIn;
 }
コード例 #12
0
 public AutoFitPoint(ROI roi, MeasureAssistant mAssist)
     : base(roi, mAssist)
 {
     mResult      = new EdgeResult();
     mResultWorld = new EdgeResult();
     if (mMeasAssist.IsCalibrationValid)
     {
         _cameraOut = HMisc.ChangeRadialDistortionCamPar("adaptive", mMeasAssist.CameraIn, 0.0);
     }
     UpdateMeasure();
 }
コード例 #13
0
        private bool IsContainPoint(double row, double col, double dist = 5)
        {
            foreach (var data in CalibratePP.CalibrateData)
            {
                if (HMisc.DistancePp(data.PixelRow, data.PixelCol, row, col) < dist)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #14
0
ファイル: CalibTool.cs プロジェクト: StevenPZChan/Utility
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (this.cTextBoxResult.Text == "")
            {
                MessageBox.Show("请选择保存路径!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            HMisc.WriteCamPar(this.CameraParameters, this.cTextBoxResult.Text + @"\campar.cal");
            this.CameraPose.WritePose(this.cTextBoxResult.Text + @"\campose.dat");
            MessageBox.Show("保存成功!", "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #15
0
        public bool WaitForClickPoints(double x, double y)
        {
            if (_clickedPointsPositionList.Count < _clickPoints)
            {
                var isNotTheSamePoint = _clickedPointsPositionList.Count == 0;
                var prevIdx           = _clickedPointsPositionList.Count - 1;
                var prevPoint         = prevIdx > -1 ? _clickedPointsPositionList[prevIdx] : null;
                if (prevPoint != null)
                {
                    isNotTheSamePoint = Math.Abs(prevPoint.ColBegin - x) > 0 || Math.Abs(prevPoint.RowBegin - y) > 0;
                }
                if (isNotTheSamePoint)
                {
                    _clickedPointsPositionList.Add(new PositionModel()
                    {
                        ColBegin = x, RowBegin = y
                    });
                }
            }

            _initPointsDone = _clickedPointsPositionList.Count == _clickPoints;
            if (_initPointsDone)
            {
                //產生 Rectangle 資訊
                midR = _clickedPointsPositionList.Average(p => p.RowBegin);
                midC = _clickedPointsPositionList.Average(p => p.ColBegin);

                //長度
                var beginRow = _clickedPointsPositionList[0].RowBegin;
                var beginCol = _clickedPointsPositionList[0].ColBegin;
                var endRow   = _clickedPointsPositionList[1].RowBegin;
                var endCol   = _clickedPointsPositionList[1].ColBegin;

                var distance = HMisc.DistancePp(beginRow, beginCol, endRow, endCol);
                length1 = distance / 2.0;
                length2 = 10;

                //決定角度
                creakPointPhi = phi = HMisc.AngleLx(beginRow, beginCol, endRow, endCol) * -1;

                rowsInit = new HTuple(new double[] { -1.0, -1.0, 1.0,
                                                     1.0, 0.0, 0.0 });
                colsInit = new HTuple(new double[] { -1.0, 1.0, 1.0,
                                                     -1.0, 0.0, 0.6 });
                //order        ul ,  ur,   lr,  ll,   mp, arrowMidpoint
                hom2D = new HHomMat2D();
                tmp   = new HHomMat2D();

                updateHandlePos();
            }
            return(_initPointsDone);
        }
コード例 #16
0
ファイル: LineDetection.cs プロジェクト: 22860364/Xvision
        public void FindLine(HImage image, double Row, double Column, double Phi, double Length1, double Length2, ushort pointNum, ushort EdgeWidth, ushort EdgeThresold, EdgePolarEnum edgePolar, EdgeTypeEnum edgeType, out PointF firstPoint, out PointF endPoint, out double angle, out HXLDCont[] cross, out HXLDCont line)
        {
            double[] row          = new double[pointNum];
            double[] column       = new double[pointNum];
            HTuple   _rowEdges    = new HTuple();
            HTuple   _columnEdges = new HTuple();

            image.GetImageSize(out int width, out int height);
            for (int i = 0; i <= (pointNum - 1) / 2; i++)//遍历搜索点数的一半
            {
                row[i]                   = Row - (Length2 - 2.0 * Length2 * (i + 1) / (pointNum + 1)) * Math.Cos(Phi);
                column[i]                = Column - (Length2 - 2.0 * Length2 * (i + 1) / (pointNum + 1)) * Math.Sin(Phi);
                row[pointNum - 1 - i]    = 2 * Row - row[i];
                column[pointNum - 1 - i] = 2 * Column - column[i];
            }
            for (int i = 0; i < pointNum - 1; i++)
            {
                HMeasure measure = new HMeasure(row[i], column[i], Phi, Length1, EdgeWidth, width, height, "nearest_neighbor");                                                              //获得测量矩形
                measure.MeasurePos(image, 1, EdgeThresold, edgePolar.ToString(), edgeType.ToString(), out HTuple rowEdge, out HTuple columnEdge, out HTuple Amplitude, out HTuple distance); //提取垂直于矩形或环形弧的直边
                if (rowEdge.Length > 0 && columnEdge.Length > 0)
                {
                    _rowEdges    = _rowEdges.TupleConcat(rowEdge);
                    _columnEdges = _columnEdges.TupleConcat(columnEdge);
                }
            }
            if (_rowEdges.Length > 5)
            {
                HXLDCont Contour = new HXLDCont(_rowEdges, _columnEdges);
                Contour.SmoothContoursXld(5);
                Contour.FitLineContourXld("tukey", -1, 0, 5, 2, out double rowBegin, out double columnBegin, out double rowEnd, out double columnEnd, out double nr, out double nc, out double dist);
                Contour.GenContourPolygonXld(new HTuple(rowBegin, rowEnd), new HTuple(columnBegin, columnEnd));
                cross = new HXLDCont[_rowEdges.Length];
                for (int i = 0; i < _rowEdges.Length; i++)
                {
                    HXLDCont _cross = new HXLDCont();
                    _cross.GenCrossContourXld(_rowEdges[i], _columnEdges[i], 30d, 0);
                    cross[i] = _cross;
                }
                firstPoint = new PointF((float)columnBegin, (float)rowBegin);
                endPoint   = new PointF((float)columnEnd, (float)rowEnd);
                angle      = HMisc.AngleLx(rowBegin, columnBegin, rowEnd, columnEnd) * 180 / Math.PI;
                line       = Contour;
            }
            else
            {
                firstPoint = new PointF(0, 0);
                endPoint   = new PointF(0, 0);
                cross      = null;
                line       = null;
                angle      = 0;
            }
        }
コード例 #17
0
        /// <summary>
        /// Auxiliary method to display an arrow at the extent arc position
        /// </summary>
        private void updateArrowHandle()
        {
            double row1, col1, row2, col2;
            double rowP1, colP1, rowP2, colP2;
            double length, dr, dc, halfHW, sign, angleRad;
            double headLength = 15;
            double headWidth  = 15;

            try
            {
                arrowHandleXLD.Dispose();
                arrowHandleXLD.GenEmptyObj();

                row2     = extentR;
                col2     = extentC;
                angleRad = (_startPhi + _extentPhi) + Math.PI * 0.5;

                sign = (_pointOrder == "negative") ? -1.0 : 1.0;
                row1 = row2 + sign * Math.Sin(angleRad) * 20;
                col1 = col2 - sign * Math.Cos(angleRad) * 20;

                length = HMisc.DistancePp(row1, col1, row2, col2);
                if (length == 0)
                {
                    length = -1;
                }

                dr = (row2 - row1) / length;
                dc = (col2 - col1) / length;

                halfHW = headWidth / 2.0;
                rowP1  = row1 + (length - headLength) * dr + halfHW * dc;
                rowP2  = row1 + (length - headLength) * dr - halfHW * dc;
                colP1  = col1 + (length - headLength) * dc - halfHW * dr;
                colP2  = col1 + (length - headLength) * dc + halfHW * dr;
                if (length == -1)
                {
                    arrowHandleXLD.GenContourPolygonXld(row1, col1);
                }
                else
                {
                    arrowHandleXLD.GenContourPolygonXld(new HTuple(new double[] { row1, row2, rowP1, row2, rowP2, row2 }),
                                                        new HTuple(new double[] { col1, col2, colP1, col2, colP2, col2 }));
                }
            }
            catch (Exception ex)
            {
                Hanbo.Log.LogManager.Error(ex);
            }
        }
コード例 #18
0
        public override double getDistanceFromStartPoint(double row, double col)
        {
            double sRow = midR;             // assumption: we have an angle starting at 0.0
            double sCol = midC + 1 * radius;

            double angle = HMisc.AngleLl(midR, midC, sRow, sCol, midR, midC, row, col);

            if (angle < 0)
            {
                angle += 2 * Math.PI;
            }

            return(radius * angle);
        }
コード例 #19
0
        /// <summary>
        /// Auxiliary method to display an arrow at the extent arc position
        /// </summary>
        private void updateArrowHandle()
        {
            double row1, col1, row2, col2;
            double rowP1, colP1, rowP2, colP2;
            double length, dr, dc, halfHW, sign, angleRad;

            int    width      = GetHandleWidth();
            double headLength = width;
            double headWidth  = width;

            if (arrowHandleXLD == null)
            {
                arrowHandleXLD = new HXLDCont();
            }
            arrowHandleXLD.Dispose();
            arrowHandleXLD.GenEmptyObj();

            row2     = extentR;
            col2     = extentC;
            angleRad = (startPhi + extentPhi) + Math.PI * 0.5;

            sign = (circDir == "negative") ? -1.0 : 1.0;
            row1 = row2 + sign * Math.Sin(angleRad) * 20;
            col1 = col2 - sign * Math.Cos(angleRad) * 20;

            length = HMisc.DistancePp(row1, col1, row2, col2);
            if (length == 0)
            {
                length = -1;
            }

            dr = (row2 - row1) / length;
            dc = (col2 - col1) / length;

            halfHW = headWidth / 2.0;
            rowP1  = row1 + (length - headLength) * dr + halfHW * dc;
            rowP2  = row1 + (length - headLength) * dr - halfHW * dc;
            colP1  = col1 + (length - headLength) * dc - halfHW * dr;
            colP2  = col1 + (length - headLength) * dc + halfHW * dr;

            if (length == -1)
            {
                arrowHandleXLD.GenContourPolygonXld(row1, col1);
            }
            else
            {
                arrowHandleXLD.GenContourPolygonXld(new HTuple(new double[] { row1, row2, rowP1, row2, rowP2, row2 }),
                                                    new HTuple(new double[] { col1, col2, colP1, col2, colP2, col2 }));
            }
        }
コード例 #20
0
        /// <summary>
        /// Defines the measuring field of a linear ROI.
        /// </summary>
        /// <param name="line">
        /// Model data for a linear interactive ROI
        /// </param>
        /// <param name="width">Half width of (rectangular) measure ROI</param>
        /// <returns>Model data describing a linear measuring field</returns>
        private HTuple GenSurRect2(HTuple line, double width)
        {
            double row1 = line[0];
            double col1 = line[1];
            double row2 = line[2];
            double col2 = line[3];

            double phi     = HMisc.AngleLx(row1, col1, row2, col2);
            double length1 = (HMisc.DistancePp(row1, col1, row2, col2)) / 2.0;
            double length2 = width;
            double rowM    = (row1 + row2) / 2;
            double colM    = (col1 + col2) / 2;

            return(new HTuple(new double[] { rowM, colM, phi, length1, length2 }));
        }
コード例 #21
0
        /// <summary>
        /// 辅助的箭头显示方法
        /// </summary>
        private void updateArrowHandle()
        {
            double length, dr, dc, halfHW;
            double rrow1, ccol1, rowP1, colP1, rowP2, colP2;

            int    width      = GetHandleWidth();
            double headLength = width;
            double headWidth  = width;

            if (arrowHandleXLD == null)
            {
                arrowHandleXLD = new HXLDCont();
            }
            arrowHandleXLD.Dispose();
            arrowHandleXLD.GenEmptyObj();

            //箭头起始点为直线长度的0.8位置
            rrow1 = startRow + (endRow - startRow) * 0.8;
            ccol1 = startCol + (endCol - startCol) * 0.8;
            //测量箭头起始点到直线终点的距离
            length = HMisc.DistancePp(rrow1, ccol1, endRow, endCol);
            //如果距离为0说明直线长度为0
            if (length == 0)
            {
                length = -1;
            }

            dr = (endRow - rrow1) / length;
            dc = (endCol - ccol1) / length;

            halfHW = headWidth / 2.0;
            rowP1  = rrow1 + (length - headLength) * dr + halfHW * dc;
            rowP2  = rrow1 + (length - headLength) * dr - halfHW * dc;
            colP1  = ccol1 + (length - headLength) * dc - halfHW * dr;
            colP2  = ccol1 + (length - headLength) * dc + halfHW * dr;

            if (length == -1)
            {
                arrowHandleXLD.GenContourPolygonXld(rrow1, ccol1);
            }
            else
            {
                arrowHandleXLD.GenContourPolygonXld(new HTuple(new double[] { rrow1, endRow, rowP1, endRow, rowP2, endRow }),
                                                    new HTuple(new double[] { ccol1, endCol, colP1, endCol, colP2, endCol }));
            }
        }
コード例 #22
0
        /// <summary>
        /// Triggers an update of the measure results because of
        /// changes in the parameter setup or a recreation of the measure
        /// object caused by an update in the ROI model.
        /// </summary>
        public override void UpdateResults()
        {
            if (mHandle == null)
            {
                return;
            }

            mMeasAssist.exceptionText = "";

            try
            {
                HObject imageReduced;
                HOperatorSet.GenEmptyObj(out imageReduced);
                //«Ø ROI
                var     roiModel = mRoi.getModelData();
                var     row      = roiModel[0];
                var     column   = roiModel[1];
                var     phi      = roiModel[2];
                var     length1  = roiModel[3];
                var     length2  = roiModel[4];
                HRegion region   = new HRegion();
                region.GenRectangle2(row.D, column.D, phi.D, length1.D, length2.D);

                if (mMeasAssist.ApplyCalibration && mMeasAssist.IsCalibrationValid)
                {
                    HTuple cameraOut    = HMisc.ChangeRadialDistortionCamPar("adaptive", mMeasAssist.CameraIn, 0.0);
                    var    rectifyImage = mMeasAssist.mImage.ChangeRadialDistortionImage(region, mMeasAssist.CameraIn, cameraOut);
                    measurePos(rectifyImage);
                }
                else
                {
                    HOperatorSet.ReduceDomain(mMeasAssist.mImage, region, out imageReduced);
                    measurePos(new HImage(imageReduced));
                }
                mResultWorld = new EdgeResult(mResult);
            }
            catch (HOperatorException e)
            {
                mEdgeXLD.Dispose();
                mMeasAssist.exceptionText = e.Message;
                mResultWorld = new EdgeResult();
                return;
            }
            UpdateXLD();
        }
コード例 #23
0
        /// <summary>
        /// 計算滑鼠位置接近控制點 (Handle) 的距離
        /// </summary>
        /// <param name="x">x position of mouse</param>
        /// <param name="y">y position of mouse</param>
        /// <returns></returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[NumHandles];

            val[0] = HMisc.DistancePp(y, x, this._rawPointRow, this._rawPointCol);             // midpoint

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for
            return(val[activeHandleIdx]);
        }
コード例 #24
0
        /// <summary>
        /// 計算滑鼠位置接近控制點 (Handle) 的距離
        /// </summary>
        /// <param name="x">x position of mouse</param>
        /// <param name="y">y position of mouse</param>
        /// <returns></returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[NumHandles];

            val[0] = HMisc.DistancePp(y, x, this.NewCenterRow, this.NewCenterCol);             // midpoint
            val[1] = HMisc.DistancePl(y, x, this._arrowLineRowBegin, this._arrowLineColBegin, this._arrowLineRowEnd, this._arrowLineColEnd);
            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for
            return(val[activeHandleIdx]);
        }
コード例 #25
0
ファイル: ROICircle.cs プロジェクト: lake2010/SZVppFilmUI
        /// <summary>
        /// Returns the distance of the ROI handle being
        /// closest to the image point(x,y)
        /// </summary>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double [] val = new double[NumHandles];

            val[0] = HMisc.DistancePp(y, x, row1, col1);             // border handle
            val[1] = HMisc.DistancePp(y, x, midR, midC);             // midpoint
            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for
            return(val[activeHandleIdx]);
        }
コード例 #26
0
        /// <summary>
        /// 計算滑鼠位置接近控制點 (Handle) 的距離
        /// </summary>
        /// <param name="x">x position of mouse</param>
        /// <param name="y">y position of mouse</param>
        /// <returns></returns>
        public override double distToClosestHandle(double x, double y)
        {
            double max = 10000;

            double[] val = new double[NumHandles];

            val[0] = HMisc.DistancePl(y, x, _model.RowBegin, _model.ColBegin, _model.RowEnd, _model.ColEnd);

            for (int i = 0; i < NumHandles; i++)
            {
                if (val[i] < max)
                {
                    max             = val[i];
                    activeHandleIdx = i;
                }
            }            // end of for
            return(val[activeHandleIdx]);
        }
コード例 #27
0
        /// <summary>
        /// 是否选中圆
        /// </summary>
        /// <returns></returns>
        public override int isSelected(double x, double y)
        {
            _operationing = -1;

            double max = 35;

            double[] value = new double[_operation_piont_number];
            value[0] = HMisc.DistancePp(y, x, _row_r_y, _col_r_x);
            value[1] = HMisc.DistancePp(y, x, _center_row_y, _center_column_x);
            for (int i = 0; i < _operation_piont_number; i++)
            {
                if (value[i] < max)
                {
                    max           = value[i];
                    _operationing = i;
                }
            }
            return(_operationing);
        }
コード例 #28
0
        public void SetCrossActive(double x, double y)
        {
            double[] val = new double[crossList.Count];
            for (int i = 0; i < crossList.Count; i++)
            {
                crossList[i].Color = InActiveColor;
                val[i]             = HMisc.DistancePp(crossList[i].Pixel.Y, crossList[i].Pixel.X, y, x);
            }

            if (val.Length > 0 && val.Min() < FAR_ACTIVE_DISTANCE)
            {
                ActiveIndex = Array.IndexOf(val, val.Min());
                crossList[ActiveIndex].Color = AcitveColor;
            }
            else
            {
                ActiveIndex = -1;
            }
        }
コード例 #29
0
ファイル: Camera.cs プロジェクト: abedGNU/LibreCV-cSharp
 public void readCamParam()
 {
     try
     {
         FileInfo fi = new FileInfo(dirPath + @"\Cameras\" + cameraName + @"\camera_parameters.dat");
         if (fi.Exists)
         {
             CameraParameter = HMisc.ReadCamPar(fi.FullName);
         }
     }
     catch (HOperatorException ex)
     {
         Utilitiy.write_error(this.GetType().FullName, System.Reflection.MethodBase.GetCurrentMethod().ToString(), ex, DataType.eErrors.Exeption);
     }
     catch (Exception ex)
     {
         Utilitiy.write_error(this.GetType().FullName, System.Reflection.MethodBase.GetCurrentMethod().ToString(), ex, DataType.eErrors.Exeption);
     }
 }
コード例 #30
0
        private void btnReadParam_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.DefaultExt = "cal";
            this.openFileDialog1.FileName   = "campar.cal";
            this.openFileDialog1.Filter     = "内参数据文件 | *.*";
            if (DialogResult.OK != this.openFileDialog1.ShowDialog())
            {
                return;
            }

            this.CameraParam    = HMisc.ReadCamPar(this.openFileDialog1.FileName);
            this.tbxFocus.Text  = this.CameraParam[0].D.ToString(CultureInfo.InvariantCulture);
            this.tbxKappa.Text  = this.CameraParam[1].D.ToString(CultureInfo.InvariantCulture);
            this.tbxSx.Text     = this.CameraParam[2].D.ToString(CultureInfo.InvariantCulture);
            this.tbxSy.Text     = this.CameraParam[3].D.ToString(CultureInfo.InvariantCulture);
            this.tbxCx.Text     = this.CameraParam[4].D.ToString(CultureInfo.InvariantCulture);
            this.tbxCy.Text     = this.CameraParam[5].D.ToString(CultureInfo.InvariantCulture);
            this.tbxWidth.Text  = this.CameraParam[6].I.ToString();
            this.tbxHeight.Text = this.CameraParam[7].I.ToString();
        }