コード例 #1
0
        /// <summary>
        /// 找到匹配模型
        /// </summary>
        /// <param name="hImage">影像</param>
        /// <param name="hv_A1LModelId">匹配模型 ID</param>
        /// <returns></returns>
        public ShapeModel Find(HObject hImage, HTuple hv_A1LModelId)
        {
            ShapeModel shapeModel = null;

            try
            {
                shapeModel = findShapeModel(hImage, hv_A1LModelId);
            }
            catch (Exception ex)
            {
                Hanbo.Log.LogManager.Error("ShapeFinder exception:" + ex.Message);
            }
            return(shapeModel);
        }
コード例 #2
0
        /// <summary>
        /// 找到匹配模型
        /// </summary>
        /// <param name="hImage">影像</param>
        /// <param name="trainingModelfilepath">匹配模型數據檔案路徑</param>
        /// <returns></returns>
        public ShapeModel Find(HObject hImage, string trainingModelfilepath)
        {
            ShapeModel shapeModel = null;

            if (File.Exists(trainingModelfilepath))
            {
                try
                {
                    Hanbo.Log.LogManager.Trace("ShapeFinder @Find() => readShapeModel()");
                    HTuple hv_A1LModelId = ReadShapeModel(trainingModelfilepath);
                    shapeModel = findShapeModel(hImage, hv_A1LModelId);
                }
                catch (Exception ex)
                {
                    Hanbo.Log.LogManager.Error("ShapeFinder exception:" + ex.Message);
                }
            }
            return(shapeModel);
        }
コード例 #3
0
        private ShapeModel findShapeModel(HObject hImage, HTuple hv_A1LModelId)
        {
            ShapeModel shapeModel = null;
            //local variables
            HTuple hv_ModelRow, hv_ModelColumn, hv_ModelAngle, hv_ModelScore;

            //find
            Hanbo.Log.LogManager.Trace("ShapeFinder @Find() => FindShapeModel(), MinScore = " + _minScore);
            HOperatorSet.FindShapeModel(hImage, hv_A1LModelId, (new HTuple(0)).TupleRad()
                , (new HTuple(360)).TupleRad(),
                _minScore,
                _numMatches,
                _maxOverlap,
                _subpixAlgo,
                _numberOfLevel,
                _greediness,
                out hv_ModelRow, out hv_ModelColumn, out hv_ModelAngle, out hv_ModelScore);

            //result model
            if (hv_ModelScore.DArr.Length > 0)
            {
                shapeModel = new ShapeModel()
                {
                    ModelId = hv_A1LModelId,
                    Row = hv_ModelRow,
                    Col = hv_ModelColumn,
                    Angle = hv_ModelAngle,
                    Score = hv_ModelScore
                };
            }
            return GetOrderdShapeModel(shapeModel);
        }
コード例 #4
0
 /// <summary>
 /// 取得排序後的 Model, Order by Col theny By Row
 /// </summary>
 /// <param name="raw"></param>
 /// <returns></returns>
 public ShapeModel GetOrderdShapeModel(ShapeModel raw)
 {
     ShapeModel orderedModel = null;
     if (raw != null)
     {
         List<ShapeModelDataTransferObject> aList = new List<ShapeModelDataTransferObject>();
         for (int i = 0; i < raw.Score.TupleLength(); i++)
         {
             aList.Add(new ShapeModelDataTransferObject()
             {
                 Row = raw.Row[i].D,
                 Col = raw.Col[i].D,
                 Angle = raw.Angle[i].D,
                 Score = raw.Score[i].D,
             });
         }
         var orderedList = aList.OrderBy(p => p.Col).ThenBy(p => p.Row).ToList();
         orderedModel = new ShapeModel()
         {
             ModelId = raw.ModelId,
             Row = orderedList.Select(p => p.Row).ToArray(),
             Col = orderedList.Select(p => p.Col).ToArray(),
             Angle = orderedList.Select(p => p.Angle).ToArray(),
             Score = orderedList.Select(p => p.Score).ToArray(),
         };
     }
     return orderedModel;
 }