コード例 #1
0
ファイル: TextDetectionModel.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Given the input frame, prepare network input, run network inference, post-process network output and return result detections.
 /// </summary>
 /// <param name="frame">The input image</param>
 /// <param name="detections">Array with detections' RotationRect results</param>
 /// <param name="confidences">Array with detection confidences</param>
 public void DetectTextRectangles(IInputArray frame, VectorOfRotatedRect detections, VectorOfFloat confidences)
 {
     using (InputArray iaFrame = frame.GetInputArray())
     {
         DnnInvoke.cveDnnTextDetectionModelDetectTextRectangles(_textDetectionModel, iaFrame, detections, confidences);
     }
 }
コード例 #2
0
        /// <summary>
        /// Performs non maximum suppression given boxes and corresponding scores.
        /// </summary>
        /// <param name="bboxes">a set of bounding boxes to apply NMS.</param>
        /// <param name="scores">a set of corresponding confidences.</param>
        /// <param name="scoreThreshold">a threshold used to filter boxes by score.</param>
        /// <param name="nmsThreshold">a threshold used in non maximum suppression.</param>
        /// <param name="indices">the kept indices of bboxes after NMS.</param>
        /// <param name="eta">a coefficient in adaptive threshold formula</param>
        /// <param name="topK">if `&gt;0`, keep at most @p top_k picked indices.</param>
        // ReSharper disable once IdentifierTypo
        public static void NMSBoxes(IEnumerable <RotatedRect> bboxes, IEnumerable <float> scores,
                                    float scoreThreshold, float nmsThreshold,
                                    out int[] indices,
                                    float eta = 1.0f, int topK = 0)
        {
            if (bboxes == null)
            {
                throw new ArgumentNullException(nameof(bboxes));
            }
            if (scores == null)
            {
                throw new ArgumentNullException(nameof(scores));
            }

            // ReSharper disable once IdentifierTypo
            using (var bboxesVec = new VectorOfRotatedRect(bboxes))
                using (var scoresVec = new VectorOfFloat(scores))
                    using (var indicesVec = new VectorOfInt32())
                    {
                        NativeMethods.dnn_NMSBoxes_RotatedRect(
                            bboxesVec.CvPtr, scoresVec.CvPtr, scoreThreshold, nmsThreshold,
                            indicesVec.CvPtr, eta, topK);
                        indices = indicesVec.ToArray();
                    }
        }
コード例 #3
0
ファイル: DnnInvoke.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Performs non maximum suppression given boxes and corresponding scores.
 /// </summary>
 /// <param name="bboxes">A set of bounding boxes to apply NMS.</param>
 /// <param name="scores">A set of corresponding confidences.</param>
 /// <param name="scoreThreshold">A threshold used to filter boxes by score.</param>
 /// <param name="nmsThreshold">A threshold used in non maximum suppression.</param>
 /// <param name="eta">A coefficient in adaptive threshold</param>
 /// <param name="topK">If &gt;0, keep at most top_k picked indices.</param>
 /// <returns>The indices of the boxes to keep after NMS</returns>
 public static int[] NMSBoxes(RotatedRect[] bboxes, float[] scores, float scoreThreshold, float nmsThreshold, float eta = 1.0f, int topK = 0)
 {
     using (VectorOfRotatedRect vBoxes = new VectorOfRotatedRect(bboxes))
         using (VectorOfFloat vScores = new VectorOfFloat(scores))
             using (VectorOfInt indices = new VectorOfInt())
             {
                 NMSBoxes(vBoxes, vScores, scoreThreshold, nmsThreshold, indices, eta, topK);
                 return(indices.ToArray());
             }
 }
コード例 #4
0
ファイル: DnnInvoke.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Performs non maximum suppression given boxes and corresponding scores.
 /// </summary>
 /// <param name="bboxes">A set of bounding boxes to apply NMS.</param>
 /// <param name="scores">A set of corresponding confidences.</param>
 /// <param name="scoreThreshold">A threshold used to filter boxes by score.</param>
 /// <param name="nmsThreshold">A threshold used in non maximum suppression.</param>
 /// <param name="indices">The kept indices of bboxes after NMS.</param>
 /// <param name="eta">A coefficient in adaptive threshold</param>
 /// <param name="topK">If &gt;0, keep at most top_k picked indices.</param>
 public static void NMSBoxes(VectorOfRotatedRect bboxes, VectorOfFloat scores, float scoreThreshold, float nmsThreshold, VectorOfInt indices, float eta = 1.0f, int topK = 0)
 {
     cveDnnNMSBoxes2(bboxes, scores, scoreThreshold, nmsThreshold, indices, eta, topK);
 }