Automation and bots

 Помощь      Поиск      Пользователи


 Страниц (1): [1]   

> Без описания
Kibor
Отправлено: 25 Июля, 2018 - 15:51:22
Post Id



Администратор
Full Member


Покинул форум
Сообщений всего: 160
Дата рег-ции: Дек. 2017  
Репутация: 0
Карма 0




Added a learning text recognition function readtext . Purpose - recognition of the text provided in the form of images (screen area, game window area (program), BMP file JPG PNG) for further translation into text and/or numbers.
Added training tool. You can find it in the graphics tab by selecting the desired area with text and clicking the right mouse button> Set text recognition.

Download the training base. I was trained in a notebook on standard fonts. About 10.
Video work functions and learning process.


This video shows the use of optical text recognition when creating a bot to play in a visual editor.


The bot for surfing. Razgadyvaet simple caches, works in the background
Creating a bot for Music Wars in real time. Scanning and Recognizing Screen Data

readtext - scans the specified area of ​​the screen, window or two-dimensional array int where the image is downloaded, clears the image from noise, recognizes the text and writes it to string or char
loadsymbolbase - loads the trained database. You can load multiple databases.
symbolxpos - returns the character position on X from the beginning of the search zone. Left corner
symbolypos - returns the character position of Y from the beginning of the search zone. bottom corner
symbolwidth - returns the width of the character
symbolheight - returns the height of the symbol
symbolcorrect - returns an evaluation of the correctness of character recognition. maximum 1
symboltype - returns a type. 0 digit, 1 Russian, 2 English, 3 punctuation mark, etc.
allowsymbolbase - connects the selected database to the previously loaded loadsymbolbase
disablesymbolbase - disables a particular database selected previously loadedymbolbase


Parameters:
readtext (RU, #ch [0] [0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);
1 - what types of characters will we look for
NUM digits
RU Russian
EN English
MARK signs
Can be combined
NUM | RU | EN | MARK
CODE:
readtext (NUM | RU | EN | MARK, #ch [0] [0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483 , -1);


2 - where we will save the text

It is possible in string
CODE:
string text;
readtext (RU, #text, 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);


In this case, the multiline text will be separated by a line translation.
CODE:
string text [5];
readtext (RU, #text [0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);

In this case, text [0] will be the first line, in text [1] the second, etc.

It is possible in char
CODE:
char c;
readtext (RU, #c, 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);

In this case, c will have one first character.

CODE:
char c [200];
readtext (RU, #c [0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);

In this case, c will have all the text. The lines will be separated 0

 Цитата:
char c[5][200];
readtext (RU, #c[0][0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);

In this case, the text
cyborg
bot

will be located like this:
CODE:
c [0] [0]='to', c [0] [1]='and', c [0] [2]='b', c [0] [3]=' , c [0] [4]='p', c [0] [5]=0;
c [1] [0]='b', c [1] [1]='o', c [1] [2]='t', c [1] [3]=0;

The end of the line is filled with 0, so you need to allocate more memory than the text.


3 - text/background filter parameter. You can learn it in the setup and training tool.
4 - smoothing parameter
5 - Contrast
6 - length of horizontal lines to be removed
7 - length of vertical lines to be removed
8 - pointer (if necessary) on a one-dimensional array int in which there are text colors
9 - pointer (if necessary) on a one-dimensional array int in which the background colors are located
10 - permissibility of these colors
CODE:
int col_text [2];
col_text [0]=236455;
col_text [1]=23445;
int col_fon [1];
col_fon [0]=654767567;
readtext (RU | MARK, #ch [0] [0], 4, 1, -1, 35, 35, #col_text [0], #col_fon [0], 25, 50, 11, 150, 641, 483, -1);

If you do not put -1

11 - the amount of training. This parameter indicates how much we trust the program to make decisions on the separation of the symbol, merge and

etc. To indicate no more than the ratings in the settings and training tool show.

12 13 14 15 - scanning area. The function is demanding. Do not specify a large zone with a large number of characters. Only that which is necessary to recognize.

16 - a pointer to the window, a screen or a two-dimensional array int in which the image is located.

CODE:
readtext (RU | MARK, #ch [0] [0], 4, 1, -1, 35, 35, #col_text [0], #col_fon [0], 25, 50, 11, 150, 641 , 483, -1);//the whole screen

CODE:
win w=window ("rf online.jpg - Paint", "MSPaintApp", -1);
readtext (RU | MARK, #ch [0] [0], 4, 1, -1, 35, 35, #col_text [0], #col_fon [0], 25, 50, 11, 150, 641, 483, w);//window


CODE:
int Image_0 [351] [82];
loadimage (# Image_0 [0] [0], "C:\Image_0.bmp");
readtext (RU | MARK, #ch [0] [0], 4, 1, -1, 35, 35, #col_text [0], #col_fon [0], 25, 50, 11, 150, 641, 483, # Image_0 [0] [0]);//image



The function returns the number of characters including spaces and line breaks.
-1 if the scan area is outside the image
-2 if there are more than the allocated memory for the receive.
==============================


loadsymbolbase
Parameter
CODE:
loadsymbolbase ("C:\simvol\Base.sib");


symbolxpos
Parameters:
CODE:
symbolxpos (5);

Returns the position in X 5 of the recognized symbol. It is recognized line by line from the upper left corner.

CODE:
symbolxpos (2, 7);

Returns the position of X 8 characters in the 3 line.


CODE:
symbolcorrect (0);

Returns the correctness of the recognition of the first character from 1 and lower.
The higher the value of the topics, we can more trust that the symbol is recognized exactly.

With the rest of the functions,


=====


loadsymbolbase allows you to load multiple text recognition databases.

loadsymbolbase ("C:\basetext.sib");//0 base
loadsymbolbase ("C:\mer.sib");//1 base
loadsymbolbase ("C:\cum.sib");//2 base


They all merged into one with which the text recognition function worked readtext


Functions
enablesymbolbase - connects a particular database that was previously loaded loadsymbolbase
disablesymbolbase - disables the selected database previously loaded loadsymbolbase

You can use these functions dynamically at runtime of the script anywhere.

Syntax:
enablesymbolbase (0);
disablesymbolbase (2);

When loading the bases loadsymbolbase , they are numbered in the order of loading from 0

The above code includes the first loaded database and disables 3.

It is also possible to connect or disconnect all databases at once

enablesymbolbase (ALL);
disablesymbolbase (ALL);

=========================

By default, when loading the base loadsymbolbase , it connects automatically and does not require a call enablesymbolbase

An example of scanning a screen and outputting text information as a string


CODE:
string text;
loadsymbolbase ("C:\simvol\TEST\Base.sib");//Load the database

loop ()
{
readtext (RU | NUM | MARK, #text, 2, 1, -1, -1, -1, -1, -1, 0, -1, 77, 162, 248, 192, -1);
textout (0, 50, 50, text + "", 0);
sleep (20);
}




An example of scanning part of the screen and searching for necessary words on it with their positions.
CODE:
char ch [20] [100];
string t;
int n, u, u1, k, n1, x, y;

loadsymbolbase ("C:\simvol\TEST\Base.sib");//Load the database

sleep (500);
for (n=0; n <20; n ++) ch [n] [0]=0;
//Scan and recognize the text. Write it into a two-dimensional char array continually
readtext (RU, #ch [0] [0], 4, 1, -1, 35, 35, -1, -1, 0, 50, 11, 150, 641, 483, -1);
n1=0;


//Look for the words KIBOR in this array
for (n=0; n <20; n ++)
{
t="";
k=size (#ch [n] [0]);
for (u=0; u <k; u ++)
{
if (ch [n] [u]=='to')
{
x=symbolxpos (n, u) +11;
y=symbolypos (n, u) +153;
for (u1=u; u1 <k; u1 ++)
{
if (ch [n] [u1]!='')
{
t=t + ch [n] [u1];
if (t=="cyborg")
{
textout (n1, x, y, t, 0);
//mousemove (symbolxpos (n, u1) + 11-10, symbolypos (n, u1) + 150-2);
n1 ++;
//pause (1000);
t="";
u=u1;
goto d;
}
}
}
}
d :;
}
}

loop () sleep (100) ;;


The work of these scripts can be seen on the video.






To get the code of the configured readtext function, you can click on the button
GET THE READTEXT CODE

Generates the complete code of the configured readtext function, loadsymbolbase, variables, and so on.
The coordinates of the scanning zone are inserted on the screen and coincide with the real ones only when you receive a picture in the SCREEN mode. Therefore, when working in windowed mode, you must specify them yourself, as well as the pointer to the window.

=========================================

This code will find the text zones where the player names are written and recognizes the names.
Zones are defined with respect to the fragment of the label under the text. Explanation on the screen.

Download
Recognition database from the first post http://kibor-bot.com/files/basetext.sib
The search for the part of the tablet http://kibor-bot.com/files/readtext_fifa/tab.bmp

Explanation:


This image is scanned and text is recognized on it. Arrange it so that everything on the screen is displayed.





CODE:
int tab [50] [50];
int x [10], y [10];
int r=50, p=100;

int col, ex, ey;

int smX=38, smY=55;
int razmX=93, razmY=12;

int zona_text_X1, zona_text_Y1;
int zona_text_X2, zona_text_Y2;

string Text;

if (loadimage (#tab [0] [0], "C:\tab.bmp") <1) {messagebox ("no C:\tab.bmp"); goto er;}
if (loadsymbolbase ("C:\basetext.sib") <1) {messagebox ("noC:\basetext.sib"); goto er;}


getdisplay (col, ex, ey);

pause (1000);
int k=findimage (10, #tab [0] [0], 0, #x [0], #y [0], 0, 0, ex, ey, r, r, r, r, r, r, p, 1, -1);


for (int n=0; n <k; n ++)
{
zona_text_X1=x [n] -smX;
zona_text_Y1=y [n] -smY;
zona_text_X2=zona_text_X1 + razmX;
zona_text_Y2=zona_text_Y1 + razmY;

readtext (EN, #Text, 9, 1, 50, -1, -1, -1, -1, 0, 50, zona_text_X1, zona_text_Y1, zona_text_X2, zona_text_Y2, -1);
messagebox (Text);
pause (1000);
}

er:;


-----
The Visual Code Editor is Kibor. Creating bots without knowledge of programming.

Learning function for recognizing text.
-----
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 1 (гостей: 1, зарегистрированных: 0)
« About Kibor »


Все гости форума могут просматривать этот раздел.
Только администраторы и модераторы могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 




Powered by