Image processing method, image processing device and electronic equipment
By introducing the global variable of the cropping position into the scanning pen, the image to be recognized is cropped and the cropping position is updated, which solves the problem of increased time and power consumption during the scanning and recognition process, and achieves a more efficient text recognition operation.
Patent Information
- Application Number
- CN202210366570.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-04-08
AI Technical Summary
During the scanning and recognition process of the scanner pen, image splicing leads to an increase in recognition time and power consumption, which is difficult to effectively reduce with existing technology.
Introducing the global variable of cropping position, the text recognition module crops the image to be recognized from the spliced image in each round of scanning and recognition, and updates the cropping position based on the recognition results to avoid repeated recognition of the recognized area.
By reducing the data processing volume of text recognition and avoiding repeated recognition, the recognition time and power consumption are reduced, and the efficiency and battery life of the scanner pen are improved.
Smart Images

Figure CN114694153B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of scanning pen technology, and in particular relates to an image processing method, an image processing device, an electronic device and a computer-readable storage medium. Background Art
[0002] The appearance of the scanning pen is similar to a pen. It is a handheld device that allows users to scan and input text by holding the scanning pen. For the scanned and input text, the scanning pen can realize multiple functions such as display, word meaning interpretation, translation and voice broadcast.
[0003] During a round of scanning and recognition, the scanning pen usually performs a cyclic puzzle and continuously recognizes the entire spliced image. As the scanning and recognition proceed, the image will become longer and longer, which results in longer and longer recognition time and higher power consumption. Summary of the invention
[0004] The present application provides an image processing method, an image processing device, an electronic device and a computer-readable storage medium, which can reduce the time and power consumption of text recognition.
[0005] In a first aspect, the present application provides an image processing method, which is applied to an electronic device, wherein a text recognition module is provided in the electronic device, and the image processing method comprises:
[0006] During this round of scanning and recognition, the text recognition module receives the spliced image transmitted asynchronously;
[0007] The text recognition module crops the image to be recognized from the spliced image based on the cropping position saved during the current round of scanning and recognition;
[0008] The text recognition module determines the segmentation position of the image to be recognized by performing text recognition operation on the image to be recognized;
[0009] The text recognition module updates the cropping position according to the segmentation position.
[0010] In a second aspect, the present application provides an image processing device, the image processing device comprising a text recognition module, the text recognition module comprising:
[0011] A receiving unit, used for receiving the currently stitched image transmitted asynchronously during the current round of scanning and recognition;
[0012] A cropping unit, used for cropping the image to be recognized from the spliced images based on the cropping position saved during the current round of scanning and recognition;
[0013] A determination unit, used to determine the segmentation position of the image to be identified by performing a text recognition operation on the image to be identified;
[0014] The updating unit is used to update the cropping position according to the segmentation position.
[0015] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method of the first aspect when executing the computer program.
[0016] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect are implemented.
[0017] In a fifth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by one or more processors, it implements the steps of the method of the first aspect.
[0018] Compared with the prior art, the present application has the following beneficial effects: in each round of scanning and recognition, a global variable is introduced: the cropping position. After receiving the spliced image each time, the text recognition module of the electronic device will first crop the image to be recognized from the spliced image based on the cropping position saved in the current round of scanning and recognition. The subsequent text recognition module only performs text recognition operation on the image to be recognized, and after the text recognition operation is completed, the segmentation position of the image to be recognized is determined, and the cropping position is updated based on this. The above process achieves the reduction of time and power consumption of text recognition through the following two aspects: on the one hand, the image to be recognized is only the image corresponding to a part of the spliced image in most cases, that is, the object of the text recognition operation is no longer the whole spliced image, but a part of the spliced image, which reduces the data processing amount of the text recognition operation; on the other hand, after each text recognition operation is completed, the text recognition module will also update the cropping position, which avoids repeated recognition of the recognized area.
[0019] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 any creative work.
[0021] Figure 1 Schematic diagram of the workflow of the text recognition module in the image processing method provided in the embodiment of the present application;
[0022] Figure 2 This is an example diagram provided by an embodiment of the present application in which the cropping position is not updated;
[0023] Figure 3 This is an example diagram of an application scenario of the image processing method provided in an embodiment of the present application;
[0024] Figure 4 is a schematic diagram of the workflow of the image stitching module in the image processing method provided in the embodiment of the present application;
[0025] Figure 5 is a structural block diagram of an image processing device provided in an embodiment of the present application;
[0026] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0028] In order to illustrate the technical solution proposed in this application, a specific embodiment is provided below for illustration.
[0029] The image processing method proposed in the embodiment of the present application is described below. The image processing method is applied to an electronic device, and a text recognition module is provided in the electronic device. As an example only, the electronic device can be a scanning pen, or a server or other device that has established a communication connection with the scanning pen, and the specific type of the electronic device is not limited here.
[0030] See also Figure 1 ,The workflow of the text recognition module is detailed as follows:
[0031] Step 101 : During this round of scanning and recognition, the text recognition module receives the currently stitched image transmitted asynchronously.
[0032] From the time the user puts down the scanning pen to the time the user lifts up the scanning pen, it corresponds to a round of scanning and recognition process. Generally speaking, the scanning pen may be provided with an image stitching module, which can stitch the collected images during this round (i.e., the current round) of scanning and recognition, and asynchronously transmit the stitched images obtained by the stitching operation to the text recognition module. As a result, the text recognition module can receive the stitched images asynchronously transmitted by the image stitching module at least once during each round of scanning and recognition.
[0033] It can be understood that when the electronic device is a scanning pen, the image stitching module and the text recognition module are both built into the scanning pen; in this case, the transmission of the stitched image belongs to the data transmission inside the scanning pen. When the electronic device is a server (or other device), the image stitching module is built into the scanning pen, and the text recognition module is built into the server (or other device); in this case, the transmission of the stitched image belongs to the data transmission between the scanning pen and the server (or other device).
[0034] Step 102 : The text recognition module crops the image to be recognized from the spliced image based on the cropping position saved during the current round of scanning and recognition.
[0035] Considering that in real life, characters in text are usually arranged horizontally from left to right, when users use a scanning pen to scan, they usually scan the text horizontally from left to right, which makes the right side of the spliced image usually the newly spliced part, and the left side usually the recognized part. Based on this, a new global variable is introduced in the embodiment of the present application: the cropping position. The text recognition module can start from the cropping position saved in the current round of scanning and recognition process in the spliced image, and crop an image with a width of d to the right as the image to be recognized.
[0036] As an example only, d can be taken as follows:
[0037] If the distance from the cropping position to the right edge of the stitched image is greater than a preset upper limit of the distance (e.g., 80 pixels), d is taken as the upper limit of the distance. That is, in this case, the image to be identified is the image corresponding to the partial area to the right of the cropping position.
[0038] If the distance from the cropping position to the right edge of the stitched image is less than or equal to the upper limit of the distance, d is taken as the distance from the cropping position to the right edge. That is, in this case, the image to be identified is the image corresponding to the entire area to the right of the cropping position.
[0039] Specifically, because the image stitching module is continuously stitching on the right side of the image when performing image stitching; that is, in the same round of scanning and recognition process, the width of the stitched image received later is usually larger than that of the stitched image received earlier. For this reason, the main purpose of cropping is to divide the stitched image into a left image (an image that has been recognized) and a right image (a newly stitched image, that is, an image to be recognized). Based on this, the cropping position in the embodiment of the present application specifically refers to: the horizontal coordinate corresponding to the position to be cropped in the stitched image, that is, the cropping horizontal coordinate. For the convenience of subsequent description, the cropping position (that is, the cropping horizontal coordinate) can be recorded as cursor.
[0040] It should be noted that before each round of scanning and recognition process begins, the text recognition module may reset the cropping position to a default value of 0. That is, the cropping horizontal coordinate is reset to a default value of 0.
[0041] Step 103: The text recognition module determines the segmentation position of the image to be recognized by performing text recognition operation on the image to be recognized.
[0042] The text recognition module no longer performs text recognition on the entire spliced image, but only on the image to be recognized. Considering the uncertainty of image splicing time, the edge of the image to be recognized may truncate the characters. To solve this problem, the text recognition module can segment the image to be recognized in combination with the CTC result (an intermediate output of the text recognition result) when performing text recognition on the image to be recognized, thereby obtaining the segmentation position of the image to be recognized.
[0043] It can be understood that the text recognition module can correct the original text recognition results based on the segmentation results to avoid including truncated characters in the recognition range. After the text recognition operation is completed, the text recognition module can output and display the obtained accurate text recognition results. In some examples, if the electronic device is a scanning pen, the text recognition module can output the accurate text recognition results to its own screen for display; or, the accurate text recognition results can also be output to the screen of the user terminal connected to itself for display. In other examples, if the electronic device is a server, the text recognition module can output the accurate text recognition results to the screen of the scanning pen for display; or, the accurate text recognition results can also be output to the screen of the user terminal connected to the scanning pen for display. The embodiments of the present application do not limit the specific process of the output display.
[0044] It can be understood that the image to be identified is actually also a part of the spliced image. In order to facilitate the processor to perform operations, the text recognition module still uses the spliced image (rather than the image to be identified) as a reference to describe the segmentation position. That is, the segmentation position specifically refers to: the horizontal coordinate corresponding to the position where the segmentation occurs in the spliced image, that is, the segmentation horizontal coordinate. In fact, for the position where the segmentation occurs, its horizontal coordinate in the image to be identified and its horizontal coordinate in the spliced image can be converted to each other through calculation.
[0045] For ease of understanding, the horizontal coordinate of the position where the segmentation occurs in the image to be identified can be marked as c'[t], and the horizontal coordinate of the position in the spliced image can be marked as c[t], and the following coordinate conversion formula is obtained: c[t] = c'[t] + cursor. The segmentation position (segmentation horizontal coordinate) of the image to be identified in the embodiment of the present application is specifically c[t].
[0046] Step 104: the text recognition module updates the cropping position according to the segmentation position.
[0047] After the recognition is completed, the text recognition module can update the cropping position according to the segmentation position, specifically: the segmentation position is used as the new cropping position. That is, the value of the segmentation horizontal coordinate c[t] is assigned to the cropping horizontal coordinate, cursor = c[t]. Through this operation, it is ensured that the cropping position can be continuously updated iteratively following the scanning and recognition process, so that the text recognition module will not repeat the recognition of the previously recognized part when it receives a new spliced image next time.
[0048] In some embodiments, in order to further improve the efficiency of the text recognition module in performing text recognition operations and avoid cropping and text recognition operations when the newly spliced portion of the spliced image is too small, before step 102, the image processing method may further include:
[0049] The text recognition module determines whether the spliced image meets the preset cropping conditions;
[0050] Accordingly, step 102 may specifically be:
[0051] When the stitched image meets the cropping condition, the text recognition module crops the image to be recognized from the stitched image based on the cropping position saved during the current round of scanning and recognition.
[0052] That is, to ensure the efficiency of subsequent text recognition operations, the text recognition module can perform a series of subsequent operations such as cropping and text recognition only when the stitched image meets the cropping conditions. If the stitched image does not meet the cropping conditions, the text recognition module can directly discard (i.e., ignore) the stitched image.
[0053] As an example only, the clipping condition may include the following two conditions:
[0054] The first condition is that a position difference between a boundary position of a specified boundary of the stitched image and a cropping position is greater than a preset first position difference threshold.
[0055] As described above, when performing the stitching operation, the new part is spliced in from the right side of the image, so the specified boundary mentioned here actually refers to the right boundary. Similar to the definition of the cropping position, the boundary position of the specified boundary specifically refers to: the horizontal coordinate (i.e., the boundary horizontal coordinate) corresponding to the specified boundary (right boundary) in the stitched image. It can be understood that the boundary position (i.e., the boundary horizontal coordinate) actually also expresses the width of the stitched image.
[0056] For the convenience of subsequent description, the boundary position (ie, the boundary horizontal coordinate) may be recorded as w[t]. Then the first condition may be expressed as: w[t]-cursor>D1, wherein D1 is a preset first position difference threshold.
[0057] The second condition is that the time difference between the reception time of the stitched image and the end time of the most recent text recognition operation (ie, the previous text recognition operation) in the current round of scanning and recognition is greater than a preset first time difference threshold.
[0058] Since users usually do not slide too quickly when scanning and identifying with the scanning pen, the stitched image obtained in a short period of time usually does not change too much, that is, the stitched image usually does not add too much new content in a short period of time. Based on this, it is possible to determine whether subsequent operations such as cropping and recognition are needed from a time perspective: if a long time has passed since the previous text recognition operation before the stitched image is received, it is considered that the user may have scanned a large number of new areas with the scanning pen, and it is considered necessary to perform subsequent operations such as cropping and recognition.
[0059] For the convenience of subsequent explanation, the reception time of the stitched image can be recorded as T receive , the end time of the most recent text recognition operation in this round of scanning and recognition is recorded as T OCR . Then the second condition can be expressed as: T receive -T OCR >T1, where T1 is a preset first time difference threshold. Obviously, since the second condition involves the most recent text recognition operation, when there is no most recent text recognition operation (for example, this is the first time to receive the spliced image), the text recognition module cannot make a determination based on the second condition.
[0060] It can be understood that as long as the stitched image can satisfy any of the above two conditions (including the case where only one condition is satisfied or the case where both conditions are satisfied), the stitched image can be considered to satisfy the cropping condition.
[0061] In some embodiments, if the user holds the scanning pen and scans slowly, the text recognition module is likely to trigger the cropping and recognition operations because the cropping conditions are met in time. However, in some extreme cases, such as when the scanning movement speed is too slow, the width of the newly added content in the stitched image this time may be very small compared to the previously stitched image, and it is even possible that the width of the newly added content cannot accommodate a character. In this extreme case, when performing text recognition on the image to be recognized containing the newly added content, even if a segmentation method is adopted, it may still be impossible to avoid recognition errors. In order to reduce the occurrence of recognition errors in this extreme case, step 104 may include:
[0062] The text recognition module determines whether the position difference between the segmentation position and the cropping position is greater than a preset second position difference threshold; only when the position difference between the segmentation position and the cropping position is greater than the second position difference threshold, the text recognition module updates the cropping position to the segmentation position.
[0063] That is, the electronic device can determine whether c[t]-cursor>D2 is established, wherein D2 is a preset second position difference threshold value, which can be determined based on the minimum width of a single character. If c[t]-cursor>D2 is established, the result of this text recognition is considered to be relatively credible, that is, the text recognition operation is valid, and only then will the value c[t] of the current segmentation horizontal coordinate be assigned to the cropping horizontal coordinate, and the text recognition result can be output and displayed. On the contrary, if c[t]-cursor>D2 is not established, the result of this text recognition is considered to be relatively unreliable, that is, the text recognition operation is invalid, and the cropping horizontal coordinate is not updated, and the text recognition result is not output and displayed. In this way, it can be ensured that the image to be recognized that was not recognized this time can be within the range of the next recognition.
[0064] As an example only, see Figure 2 , Figure 2 An example of not updating the clipping position is given. Figure 2 For the stitched image shown, the position difference between the cropping position and the segmentation position is very small, and at this time, the text recognition module does not update the cropping position. That is, the next time the stitched image is received, it still starts from the unupdated cropping position and crops the image to be recognized to the right.
[0065] To understand the above process, please refer to Figure 3 , Figure 3 A specific scenario example is given:
[0066] The text recognition module receives the first stitched image I1 in this round of scanning and recognition at time T1. At this time, the cropping position cursor is the default value 0. Based on the cursor, it is determined that the stitched image I1 itself is the first image to be recognized. After performing text recognition on the image to be recognized, the segmentation position c[1] is determined. The text recognition module can then update the cropping position cursor to the segmentation position c[1].
[0067] The text recognition module receives the second stitched image I2 in this round of scanning and recognition at time T2. Based on the current cropping position cursor (equivalent to the segmentation position c[1]), the image to the right of the cropping position cursor is determined to be the second image to be recognized. After performing text recognition on the image to be recognized, the segmentation position c[2] is determined. The text recognition module can then update the cropping position cursor to the segmentation position c[2].
[0068] The text recognition module receives the third stitched image I3 in this round of scanning and recognition at time T3. Based on the current cropping position cursor (equivalent to the segmentation position c[2]), the image to the right of the cropping position cursor is determined to be the image to be recognized. After performing text recognition on the image to be recognized, the segmentation position c[3] is determined. The text recognition module can then update the cropping position cursor to the segmentation position c[3].
[0069] And so on, until this round of scanning and recognition is completed.
[0070] As can be seen from the above, in the embodiment of the present application, the text recognition module of the electronic device introduces a global variable for each round of scanning and recognition: the cropping position. After receiving the spliced image each time, the text recognition module will first crop the image to be recognized from the spliced image based on the cropping position saved during the current round of scanning and recognition. The subsequent text recognition module only performs text recognition operation on the image to be recognized, and after the text recognition operation is completed, it determines the segmentation position of the image to be recognized, and updates the cropping position based on this. The above process achieves the reduction of time and power consumption of text recognition through the following two aspects: on the one hand, the image to be recognized is only the image corresponding to a part of the area in the spliced image in most cases, that is, the object of the text recognition operation is no longer the whole spliced image, but a part of the area in the spliced image, which reduces the data processing amount of the text recognition operation; on the other hand, after each text recognition operation is completed, the text recognition module will also update the cropping position, which avoids repeated recognition of the recognized area.
[0071] In some embodiments, in order to further improve the working efficiency of the text recognition module, the image stitching module can also be optimized so that the image stitching module no longer continuously transmits the stitched image to the text recognition module as in the past. Figure 4 ,The workflow of the image stitching module is described as follows:
[0072] Step 401 , during this round of scanning and recognition, the image stitching module stitches the images collected in real time to obtain a real-time stitched image.
[0073] Step 402: The image stitching module determines whether the real-time stitching image meets a preset transmission condition.
[0074] The image stitching module no longer transmits images to the text recognition module in real time and continuously, but sets a transmission condition, and transmits the image to the text recognition module only when the real-time stitching image meets the transmission condition.
[0075] Similar to the clipping condition mentioned above, the transmission condition may include the following two conditions:
[0076] The first condition: The difference between the width of the real-time stitched image and the specified width is greater than the preset width difference threshold
[0077] As described above, the width of the image can be represented by the horizontal coordinate of the right edge of the image. Specifically, the specified width refers to the width of the stitched image that was previously transmitted during this round of scanning and recognition. For the convenience of subsequent explanation, the specified width can be denoted as w, and the width of the real-time stitched image can be denoted as w[t]. Then the first condition can be expressed as: w[t]-w>D3, where D3 is the preset width difference threshold.
[0078] It should be noted that before each round of scanning and recognition process begins, the image stitching module may reset the specified width to a default value of 0.
[0079] The second condition is that the time difference between the stitching time of the real-time stitched image and the transmission time of the most recent stitched image (ie, the previously transmitted stitched image) during the current round of scanning and recognition is greater than a preset second time difference threshold.
[0080] For the convenience of subsequent explanation, the stitching time of the real-time stitching image can be recorded as T stitching , the transmission time of the most recent stitched image in this round of scanning and recognition is recorded as T transmit . Then the second condition can be expressed as: T stitching -T transmit>T2, where T2 is a preset second time difference threshold. Obviously, since the second condition is related to the most recent stitched image, when there is no most recent stitched image (for example, during this round of scanning and recognition, no stitched image has been transmitted before), the image stitching module cannot make a judgment based on the second condition.
[0081] It can be understood that as long as the real-time stitched image can meet any of the above two conditions (including the case where only one of the conditions is met or the case where both conditions are met), the real-time stitched image can be considered to meet the transmission condition.
[0082] Step 403: When the real-time stitched image meets the transmission condition, the image stitching module transmits the real-time stitched image as the stitched image of this time to the text recognition module.
[0083] After the current round of scanning and recognition begins, the image stitching module may transmit the stitched image to the text recognition module at any time; correspondingly, the text recognition module cannot predict when it will receive the stitched image transmitted by the image stitching module. That is, the transmission is asynchronous transmission.
[0084] It should be noted that during a round of scanning and recognition, the image stitching module can update the specified width to the width of the stitched image each time after transmitting the stitched image to the text recognition module; that is, the value of the width of the stitched image is assigned to the specified width.
[0085] It can be understood that the coordinates mentioned in the embodiments of the present application are all coordinates in the image coordinate system of the corresponding image. The image coordinate system takes the upper left vertex of the corresponding image as the origin, horizontally to the right as the positive direction of the horizontal coordinate, and vertically downward as the positive direction of the vertical coordinate. The concept of the image coordinate system will not be repeated here.
[0086] As can be seen from the above, in the embodiment of the present application, the image stitching module and the text recognition module are designed as two independent modules that do not interfere with each other. The modular design makes the architecture of the electronic device clearer and more flexible, and easy to maintain and improve. Specifically, the image stitching module can send the stitched image according to certain rules, so that the text recognition module does not have to wait because the unrecognized area in the stitched image is too small, nor does it have to be too late to recognize because the unrecognized area is too large; the text recognition module can also crop the image to be recognized according to certain rules, and through precise tail segmentation, it can ensure that the text recognition is performed at the most appropriate image size, thereby ensuring the speed of text recognition, reducing the time and power consumption of text recognition, and improving the battery life of the electronic device.
[0087] Corresponding to the image processing method provided above, the embodiment of the present application also provides an image processing device. Figure 5 As shown, the image processing device 5 includes a text recognition module 50, and the text recognition module 50 includes:
[0088] The receiving unit 501 is used to receive the current spliced image transmitted asynchronously during the current round of scanning and recognition;
[0089] A cropping unit 502, used for cropping the image to be recognized from the spliced images based on the cropping position saved during the current round of scanning and recognition;
[0090] A determination unit 503, configured to determine a segmentation position of the image to be identified by performing a text recognition operation on the image to be identified;
[0091] The updating unit 504 is used to update the cropping position according to the segmentation position.
[0092] Optionally, the text recognition module 50 further includes:
[0093] A cropping judgment unit, used to judge whether the spliced image meets the preset cropping conditions;
[0094] Correspondingly, the cropping unit 502 is specifically configured to crop the image to be recognized from the spliced image based on the cropping position saved during the current round of scanning and recognition when the spliced image meets the cropping condition.
[0095] Optionally, the clipping conditions include:
[0096] The position difference between the boundary position of the specified boundary of the stitched image and the cropping position is greater than a preset first position difference threshold; or,
[0097] The time difference between the receiving time of the stitched image and the ending time of the most recent text recognition operation in the current round of scanning and recognition is greater than a preset first time difference threshold.
[0098] Optionally, the updating unit 504 includes:
[0099] A first judgment subunit is used for the text recognition module to judge whether the position difference between the segmentation position and the cropping position is greater than a preset second position difference threshold;
[0100] The position updating subunit is used for, when the position difference between the segmentation position and the cropping position is greater than a second position difference threshold, for the text recognition module to update the cropping position to the segmentation position.
[0101] Optionally, the image processing device 5 further includes an image stitching module, and the image stitching module includes:
[0102] A stitching unit is used to stitch the real-time collected images during the current round of scanning and recognition to obtain a real-time stitched image;
[0103] A transmission judgment unit, used to judge whether the real-time stitched image meets the preset transmission conditions;
[0104] The transmission unit is used to transmit the real-time stitched image as the stitched image of this time to the text recognition module 50 when the real-time stitched image meets the transmission condition.
[0105] Optionally, the transmission conditions include:
[0106] The difference between the width of the real-time stitched image and the specified width is greater than a preset width difference threshold; or,
[0107] The time difference between the stitching time of the real-time stitched image and the transmission time of the most recent stitched image in the current round of scanning and recognition is greater than a preset second time difference threshold.
[0108] Optionally, the image stitching module further includes:
[0109] The width updating unit is used to update the specified width to the width of the current stitched image after the real-time stitched image is transmitted as the current stitched image to the text recognition module.
[0110] As can be seen from the above, in the embodiment of the present application, the image stitching module and the text recognition module are designed as two independent modules that do not interfere with each other. The modular design makes the architecture of the electronic device clearer and more flexible, and easy to maintain and improve. Specifically, the image stitching module can send the stitched image according to certain rules, so that the text recognition module does not have to wait because the unrecognized area in the stitched image is too small, nor does it have to be too late to recognize because the unrecognized area is too large; the text recognition module can also crop the image to be recognized according to certain rules, and through precise tail segmentation, it can ensure that the text recognition is performed at the most appropriate image size, thereby ensuring the speed of text recognition, reducing the time and power consumption of text recognition, and improving the battery life of the electronic device.
[0111] Corresponding to the image processing method provided above, the present application embodiment also provides an electronic device. Figure 6 The electronic device 6 in the embodiment of the present application includes: a memory 601, one or more processors 602 ( Figure 6Only one is shown) and a computer program stored in the memory 601 and executable on the processor. Among them: the memory 601 is used to store software programs and units, and the processor 602 executes various functional applications and data processing by running the software programs and modules stored in the memory 601 to obtain the resources corresponding to the above-mentioned preset events. Specifically, the processor 602 implements the steps in each method embodiment of the image processing method by running the above-mentioned computer program stored in the memory 601, which will not be repeated here.
[0112] It should be understood that in the embodiment of the present application, the processor 602 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0113] The memory 601 may include a read-only memory and a random access memory, and provide instructions and data to the processor 602. A part or all of the memory 601 may also include a non-volatile random access memory. For example, the memory 601 may also store information of a device category.
[0114] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0115] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0116] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of external device software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0117] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0118] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0119] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the associated hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The above-mentioned computer-readable storage medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer-readable memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the above-mentioned computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media does not include electrical carrier signals and telecommunication signals.
[0120] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An image processing method, characterized in that: The image processing method is applied to an electronic device, wherein a text recognition module is provided in the electronic device, and the image processing method comprises: During this round of scanning and recognition, the text recognition module receives the asynchronously transmitted spliced image. The text recognition module crops the image to be recognized from the stitched image based on the cropping position saved in the process of the current round of scanning and recognition, wherein the image to be recognized is a portion of the stitched image that has not been recognized starting from the cropping position; The text recognition module determines the segmentation position of the image to be recognized by performing a text recognition operation on the image to be recognized; The text recognition module updates the cropping position according to the segmentation position; In the case where the electronic device is a scanning pen, the electronic device is further provided with an image stitching module; the image processing method further comprises: During the current round of scanning and recognition, the image stitching module stitches the images collected in real time to obtain a real-time stitched image; The image stitching module determines whether the real-time stitched image meets a preset transmission condition, wherein the transmission condition includes: a width difference between the width of the real-time stitched image and a specified width is greater than a preset width difference threshold; or a time difference between a stitching time of the real-time stitched image and a transmission time of the most recent stitched image in the current round of scanning and recognition is greater than a preset second time difference threshold; When the real-time stitched image meets the transmission condition, the image stitching module transmits the real-time stitched image as the stitched image of this time to the text recognition module; The image stitching module updates the specified width to the width of the stitched image this time.
2. The image processing method according to claim 1, characterized in that: Before the text recognition module crops the image to be recognized from the spliced image based on the cropping position saved in the current round of scanning and recognition, the image processing method further includes: The text recognition module determines whether the spliced image meets a preset cropping condition; Accordingly, the text recognition module crops the image to be recognized from the spliced image based on the cropping position saved in the current round of scanning and recognition, including: When the stitched image meets the cropping condition, the text recognition module crops the image to be recognized from the stitched image based on the cropping position saved during the current round of scanning and recognition.
3. The image processing method according to claim 2, characterized in that: The cutting conditions include: The position difference between the boundary position of the designated boundary of the stitched image and the cropping position is greater than a preset first position difference threshold; or, The time difference between the receiving time of the stitched image and the ending time of the most recent text recognition operation in the current round of scanning and recognition is greater than a preset first time difference threshold.
4. The image processing method according to claim 1, wherein: The text recognition module updates the cropping position according to the segmentation position, including: The text recognition module determines whether the position difference between the segmentation position and the cropping position is greater than a preset second position difference threshold; In a case where the position difference between the segmentation position and the cropping position is greater than the second position difference threshold, the text recognition module updates the cropping position to the segmentation position.
5. An image processing device, characterized in that: The image processing device is applied to an electronic device, and the image processing device includes a text recognition module, and the text recognition module includes: A receiving unit, used for receiving the currently stitched image transmitted asynchronously during the current round of scanning and recognition; A cropping unit, configured to crop the image to be recognized from the stitched image based on the cropping position saved in the process of the current round of scanning and recognition, wherein the image to be recognized is a portion of the stitched image that has not been recognized starting from the cropping position; A determination unit, configured to determine a segmentation position of the image to be identified by performing a text recognition operation on the image to be identified; An updating unit, configured to update the cropping position according to the segmentation position; In the case where the electronic device is a scanning pen, the image processing device further includes an image stitching module; the image stitching module includes: A stitching unit, used for stitching the images collected in real time to obtain a real-time stitched image during the current round of scanning and recognition; A transmission judgment unit, used to judge whether the real-time stitched image meets a preset transmission condition, wherein the transmission condition includes: a width difference between the width of the real-time stitched image and a specified width is greater than a preset width difference threshold; or a time difference between a stitching time of the real-time stitched image and a transmission time of the most recent stitched image in the current round of scanning and recognition is greater than a preset second time difference threshold; A transmission unit, configured to, when the real-time stitched image meets the transmission condition, transmit the real-time stitched image as the stitched image of this time to the text recognition module by the image stitching module; The width updating unit is used to update the specified width to the width of the stitched image this time after the real-time stitched image is transmitted to the text recognition module as the stitched image this time.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Frame-skipping scanning and recognizing device and method
CN102222222A
Optical character recognition method and device, electronic equipment and storage medium
CN113343997A
