Пример #1
0
        /// <summary>
        /// Converts MSER contours (vector<Point>) to ERStat regions.
        /// </summary>
        /// <param name="image">Source image CV_8UC1 from which the MSERs where extracted.</param>
        /// <param name="contours">Input vector with all the contours</param>
        /// <param name="regions">Output where the ERStat regions are stored</param>
        public static void MSERsToERStats(InputArray image, Point[][] contours, out ERStat[][] regions)
        {
            using (var vecRegions = new VectorOfVectorERStat())
                using (var vecContours = new VectorOfVectorPoint(contours))
                {
                    NativeMethods.text_MSERsToERStats(image.CvPtr, vecContours.CvPtr, vecRegions.CvPtr);

                    regions = vecRegions.ToArray();
                }
        }
Пример #2
0
        /// <summary>
        /// Find groups of Extremal Regions that are organized as text blocks
        /// </summary>
        /// <param name="image">Original RGB or Greyscale image from wich the regions were extracted</param>
        /// <param name="channels">Vector of single channel images CV_8UC1 from wich the regions were extracted</param>
        /// <param name="regions">Vector of ER's retrieved from the ERFilter algorithm from each channel</param>
        /// <param name="groups">The output of the algorithm is stored in this parameter as set of lists of indexes to provided regions</param>
        /// <param name="groups_rects">The output of the algorithm are stored in this parameter as list of rectangles</param>
        /// <param name="method">Grouping method (see GroupingModes). Can be one of { OrientationHorizontal, OrientationAny }</param>
        /// <param name="filename">The XML or YAML file with the classifier model. Only to use when grouping method is OrientationAny</param>
        /// <param name="minProbablity">The minimum probability for accepting a group. Only to use when grouping method is OrientationAny</param>
        public static void ErGrouping(Mat image, Mat[] channels, ERStat[][] regions, out Vec2i[][] groups, out Rect[] groups_rects, GroupingModes method, string filename = null, float minProbablity = 0.5f)
        {
            using (var vecChannels = new InputArray(channels))
                using (var vecRegions = new VectorOfVectorERStat(regions))
                    using (var vecGroups = new VectorOfVectorVec2i())
                        using (var vecRects = new VectorOfRect())
                            using (var input = new InputArray(image))
                            {
                                if (null == filename)
                                {
                                    filename = string.Empty;
                                }
                                NativeMethods.text_erGrouping1(input.CvPtr, vecChannels.CvPtr, vecRegions.CvPtr, vecGroups.CvPtr, vecRects.CvPtr, (int)method, filename, minProbablity);

                                groups       = vecGroups.ToArray();
                                groups_rects = vecRects.ToArray();
                            }
        }