Покинул форум
Сообщений всего: 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.
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
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
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.
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.
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.
Все гости форума могут просматривать этот раздел. Только администраторы и модераторы могут создавать новые темы в этом разделе. Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.