Cell positioning method, device, storage medium and computer equipment
By converting the statistical results of cells in the table into pixel values and using the object detection model to detect image files, the problem of complex and inaccurate positioning of cells in the prior art is solved, and more efficient and accurate cell positioning is achieved.
Patent Information
- Application Number
- CN202210238405.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-11
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2042-03-11
AI Technical Summary
In the prior art, using matching rules to locate cells is complex and inaccurate, making it difficult to adapt to changes in table writing style and character content.
By counting the character types and number of characters of each cell in the table, converting these statistical results into pixel values, generating an image file, and detecting the image file using a pre-trained object detection model to obtain cell position information.
Reduces the complexity of manual configuration matching rules and improves cell positioning efficiency and accuracy.
Smart Images

Figure CN114626355B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of office automation, and in particular to a cell positioning method, device, storage medium and computer equipment. Background Art
[0002] Users can greatly improve office efficiency by using tables. Tables include multiple cells, which can be filled with different types of characters. In the prior art, the method of extracting characters from a table is: pre-configure the matching rules of the cells, and the computer device determines the location of the target cell in the table according to the matching rules. The matching rules are generally to search the target cell according to keywords, and then extract characters from the target cell. However, the writing style and character content of the table are the same, and it is difficult for users to configure a unified matching rule to locate the target cell. Summary of the invention
[0003] The embodiments of the present application provide a cell positioning method, device, storage medium and computer equipment, which can solve the problems of high complexity and inaccurate positioning caused by using matching rules to locate cells in the prior art. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a cell positioning method, the method comprising:
[0005] Obtain a table in a table file; wherein the table includes a plurality of cells;
[0006] Count the character type and number of characters in each cell;
[0007] Convert the statistical results of each cell into pixel values;
[0008] Generate an image file according to the converted pixel values;
[0009] The image file is detected according to a pre-trained target detection model to obtain cell location information.
[0010] In a second aspect, an embodiment of the present application provides a cell positioning device, the device comprising:
[0011] An acquisition unit, used for acquiring a table in a table file; wherein the table includes a plurality of cells;
[0012] Statistical unit, counts the character type and number of characters in each cell;
[0013] A conversion unit, used for converting the statistical results of each cell into a pixel value;
[0014] A generating unit, used for generating an image file according to the pixel values obtained by the conversion;
[0015] The detection unit is used to detect the image file according to a pre-trained target detection model to obtain cell location information.
[0016] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0017] In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0018] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0019] The character type and number of characters in each cell in the table are counted, and then the statistical results of each cell are converted into pixel values. An image file is generated using the converted pixel values, and then the image file is detected using a target detection model to obtain the cell location information. The present application converts the table into an image, and then uses a target detection model to detect the image to obtain the location information of the target cell. Compared with the method of configuring matching rules to locate cells in the prior art, this can reduce the complexity of manually configuring matching rules and improve the efficiency of positioning. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 It is a schematic diagram of the network architecture provided by the embodiment of the present application;
[0022] Figure 2 is a schematic diagram of the process of the cell positioning method provided in the embodiment of the present application;
[0023] Figure 3 It is a schematic diagram of converting a table provided in an embodiment of the present application into an image;
[0024] Figure 4 It is a structural schematic diagram of a cell positioning device provided by the present application;
[0025] Figure 5 It is a structural schematic diagram of a computer device provided by this application. DETAILED DESCRIPTION
[0026] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0027] It should be noted that the cell positioning method provided in the present application is generally executed by a computer device, and accordingly, the cell positioning device is generally arranged in the computer device.
[0028] Figure 1 An exemplary system architecture that can be applied to the cell locating method or cell locating device of the present application is shown.
[0029] like Figure 1 As shown, the system architecture may include: a computer device 101 and a server 102. The computer device 101 and the server 102 may communicate via a network, and the network is used as a medium for providing communication links between the above-mentioned units. The network may include various types of wired communication links or wireless communication links, for example: a wired communication link includes an optical fiber, a twisted pair or a coaxial cable, etc., and a wireless communication link includes a Bluetooth communication link, a wireless fidelity (WIreless-FIdelity, Wi-Fi) communication link or a microwave communication link, etc.
[0030] The server 102 stores a data set, and the server 102 obtains a target detection model according to the data set training, and then deploys the target detection model. The target detection model can be deployed on the computer device 101 or on the server 102, and this application does not limit it. The computer device 101 can obtain a table in a table file; wherein the table includes multiple cells; count the character type and the number of characters in each cell; convert the statistical results of each cell into pixel values; generate an image file according to the converted pixel values; and detect the image file according to calling the target detection model to obtain cell position information.
[0031] It should be noted that the computer device 101 and the server 102 can be hardware or software. When the computer device 101 and the server 102 are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the computer device 101 and the server 102 are software, they can be implemented as multiple software or software modules (for example, for providing distributed services), or as a single software or software module, which is not specifically limited here.
[0032] Various communication client applications can be installed on the computer device of the present application, such as: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0033] The computer device may be hardware or software. When the computer device is hardware, it may be various computer devices with a display screen, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers. When the computer device is software, it may be installed in the computer devices listed above. It may be implemented as multiple software or software modules (for example, to provide distributed services), or it may be implemented as a single software or software module, which is not specifically limited here.
[0034] When the computer device is hardware, a display device and a camera may be installed thereon. The display device may be any device capable of realizing a display function, and the camera is used to collect video streams; for example, the display device may be a cathode ray tube display (CR), a light-emitting diode display (LED), an electronic ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. The user may use the display device on the computer device to view displayed text, pictures, videos and other information.
[0035] It should be understood that Figure 1 The number of computer devices, networks and servers in the embodiment is only for illustration. Any number of computer devices, networks and servers may be used as required.
[0036] The following will be combined with the attached Figure 2 , the cell positioning method provided in the embodiment of the present application is described in detail. Among them, the cell positioning device in the embodiment of the present application can be Figure 1 Computer equipment shown.
[0037] See also Figure 2 , which is a schematic diagram of a cell positioning method provided in an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application may include the following steps:
[0038] S201, obtaining a table in a table file.
[0039] Among them, the table file can be used to edit and output the table, and the format of the table file can be Microsoft Excel format or Kingsoft WPS, etc. The table file includes a table, which is a two-dimensional table. After the computer device obtains the table file, it determines the position of the table in the table file. The position of the table can be represented by the starting row number, starting column number, ending row number and ending column number, or by the coordinates of the cells of the four vertices of the table. The two-dimensional table includes multiple cells. When the cells are filled with characters, the character type can be one or more, that is, a single type of character or a mixed type of character, for example: the character type is Chinese, English or number.
[0040] S202, counting the character type and character quantity of each cell.
[0041] The character type generally indicates the language type, and the character quantity indicates the number of characters belonging to the same character type. The computer device traverses all cells in the table to obtain the character type and character quantity of each cell. The traversal method can be row traversal, column traversal or other methods, which are not limited in this application.
[0042] For example: the characters filled in a cell are "My name is John, my English name is John, and I am 15 years old this year". The computer device counts that the number of Chinese characters in the cell is 12, the number of English characters is 4, and the number of numeric characters is 2.
[0043] S203: Convert the statistical result of each cell into a pixel value.
[0044] The computer device pre-stores or pre-configures a mapping relationship between statistical results and pixel values, and the computer device determines the pixel value corresponding to the statistical result obtained in S202 according to the mapping relationship. The pixel value of the present application can be a grayscale value, that is, the pixel value corresponds to a grayscale pixel; the pixel value can also be a color pixel value, that is, the pixel value includes a red value r, a green value g, and a blue value b. The statistical result of each cell in the table is associated with a pixel value, that is, each cell is associated with a pixel.
[0045] In a possible implementation, the character type is Chinese, English or numbers, the pixel value is composed of a red value r, a green value g and a blue value b, the color value of the present application is a red value, a green value or a blue value, the maximum value of each color value can be determined according to actual needs, the larger the maximum value of the color value, the richer the color of the image, for example: the maximum value of the red value, the green value and the blue value is 256. The computer device pre-stores or pre-configures a mapping relationship between the character type and the color type, and then determines the color type associated with the character type in S202 according to the mapping relationship, and then uses the number of characters of the character type in S202 as the color value of the color type.
[0046] For example, the statistical result of a certain unit is expressed as: the number of Chinese characters is 12, the number of English characters is 4, and the number of digital characters is 2. The mapping relationship between the character type and the color type configured by the computer device is expressed as: Chinese corresponds to red, English corresponds to green, and digital corresponds to blue, then the mapped pixel values are expressed as r=12, g=4, and b=5.
[0047] It should be noted that the mapping relationship between the character type and the color type is not limited to the above examples, and can be set according to actual needs during application.
[0048] Furthermore, when the number of characters exceeds the maximum value of the color value, the present application can use normalization to convert the number of characters into a value range of [0, 1], and then multiply the normalized value by the maximum value of the color value and round it to obtain the final color value. The normalization method of the present application includes but is not limited to: maximum-minimum normalization, Z-score normalization or log function, etc.
[0049] In another possible implementation method, the computer device converts the statistical result of each cell into a pixel value according to the following formula:
[0050] r=round(normalized(z)×A), g=round(normalized(e)×A), b=round(normalized(n)×A)
[0051] Among them, r represents the red value, g represents the green value, b represents the blue value, and A represents the maximum color value, for example: A = 255, which can fully represent the character content and avoid excessive calculation. z represents the number of Chinese characters filled in the cell, e represents the number of English characters filled in the cell, n represents the number of numeric characters filled in the cell, round() is the rounding function, and normalized() is the normalization function.
[0052] Furthermore, normalized(x)=2×(sigmoid(x)-0.5),
[0053] In the process of converting cells into pixels, there will inevitably be information loss. This application counts the number of characters in each cell in a large number of tables, draws a curve graph representing the relationship between the number of characters and the number of cells based on the statistical results, and then sets a normalization function with a similar shape based on the shape of the curve graph to improve the discrimination of information.
[0054] S204: Generate an image file according to the converted pixel values.
[0055] There is a one-to-one mapping relationship between the cells in the table and the pixels in the image file, and the size of the table is the same as the size of the image file. For example, if the table contains m rows and n columns of cells, then the generated image file contains m rows and n columns of pixels.
[0056] For example: See Figure 4 As shown, the size of the table is 11 columns and 32 rows. According to the method of S202, the table is converted into an image file with 11 columns and 32 rows.
[0057] S205 , detecting the image file according to a pre-trained target detection model to obtain cell location information.
[0058] Among them, the computer device obtains a feature vector after performing operations such as feature extraction and vector conversion on the image file, and inputs the feature vector into the target detection model to obtain cell position information, which is the pixel coordinates in the image. Since pixels and cells are in a one-to-one correspondence, the target cell can be located in the table according to the cell position information, and then the characters are extracted from the target cell to obtain structured text. The target detection model of the present application can be a deep learning model or a machine learning model, for example: the target detection model is a yolov5 model. Furthermore, in order to improve the efficiency of detection, the present application can convert the image file into an image file of a specified size, for example: the specified size is 640×640.
[0059] Among them, the target detection model of the present application is obtained by pre-training, and the target detection model is obtained by training using a data set, and the data set includes multiple sample images obtained by table conversion, and the sample images are associated with annotation files, and the annotation files store pixel coordinates, and the cells corresponding to the pixel coordinates are target cells. Furthermore, the data set includes a training set and a verification set, and the ratio of the training set to the verification set can be determined according to actual needs. For example, the ratio of the training set to the verification set is 70% and 30%, so as to avoid wasting more training time. The training set is used to train to obtain the initial target detection model, and the verification set is used to verify the accuracy of the initial target detection model. When the accuracy does not meet the requirements, the model is corrected to obtain a target detection model that meets the accuracy requirements.
[0060] When locating cells in a table, the embodiments of the present application count the character type and number of characters in each cell in the table, then convert the statistical results of each cell into pixel values, generate an image file using the converted pixel values, and then use the target detection model to detect the image file to obtain the cell location information. The present application converts the table into an image, and then uses the target detection model to detect the image to obtain the location information of the target cell. Compared with the method of configuring matching rules to locate cells in the prior art, this can reduce the complexity of manually configuring matching rules and improve the efficiency of positioning.
[0061] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0062] See also Figure 4 , which shows a schematic diagram of the structure of a cell positioning device provided by an exemplary embodiment of the present application, hereinafter referred to as device 4. The device 4 can be implemented as all or part of a computer device through software, hardware or a combination of both. The device 4 includes: an acquisition unit 401, a statistical unit 402, a conversion unit 403, a generation unit 404, and a detection unit 405.
[0063] The acquisition unit 401 is used to acquire a table in a table file; wherein the table includes a plurality of cells;
[0064] A counting unit 402 is used to count the character type and the number of characters in each cell;
[0065] A conversion unit 403, used to convert the statistical result of each cell into a pixel value;
[0066] A generating unit 404, configured to generate an image file according to the converted pixel values;
[0067] The detection unit 405 is used to detect the image file according to a pre-trained target detection model to obtain cell location information.
[0068] In one or more possible embodiments, converting the statistical results of each cell into a pixel value includes:
[0069] The statistical results of each cell are converted into pixel values according to the following formula:
[0070] r=round(normalized(z)×A), g=round(normalized(e)×A), b=round(normalized(n)×A)
[0071] Among them, r represents the red value, g represents the green value, b represents the blue value, A represents the maximum color value, z represents the number of Chinese characters filled in the cell, e represents the number of English characters filled in the cell, n represents the number of numeric characters filled in the cell, round() is the rounding function, and normalized() is the normalization function.
[0072] In one or more possible embodiments, the normalized function is expressed as: normalized(x)=2×(sigmoid(x)-0.5),
[0073] In one or more possible embodiments, it further includes:
[0074] A training unit, used to obtain a data set; wherein the training set includes a plurality of labeled sample images;
[0075] The target detection model is obtained by training according to the data set.
[0076] In one or more possible embodiments, the target detection model is a yolov5 model.
[0077] In one or more possible embodiments, the data set is divided into a 70% training set and a 30% validation set.
[0078] In one or more possible embodiments, it further includes:
[0079] an extraction unit, configured to determine a position of a target cell in the table according to the cell position information;
[0080] Extract the characters in the target cell.
[0081] It should be noted that, when the device 4 provided in the above embodiment executes the cell positioning method, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above functions. In addition, the cell positioning device provided in the above embodiment and the cell positioning method embodiment belong to the same concept, and the embodiment and implementation process thereof are detailed in the method embodiment, which will not be repeated here.
[0082] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0083] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 2The method steps of the embodiment shown in the figure can be found in the specific implementation process. Figure 2 The specific description of the illustrated embodiment will not be repeated here.
[0084] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the cell positioning method described in the above embodiments.
[0085] See also Figure 5 , which is a schematic diagram of the structure of a computer device according to an embodiment of the present application. Figure 5 As shown, the computer device 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , and at least one communication bus 502 .
[0086] The communication bus 502 is used to realize the connection and communication between these components.
[0087] The user interface 503 may include a display screen (Display) and a camera (Camera), and the optional user interface 503 may also include a standard wired interface and a wireless interface.
[0088] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0089] Among them, the processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts within the entire computer device 500, and executes various functions and processes data of the computer device 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 505, and calling data stored in the memory 505. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and it can be implemented separately through a chip.
[0090] Among them, the memory 505 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 505 may also be optionally at least one storage device located away from the aforementioned processor 501. As Figure 5 As shown, the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program.
[0091] exist Figure 5In the computer device 500 shown in FIG. 1 , the user interface 503 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 501 can be used to call the application program stored in the memory 505 and specifically execute the following steps: Figure 2 The specific process can be referred to Figure 2 As shown, no further description is given here.
[0092] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0093] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A cell positioning method, characterized in that: include: Obtain a table in a table file; wherein the table includes a plurality of cells; Count the character type and number of characters in each cell; Convert the statistical results of each cell into pixel values; Generate an image file according to the converted pixel values; the cells in the table and the pixel values in the image file are in a one-to-one mapping relationship; The image file is detected according to a pre-trained target detection model to obtain cell location information.
2. The method according to claim 1, characterized in that: The step of converting the statistical results of each cell into a pixel value includes: The statistical results of each cell are converted into pixel values according to the following formula: r=round(normalized(z)×A), g=round(normalized(e)×A), b=round(normalized(n)×A) where r represents the red value, g represents the green value, b represents the blue value, A represents the maximum color value, z represents the number of Chinese characters filled in the cell, e represents the number of English characters filled in the cell, n represents the number of numeric characters filled in the cell, round() is the rounding function, and normalized() is the normalization function.
3. The method according to claim 2, characterized in that The normalized function is expressed as: normalized(x)=2×(sigmoid(x)-0.5), 4. The method according to claim 1, 2 or 3, characterized in that: Before obtaining the table in the table file, the method further includes: Obtain a data set; wherein the training set includes a plurality of labeled sample images; The target detection model is obtained by training according to the data set.
5. The method according to claim 4, characterized in that The target detection model is the yolov5 model.
6. The method according to claim 4, characterized in that The dataset is divided into 70% training set and 30% validation set.
7. The method according to claim 5 or 6, characterized in that: Also includes: Determine the position of the target cell in the table according to the cell position information; Extract the characters in the target cell.
8. A cell positioning device, characterized in that: include: An acquisition unit, used for acquiring a table in a table file; wherein the table includes a plurality of cells; Statistical unit, counts the character type and number of characters in each cell; A conversion unit, used for converting the statistical results of each cell into a pixel value; A generating unit, used for generating an image file according to the pixel values obtained by the conversion; the cells in the table and the pixel values in the image file are in a one-to-one mapping relationship; The detection unit is used to detect the image file according to a pre-trained target detection model to obtain cell location information.
9. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.
10. A computer device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Data encryption method and device, data decryption method and device, electronic equipment and storage medium
CN111368310A
OCR (Optical Character Recognition) method for contract with table
CN111709349A
Data analysis method and device, computer equipment and storage medium
CN117390098A