예제 #1
0
        /// <summary>
        ///Extract text from Image frame
        /// </summary>
        /// <param name="fileNameObj">Accepts Object of ImageFileInput</param>
        /// <returns></returns>
        public ImageContent ExtractTextFromImage(ImageFile fileNameObj)
        {
            ImageContent _imageContent = new ImageContent();

            _imageContent.Content = _imageGrabber.ExtractTextFromImage(fileNameObj.FileName);
            return(_imageContent);
        }
        /// <summary>
        /// To get metadata of image
        /// </summary>
        /// <param name="imagePath"></param>
        /// <param name="appStartPath"></param>
        /// <returns>DataLayer.EntityModel.Image</returns>
        public DataLayer.EntityModel.Image GetImageMetadata(string imagePath, string appStartPath)
        {
            int  height = 0, width = 0, RedPercentage = 0, BluePercentage = 0, GreenPercentage = 0;
            long length = 0;

            DataLayer.EntityModel.Image imageObj = new DataLayer.EntityModel.Image();
            //to get checksum
            string checksume = GetChecksumMD5(imagePath);
            //to get no of faces from image
            int noOfFaces = _faceDetection.GetNoOfFacesFromImage(appStartPath, imagePath);

            //to get metadata
            _imgGrabber.GetImageMetadata(imagePath, ref height, ref width, ref length, ref RedPercentage, ref BluePercentage, ref GreenPercentage);
            //to check image contains text or not
            string imageContent = _imgGrabber.ExtractTextFromImage(imagePath);

            imageContent                 = string.IsNullOrEmpty(imageContent) ? imageContent : imageContent.Replace("\r\n", "");
            imageObj.RedPercentage       = RedPercentage;
            imageObj.GreenPercentage     = GreenPercentage;
            imageObj.BluePercentage      = BluePercentage;
            imageObj.Checksum            = checksume;
            imageObj.Height              = height;
            imageObj.Width               = width;
            imageObj.ImagePath           = imagePath;
            imageObj.IsImageContainsFace = noOfFaces > 0 ? true : false;
            imageObj.IsImageContainsText = imageContent.Length > 0 ? true : false;
            imageObj.Length              = length;
            imageObj.Name                = imagePath.Contains("\\") ? imagePath.Split('\\')[imagePath.Split('\\').Count() - 1] : imagePath;
            imageObj.FaceCount           = noOfFaces;
            imageObj.CreatedDatetime     = DateTime.Now;
            imageObj.IsDeleted           = false;
            imageObj.Description         = imageContent;

            return(imageObj);
        }