public static string GetTextFromImage(string path)
        {
            Bitmap         bitmap    = new Bitmap(path);
            GoogleCloudApi googleApi = new GoogleCloudApi();
            string         output    = googleApi.RecognizeText(bitmap, new List <string>()
            {
                "pl", "en"
            }, 10000);

            return(output);
        }
示例#2
0
        public void Execute(Arguments arguments)
        {
            var screenArea  = !arguments.Relative.Value ? arguments.Area.Value : arguments.Area.Value.ToAbsoluteCoordinates();
            var screenImage = RobotWin32.GetPartOfScreen(screenArea);
            var timeout     = (int)arguments.Timeout.Value.TotalMilliseconds;
            var languages   = arguments.Languages.Value.Split(',').ToList();
            var googleApi   = new GoogleCloudApi();
            var text        = googleApi.RecognizeText(screenImage, languages, timeout);

            if (string.IsNullOrEmpty(text))
            {
                throw new NullReferenceException("Ocr was unable to find text");
            }

            Scripter.Variables.SetVariableValue(arguments.Result.Value, new TextStructure(text));
        }
示例#3
0
        public void Execute(Arguments arguments)
        {
            Rectangle      rectangle    = !arguments.Relative.Value ? arguments.Area.Value : arguments.Area.Value.ToAbsoluteCoordinates();
            Bitmap         partOfScreen = RobotWin32.GetPartOfScreen(rectangle);
            int            timeout      = (int)arguments.Timeout.Value.TotalMilliseconds;
            List <string>  languages    = arguments.Languages.Value.Split(',').ToList();
            string         search       = arguments.Search.Value;
            GoogleCloudApi googleApi    = new GoogleCloudApi();
            Rectangle      output       = googleApi.RecognizeText(partOfScreen, search, languages, timeout);

            if (Equals(output, new Rectangle(-1, -1, -1, -1)))
            {
                throw new NullReferenceException("Ocr was unable to find text");
            }
            Scripter.Variables.SetVariableValue(arguments.Result.Value, new RectangleStructure(output));
        }