Image processing method and device, electronic equipment, scanning pen and storage medium
By identifying and cropping the area to be cropped in the scanned image when the scanning angle is not standard, the problem of dim and blurry images caused by the scattering of the supplementary light is solved, thus improving the scanning effect and the quality of stitching recognition.
Patent Information
- Application Number
- CN202210716575.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-22
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-06-22
AI Technical Summary
When the scanning angle between the camera and the text is outside the standard scanning angle range, the light scattering from the supplementary light causes the scanning area to be dim, resulting in dark image edges, distorted content, and blurry images, thus affecting the scanning effect.
By obtaining the scanning angle, the image area to be cropped is determined and removed from the scanned image. The cropping area includes the area outside the effective illumination range of the scanning terminal. The cropping length is calculated using the scanning angle and the length of the illumination blind zone, and the cropping start position is determined according to the scanning direction.
When users use handheld scanning terminals improperly, ensure the quality of scanned images, avoid dimness and blurriness, and improve the quality and recognition effect of stitched images.
Smart Images

Figure CN115187989B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, electronic device, scanning pen and storage medium. Background Art
[0002] When using a scanning terminal, the fill light in the terminal focuses light on the scanning area, allowing the camera to capture clear, bright images within the scanning area. However, if the user holds the terminal improperly, causing the scanning angle between the camera and the document to fall outside the standard scanning angle range, the fill light will scatter outside the scanning area, gradually dimming the scanning area away from the fill light. This can cause the image captured by the camera to have dark edges, distorted content, or blurry images, which in turn reduces image quality and affects the scanning effect.
[0003] Therefore, there is an urgent need for a technical solution that can still ensure the scanning effect when the scanning angle between the camera and the text is outside the standard scanning angle range. Summary of the Invention
[0004] Based on the above needs, the present application proposes an image processing method, device, electronic device, scanning pen and storage medium. This method can still ensure the scanning effect when the scanning angle between the camera and the text is outside the standard scanning angle range.
[0005] The technical solutions proposed in this application are as follows:
[0006] In one aspect, the present application provides an image processing method, comprising:
[0007] Obtaining the scanning angle when the scanning terminal scans and obtains the scanned image;
[0008] If the scanning angle is outside the preset standard scanning angle range, determining an image area to be cropped from the scanned image based on the scanning angle; the image area to be cropped includes an area in the scanned image that is outside the effective fill light range of the scanning terminal;
[0009] The image area to be cropped in the scanned image is cropped and deleted.
[0010] Furthermore, in the above-mentioned image processing method, determining the image area to be cropped from the scanned image according to the scanning angle includes:
[0011] Determining a cropping length of the scanned image according to the scanning angle and a length of an illumination blind zone at the scanning angle; wherein the length of the illumination blind zone at the scanning angle is a length of an illumination blind zone of a fill light of the scanning terminal when the scanning terminal operates at the scanning angle;
[0012] An image area to be cropped is determined from the scanned image according to the cropping length and the scanning direction of the scanning terminal.
[0013] Furthermore, in the above-mentioned image processing method, the length of the illumination blind zone under the scanning angle includes:
[0014] Any one of a distance between a first end and a second end of a scanning window of the scanning terminal, a length between the second end of the scanning window and a target position when generating the scanned image, and a preset length;
[0015] The first end of the scanning window is an end of the scanning window close to the scanning camera, and the second end of the scanning window is an end of the scanning window away from the scanning camera;
[0016] The target position is the intersection position of the optical axis of the fill light of the scanning terminal and the scanning object when the scanning terminal works at the scanning angle.
[0017] Furthermore, in the above-mentioned image processing method, determining the cropping length of the scanned image according to the scanning angle and the length of the illumination blind zone under the scanning angle includes:
[0018] The product of the cosine value of the scanning angle and the length of the illumination blind area is determined as the cropping length of the scanned image.
[0019] Furthermore, in the above-mentioned image processing method, determining the image area to be cropped from the scanned image according to the cropping length and the scanning direction of the scanning terminal includes:
[0020] determining a scanning initial end of the scanned image according to a scanning direction of the scanning terminal;
[0021] Starting from the initial end of the scan, an image region having the same length as the cropping length is selected from the scanned image as the image region to be cropped.
[0022] Furthermore, in the above-mentioned image processing method, the step of obtaining the scanning angle when the scanning terminal scans and obtains the scanned image includes:
[0023] Get the Euler angle when the scanning terminal scans the scanned image;
[0024] Determining whether the roll angle in the Euler angle is less than a preset roll angle threshold;
[0025] If the roll angle is less than a preset roll angle threshold, the pitch angle in the Euler angle is determined as the scanning angle when the scanning terminal scans to obtain the scanned image.
[0026] In another aspect, the present application provides an image processing device, comprising:
[0027] An acquisition module is used to acquire a scanning angle when a scanning terminal scans and obtains a scanned image;
[0028] a determination module configured to determine, if the scanning angle is outside a preset standard scanning angle range, an image region to be cropped from the scanned image based on the scanning angle; the image region to be cropped includes an area in the scanned image that is outside an effective fill light range corresponding to the scanning terminal;
[0029] The cropping module is used to crop and delete the image area to be cropped in the scanned image.
[0030] In another aspect, the present application provides an electronic device, comprising:
[0031] a memory and a first processor;
[0032] Wherein, the memory is used to store programs;
[0033] The processor is configured to implement any one of the above-mentioned image processing methods by running the program in the memory.
[0034] On the other hand, the present application provides a scanning pen, comprising a second processor, and a gesture detection component connected to the second processor;
[0035] The posture detection component is used to detect the posture of the scanning pen when scanning an image, and send the detected scanning pen posture data to the second processor;
[0036] The second processor is used to obtain the scanning angle when the scanning pen scans to obtain the scanned image based on the scanning pen posture data sent by the posture detection component. If it is detected that the scanning angle is outside the preset standard scanning angle range, the image area to be cropped is determined from the scanned image based on the scanning angle; the image area to be cropped includes the area in the scanned image that is outside the effective fill light range corresponding to the scanning terminal; the image area to be cropped in the scanned image is cropped and deleted.
[0037] On the other hand, the present application provides a storage medium, comprising: a computer program stored on the storage medium, and when the computer program is executed by a processor, each step of the image processing method described in any one of the above is implemented.
[0038] The image processing method, device, electronic device, scanning pen and storage medium of the present application include: obtaining the scanning angle when the scanning terminal scans to obtain the scanned image; if the scanning angle is outside the preset standard scanning angle range, then determining the image area to be cropped from the scanned image based on the scanning angle, wherein the image area to be cropped includes the area in the scanned image that is outside the effective fill light range of the corresponding scanning terminal, so as to facilitate cropping and deletion of the image area to be cropped in the scanned image. In an embodiment of the present application, when the user's holding motion of the scanning terminal is not standardized, resulting in a scanning angle outside the preset standard scanning angle range, based on the scanning angle when the scanning terminal scans to obtain the scanned image, the dark, distorted, and blurred image area to be cropped in the scanned image is determined and cropped and deleted, thereby ensuring the scanning effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0040] Figure 1 This is a flowchart of an image processing method provided by an embodiment of the present application;
[0041] Figure 2 is a schematic diagram of the scanning angle provided in an embodiment of the present application;
[0042] Figure 3 is a schematic diagram of a scanning terminal provided in an embodiment of the present application in a scanning state;
[0043] Figure 4 is a schematic diagram of a scanning terminal provided in an embodiment of the present application in another scanning state;
[0044] Figure 5 This is a schematic diagram of a process for determining an image area to be cropped from a scanned image provided by an embodiment of the present application;
[0045] Figure 6 This is a schematic diagram of the blind area of the scanning terminal provided in an embodiment of the present application;
[0046] Figure 7 This is another flowchart of determining an image area to be cropped from a scanned image provided by an embodiment of the present application;
[0047] Figure 8 1 is a schematic diagram of a process for determining a scanning angle according to an embodiment of the present application;
[0048] Figure 9 This is a schematic diagram of Euler angles provided in an embodiment of the present application;
[0049] Figure 10 Schematic diagram of splicing scanned images with the image area to be cropped deleted provided by an embodiment of the present application;
[0050] Figure 11 1 is a schematic diagram of splicing scanned images without cropping the image area to be cropped, provided in an embodiment of the present application;
[0051] Figure 12 1 is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0052] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0053] Figure 14 This is a structural diagram of a scanning pen provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solution of the embodiment of the present application is suitable for application scenarios where scanned images obtained by scanning a scanning terminal are processed. By adopting the technical solution of the embodiment of the present application, it is possible to determine the image area outside the effective fill light range of the scanning terminal's fill light from the scanned image based on the scanning angle when the scanning terminal scans the scanned image, and crop and delete it, thereby achieving the purpose of cropping out dark, blurred and other unclear image areas in the scanned image, thereby improving the quality of the scanned image.
[0055] For example, the technical solutions of the embodiments of the present application can be applied to hardware devices such as hardware processors, or packaged into software programs and run. When the hardware processor executes the processing of the technical solutions of the embodiments of the present application, or when the above-mentioned software programs are run, the processing of scanned images can be realized. The embodiments of the present application only provide an exemplary introduction to the specific processing of the technical solutions of the present application, and do not limit the specific implementation form of the technical solutions of the present application. Any form of technical implementation that can execute the processing of the technical solutions of the present application can be adopted by the embodiments of the present application.
[0056] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0057] This embodiment proposes an image processing method, see Figure 1 As shown, the method includes:
[0058] S101: Obtain a scanning angle when a scanning terminal scans and obtains a scanned image.
[0059] The scanning terminal refers to a terminal device with a scanning function, such as a scanning pen, translation pen, or dictionary pen. The scanning terminal is equipped with a scanning device, typically a camera. When using the scanning terminal for scanning, the camera on the scanning terminal can be aimed at the target text to be recognized and a sliding scan is performed to obtain a scanned image captured by the camera during the sliding scan. The obtained scanned images are then stitched together to obtain a stitched image corresponding to the target text. Subsequently, text recognition can be performed on the stitched image corresponding to the target text to obtain the scanned text corresponding to the target text.
[0060] The above scanning angle refers to the angle formed by the optical axis of the camera and the plane where the target text is located during the scanning process. The optical axis of the camera refers to the line passing through the center of the camera lens. For example, Figure 2 As shown, the optical axis L1 of the camera C and the plane T where the target text is located form a scanning angle θ.
[0061] The quality of the scanned image captured by the camera directly affects the quality of the subsequent stitched image and the recognition effect of the stitched image. Therefore, in order to ensure the quality of the scanned image and improve the quality of the subsequent stitched image and the recognition effect of the stitched image, it is generally required that people use a standard posture when scanning with a scanning terminal, so that the scanning angle between the optical axis of the camera in the scanning terminal and the target text is within the standard scanning angle range. In this state, if Figure 3 As shown, the scanning window M of the scanning terminal A contacts the plane T where the target text is located. The fill light of the scanning terminal A can focus on illuminating the standard scanning area S1, and the camera can capture a bright and clear scanned image. The standard scanning area S1 is the camera's capture area at the current scanning angle. That is, at the current scanning angle, the scanned image corresponds to the content within the standard scanning area S1.
[0062] However, the user cannot always ensure that the scanning angle is within the standard scanning angle range during use. Once the user's holding the scanning terminal is not standardized, causing the scanning angle to be outside the standard scanning angle range, such as Figure 4 As shown, in this state, the scanning window M of the scanning terminal A is tilted and cannot contact the target text, and the light of the fill light is scattered and scattered outside the scanning area. At this time, the scanned image corresponds to the content in the scanning area S2, and the light in the area of the scanning area S2 away from the fill light gradually dims, that is, according to Figure 4In the middle direction X1, the fill light of the fill light in the scanning area S2 gradually dims, which causes the scanned image collected by the camera to have dim edges, deformed content, and blurred content, affecting the quality of subsequent stitching images and the recognition effect of the stitching images.
[0063] Therefore, in an embodiment of the present application, the scanning angle when the scanning terminal scans to obtain a scanned image is obtained to facilitate monitoring of the scanning angle. When the scanning angle is outside the preset standard scanning angle range, the scanned image is processed to avoid affecting the quality of the subsequent stitched image and the recognition effect of the stitched image.
[0064] S102, determine whether the scanning angle is outside the preset standard scanning angle range; if the scanning angle is outside the preset standard scanning angle range, execute step S103; if the scanning angle is within the preset standard scanning angle range, end execution of this step.
[0065] In an embodiment of the present application, after obtaining the scanning angle, it is determined whether the above-mentioned scanning angle is outside the preset standard scanning angle range. If the above-mentioned scanning angle is outside the preset standard scanning angle range, it means that the current scanned image quality is low, and step S103 can be executed to process the scanned image to avoid affecting the quality of the subsequent stitched image and the recognition effect of the stitched image. If the scanning angle is within the preset standard scanning angle range, the current scanned image quality is high, and the scanned image does not need to be processed, and this step ends.
[0066] The standard scanning angle range can be determined based on actual conditions, for example, 60° to 90°, which is not limited in this embodiment. For example, if the standard scanning angle range is 60° to 90°, if a scanning angle of 40° is detected, it indicates that the scanning angle is outside the preset standard scanning angle range, and step S103 needs to be executed; if a scanning angle of 75° is detected, it indicates that the scanning angle is within the preset standard scanning angle range, and this step ends.
[0067] S103: Determine the image area to be cropped from the scanned image according to the scanning angle.
[0068] The aforementioned image area to be cropped refers to the area within the scanned image that is outside the effective fill light range of the corresponding scanning terminal. As described in the above embodiment, when the scanning angle is outside the standard scanning angle range, the fill light will scatter and scatter outside the scanning area. The light in the scanning area away from the fill light gradually dims and lacks effective fill light. In the scanned image, the area corresponding to the area receiving ineffective fill light is prone to appear dim, distorted, or blurred. Therefore, it is necessary to determine the image area to be cropped within the scanned image that is outside the effective fill light range of the corresponding scanning terminal so that the image area to be cropped can be deleted from the scanned image.
[0069] The length of the area to be cropped is related to the scanning angle, specifically, Figure 4 As shown, when the scanning angle is outside the standard scanning angle range, the smaller the scanning angle, the more severe the fill light scattering, resulting in a larger area in the scanning area without effective fill light, and correspondingly, a longer length of the image area to be cropped in the scanned image. Therefore, based on the inverse relationship between the area of the cropped image area and the scanning angle, the cropping length of the image area to be cropped can be determined from the scanned image. That is, when the scanning angle is outside the standard scanning angle range, the smaller the scanning angle, the larger the corresponding cropping length value, and the larger the scanning angle, the smaller the corresponding cropping length value.
[0070] The starting position of the cropped area is related to the scanning direction of the scanned image obtained by the scanning terminal. Specifically, when the scanning angle is outside the standard scanning angle range, if the user scans in a certain direction, the area of the scan area away from the fill light corresponds to the starting scanning portion of the scanned image. Therefore, the starting scanning portion of the scanned image can be determined based on the user's scanning direction, and an image area of the same length as the cropping length can be cut from the starting scanning portion of the scanned image to form the image area to be cropped.
[0071] S104: Crop and delete the image area to be cropped in the scanned image.
[0072] After determining the area to be cropped, crop and delete it from the scanned image.
[0073] In this embodiment, a scanning angle is obtained when the scanning terminal scans and obtains a scanned image. If the scanning angle is outside a preset standard scanning angle range, an image region to be cropped is determined from the scanned image based on the scanning angle, wherein the image region to be cropped includes an area in the scanned image that is outside the effective fill light range of the corresponding scanning terminal, and the image region to be cropped in the scanned image is cropped and deleted. In the embodiment of the present application, when the user's holding of the scanning pen is not standardized, resulting in a scanning angle outside the preset standard scanning angle range, the scanning angle when the scanning terminal scans and obtains the scanned image can be used to determine the dark, distorted, or blurred image region to be cropped in the scanned image and crop the image region to be cropped and delete it, thereby ensuring the scanning effect.
[0074] As an optional implementation, such as Figure 5 As shown, in another embodiment of the present application, the steps of the above embodiment are disclosed, which include determining the image area to be cropped from the scanned image according to the scanning angle, and include the following steps:
[0075] S501: Determine a cropping length for a scanned image according to a scanning angle and a length of an illumination blind area under the scanning angle.
[0076] The length of the blind zone at the aforementioned scanning angle refers to the length of the blind zone illuminated by the scanner's fill light when the scanner is operating at the scanning angle. Specifically, the projection of the blind zone onto the plane where the target text resides can be determined, and this projection can be used as the cropping length of the scanned image.
[0077] like Figure 6 As shown, L2 is the light passing through the upper boundary of the camera, and the intersection point e formed by the intersection of the light L2 and the plane where the target text is located falls on the boundary of the scanning area S2. In this embodiment, a length is cut from the light L2 as the length of the illumination blind area, and the projection length of the illumination blind area length on the plane where the target text is located is determined as the cropping length of the scanned image.
[0078] As an optional implementation, the distance between the first and second ends of the scanning window can be used as the length of the blind spot at the scanning angle. The first end of the scanning window is the end of the scanning window closest to the scanning camera, and the second end of the scanning window is the end of the scanning window farther from the scanning camera.
[0079] As an optional implementation method, a preset length can also be used as the length of the illumination blind zone under the scanning angle. The preset length is determined by experiment. Specifically, the scanning terminal can be used to scan and obtain a large number of sample scanned images, and during the above scanning process, the scanning angle is outside the standard scanning angle range. Then, the image area to be cropped in each sample scanned image is determined, and based on the length of the image area to be cropped and the scanning angle when scanning the sample scanned image, the sample illumination blind zone length corresponding to each sample scanned image is inferred, and then the sample illumination blind zone lengths corresponding to all sample scanned images are analyzed and processed, for example, by taking the average value and other processing, and then the illumination blind zone length of the terminal device is obtained.
[0080] S502: Determine an image area to be cropped from the scanned image according to the cropping length and the scanning direction of the scanning terminal.
[0081] In this embodiment, the scanning initial end is determined by the scanning direction of the scanning terminal. Starting from the scanning initial end, an image area with the same length as the cropping length is selected from the scanned image as the image area to be cropped, so as to determine the image area to be cropped from the scanned image and crop and delete it to ensure the scanning effect.
[0082] As an optional implementation, another embodiment of the present application discloses that the steps of the above embodiment determine the cropping length of the scanned image based on the scanning angle and the length of the illumination blind zone under the scanning angle, including the following steps:
[0083] The product of the cosine value of the scanning angle and the length of the blind area is determined as the cropping length of the scanned image. Figure 6 As shown in FIG, if the length between point e and point d is determined as the length of the illumination blind zone, the projection of the length of the illumination blind zone on the plane where the target text is located can be obtained by calculating the product of the cosine value of the scanning angle θ and the length of the illumination blind zone, and then the length of the projection is determined as the cropping length of the scanned image.
[0084] In this embodiment, the cropping length of the scanned image is determined based on the product of the cosine value of the scanning angle and the length of the illumination blind area, so as to crop and delete the image area to be cropped, thereby ensuring the scanning effect.
[0085] As an optional implementation, such as Figure 7 As shown, in another embodiment of the present application, the steps of the above embodiment cropping length and scanning direction of the scanning terminal are disclosed, and the image area to be cropped is determined from the scanned image, including:
[0086] S701: Determine a scanning initial end of a scanned image according to a scanning direction of a scanning terminal.
[0087] The scanning starting point of the area to be cropped is related to the scanning direction of the scanning terminal when scanning and obtaining the scanned image. Specifically, if the scanning terminal scans from a first direction to a second direction and the scanning angle is outside the standard scanning angle range, the end of the scanning area formed by the scanning terminal closer to the first direction is far away from the fill light, and may not receive effective fill light, resulting in a dim, distorted, or blurred image. Therefore, the edge of the scanned image corresponding to the end of the scanning area closer to the first direction can be used as the scanning starting point. This allows the image area of the same length as the cropping length to be captured starting from the scanning starting point as the image area to be cropped.
[0088] like Figure 4 As shown, direction X2 is the scanning direction of scanning terminal A. That is, scanning terminal A slides and scans in the direction from a to b. In scanning area S2, the area near end a is far away from the fill light and may not receive effective fill light. The resulting image is likely to appear dim, distorted, or blurred. Therefore, the edge corresponding to end a in scanning area S2 in the scanned image can be used as the scanning starting point.
[0089] S702 : Starting from the initial scanning end, an image region having the same length as the cropping length is selected from the scanned image as the image region to be cropped.
[0090] In an embodiment of the present application, after determining the initial scanning end, an image area with the same length as the cropping length is selected from the scanned image starting from the initial scanning end, and the content of the image is determined as the image area to be cropped.
[0091] In this embodiment, the image area to be cropped of the scanned image is determined based on the scanning direction and cropping length of the scanning terminal, so that the image area to be cropped can be cropped and deleted to ensure the scanning effect.
[0092] As an optional implementation, such as Figure 8 As shown, in another embodiment of the present application, the steps of the above embodiment are to obtain the scanning angle when the scanning terminal scans and obtains the scanned image, specifically including the following steps:
[0093] S801: Obtain the Euler angles when a scanning terminal scans a scanned image.
[0094] The above Euler angles include the pitch angle and roll angle when the scanning terminal scans and obtains the scanned image. Figure 9 As shown in the figure, if the scanning direction of the scanning terminal is the X axis, the upward direction perpendicular to the plane where the target text is located is the Y axis, and the outward direction perpendicular to the XOY plane is the Z axis, a three-dimensional coordinate system is established. Among them, the pitch angle is the angle of rotation around the Y axis, that is, according to Figure 9 The angle of rotation of the direction V1 shown; the roll angle is the angle of rotation around the X axis, that is, according to Figure 9The angle of rotation of the direction V2 shown. If it is rotated around the Z axis, that is, according to Figure 9 The angle obtained by rotating the direction V3 shown is the yaw angle.
[0095] In the embodiment of the present application, only the pitch angle and the roll angle of the Euler angle when the scanning terminal scans and obtains the scanned image are obtained. For example, the Euler angle when the scanning terminal scans and obtains the scanned image can be determined based on a gyroscope provided in the scanning terminal.
[0096] S802: Determine whether the roll angle in the Euler angle is less than a preset roll angle threshold; if the roll angle is less than the preset roll angle threshold, execute step S803; if the roll angle is not less than the preset roll angle threshold, terminate execution of this step.
[0097] In the embodiments of the present application, when the scanning terminal is scanning on a horizontal plane, the pitch angle is the angle between the scanning terminal and the target text, that is, the angle between the camera's optical axis and the target text. When the scanning terminal is scanning on an inclined plane, the pitch angle obtained by the gyroscope is the angle between the scanning terminal and the horizontal plane, that is, the angle between the camera's optical axis and the horizontal plane, and not the angle between the camera's optical axis and the target text.
[0098] To ensure the accuracy of the scanning angle, this embodiment first determines whether the roll angle is less than a preset roll angle threshold. If so, the target text is considered to be located on a horizontal plane, and step S803 is executed to determine the pitch angle as the scanning angle used by the scanning terminal when scanning the scanned image. If the roll angle is not less than the preset roll angle threshold, the target text is considered to be located on an inclined plane. The pitch angle obtained in this case is not the scanning angle, and this step is terminated. Furthermore, if the roll angle is not less than the preset roll angle threshold, a prompt message may be output to inform the user that the target text is tilted and to advise the user to place the target text on a horizontal plane before scanning.
[0099] The above preset roll angle threshold can be set according to actual conditions, for example, set to 10°, which is not limited in this embodiment.
[0100] S803: Determine the pitch angle in the Euler angle as the scanning angle when the scanning terminal scans to obtain a scanned image.
[0101] Specifically, if the roll angle is less than a preset roll angle threshold, in this embodiment, the pitch angle in the Euler angle is determined as the scanning angle when the scanning terminal scans to obtain the scanned image.
[0102] Specifically, based on Figure 9 The coordinate system shown can establish the rotation matrix corresponding to direction V1, direction V2, and direction V3:
[0103]
[0104]
[0105]
[0106] Among them, R x (α) is the rotation matrix obtained by rotating along the X axis in the direction V1, R y (β) is the rotation matrix obtained by rotating along the Y axis in the direction V2, R z (γ) is the rotation matrix obtained by rotating in the direction V3 on the Z axis, α is the pitch angle, β is the roll angle, and γ is the yaw angle.
[0107] Based on the above rotation matrix, the calculation formulas for pitch angle, roll angle and yaw angle are:
[0108]
[0109] α=atan(r 32 , r 32 )
[0110]
[0111] γ=atan(r 21 , r 11 )
[0112] In this embodiment, based on the roll angle when the scanning terminal scans and obtains the scanned image, it is determined whether the target text currently being scanned is located in a horizontal plane. When the scanned target text is in a horizontal plane, the pitch angle when the scanning terminal scans and obtains the scanned image is determined as the scanning angle. This avoids erroneously using the pitch angle as the scanning angle to determine an incorrect image area to be cropped when the scanned text is not in a horizontal plane, thereby ensuring the quality of the scanned image.
[0113] As an optional implementation method, another embodiment of the present application discloses that after the image area to be cropped is cropped and deleted from the scanned image, the multiple scanned images obtained during the scanning process can be further processed, including image registration, projection transformation, stitching calculation and image fusion steps.
[0114] The image registration process includes:
[0115] First, extract feature points from the scanned image. Feature points are points in the scanned image where the grayscale value changes dramatically or where there is significant curvature on the edge of the image. By taking photos of the same scene from different angles, feature points can be robustly extracted in every photo. Existing algorithms such as SIFT, SURF, and ORB can be used to extract feature points from the scanned image.
[0116] After the feature point extraction is completed, the scanned images with the same features can be registered. That is, the scanned images with the same features are fused into one image. In this embodiment, two scanned images with the same features are registered and spliced based on the homography matrix to preliminarily obtain a spliced image. It should be noted that, considering that there may be extraction errors in the process of feature point extraction, the RANSAC algorithm is used for solution in the embodiment of the present application. Simply put, four points are randomly selected each time to solve the homography matrix, and then the remaining matching pairs are judged whether they are correct matches based on the homography matrix, and the group with the largest number of correct matches is selected to solve the homography matrix. After the adjacent scanned images are registered, the spliced image is projected.
[0117] The projection transformation process includes:
[0118] Since the scanning direction does not always follow a straight line during the scanning process, the stitching result will appear wavy. To solve this problem, horizontal correction is required. Generally, it is necessary to project the stitched images onto a sphere or cylinder through projection transformation to obtain a stitched image for further processing. However, at this time, the stitched image may have obvious changes in brightness and darkness, as well as partial misalignment, and the overlapping areas between images will also have obvious transition marks. To solve this problem, this embodiment further performs stitching calculation and image fusion processing on the stitched image.
[0119] Seam lines can be found using existing techniques such as point-by-point methods, dynamic programming, or graph cut methods. The point-by-point method is the simplest but offers relatively poor results, while the graph cut method has the highest computational complexity but offers the best results. Dynamic programming offers a compromise between the two, offering a moderate level of computational complexity and performance. Those skilled in the art can choose different seam calculation methods based on their specific needs.
[0120] Common fusion algorithms include feathering and Laplace. Feathering involves weighting locations near the seam based on their distance from the seam for weighted fusion. Laplace, on the other hand, calculates the frequency components of the image and then fuses them by frequency. While the Laplace algorithm offers better results, it also has a higher computational complexity. Those skilled in the art can choose different fusion algorithms based on their specific needs.
[0121] After the stitching calculation and image fusion processing are completed on the stitching image, the final stitching image is obtained. The text recognition can be performed on the stitching image to obtain the scanned text corresponding to the scanned image.
[0122] In the embodiment of the present application, when the user's holding motion of the scanning terminal is not standard, resulting in the scanning angle being outside the preset standard scanning angle range, the dark, distorted, and blurred image areas to be cropped in the scanned image can be determined based on the scanning angle when the scanning terminal scans the scanned image, and the image areas to be cropped can be cropped and deleted. Then, after the above-mentioned steps of image registration, projection transformation, stitching calculation, and image fusion, the resulting stitched image is as follows: Figure 10 As shown in FIG, the scanned image that has not been cropped and deleted is processed through the above steps of image registration, projection transformation, stitching calculation and image fusion to obtain the stitched image as shown in FIG. Figure 11 As shown, by comparison, it can be seen that through this embodiment, the image area to be cropped in the scanned image is determined and the image area to be cropped is cropped and deleted, and the resulting stitching result of the stitched image is smoother, the background and font colors are more uniform, and there is no problem of inconsistent brightness, which also provides reliable basic information for the final recognition process.
[0123] Corresponding to the above-mentioned image processing method, the present application also discloses an image processing device, see Figure 12 As shown, the device includes:
[0124] An acquisition module 100 is used to acquire a scanning angle when a scanning terminal scans and obtains a scanned image;
[0125] A determination module 110 is configured to determine, if the scanning angle is outside a preset standard scanning angle range, an image region to be cropped from the scanned image based on the scanning angle; the image region to be cropped includes an area in the scanned image that is outside an effective fill light range of the corresponding scanning terminal;
[0126] The cropping module 120 is configured to crop and delete the image area to be cropped in the scanned image.
[0127] In this embodiment, the acquisition module 100 acquires the scanning angle when the scanning terminal scans and obtains the scanned image; if the scanning angle is outside the preset standard scanning angle range, the determination module 110 determines the image area to be cropped from the scanned image based on the scanning angle, wherein the image area to be cropped includes the area in the scanned image that is outside the effective fill light range of the corresponding scanning terminal, so that the cropping module 120 can crop and delete the image area to be cropped in the scanned image. In the embodiment of the present application, when the user's holding motion of the scanning terminal is not standard, resulting in the scanning angle being outside the preset standard scanning angle range, the scanning terminal can be used to determine the dark, distorted, or blurred image area to be cropped in the scanned image based on the scanning angle when the scanned image is scanned and cropped and delete the image area to be cropped, thereby ensuring the scanning effect.
[0128] Optionally, in another embodiment of the present application, the determining module 110 includes:
[0129] a first determining unit, configured to determine a cropping length of the scanned image based on a scanning angle and a length of an illumination blind zone at the scanning angle; wherein the length of the illumination blind zone at the scanning angle is a length of an illumination blind zone of a fill light of the scanning terminal when the scanning terminal operates at the scanning angle;
[0130] The second determining unit is configured to determine the image area to be cropped from the scanned image according to the cropping length and the scanning direction of the scanning terminal.
[0131] Optionally, in another embodiment of the present application, the length of the irradiation blind zone under the scanning angle includes:
[0132] Any one of the distance between the first end and the second end of the scanning window of the scanning terminal, the length between the second end of the scanning window and the target position when generating the scan image, and a preset length;
[0133] The first end of the scanning window is the end of the scanning window close to the scanning camera, and the second end of the scanning window is the end of the scanning window away from the scanning camera;
[0134] The target position is the intersection of the optical axis of the scanning terminal's fill light and the scan object when the scanning terminal is working at a scanning angle.
[0135] Optionally, in another embodiment of the present application, when the first determining unit determines the cropping length of the scanned image according to the scanning angle and the length of the illumination blind zone under the scanning angle, it is specifically configured to:
[0136] The product of the cosine value of the scanning angle and the length of the illumination blind area is determined as the cropping length of the scanned image.
[0137] Optionally, in another embodiment of the present application, the second determining unit includes:
[0138] A first determining subunit is configured to determine a scanning initial end of the scanned image according to a scanning direction of the scanning terminal;
[0139] The selection subunit is used to select an image area with the same length as the cropping length from the scanned image starting from the initial scanning end as the image area to be cropped.
[0140] Optionally, in another embodiment of the present application, the acquisition module 100 includes:
[0141] An acquisition unit, configured to acquire the Euler angles when a scanning terminal scans a scanned image;
[0142] a judging unit, configured to judge whether the roll angle in the Euler angle is less than a preset roll angle threshold;
[0143] The third determining unit is configured to determine the pitch angle in the Euler angle as a scanning angle when the scanning terminal scans to obtain a scanned image if the roll angle is less than a preset roll angle threshold.
[0144] Specifically, for the specific working contents of each unit of the above-mentioned image processing device, please refer to the contents of the above-mentioned method embodiment, which will not be repeated here.
[0145] Another embodiment of the present application further provides an electronic device, see Figure 13 As shown, the device includes:
[0146] Memory 200 and first processor 210;
[0147] The memory 200 is connected to the first processor 210 and is used to store programs;
[0148] The first processor 210 is configured to implement the image processing method disclosed in any of the above embodiments by running the program stored in the memory 200 .
[0149] Specifically, the electronic device may further include: a bus, a communication interface 220 , an input device 230 and an output device 240 .
[0150] The first processor 210, the memory 200, the communication interface 220, the input device 230 and the output device 240 are connected to each other via a bus.
[0151] A bus may include a pathway that transfers information between components of a computer system.
[0152] The first processor 210 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, or the like, or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component.
[0153] The first processor 210 may include a main processor, and may also include a baseband chip, a modem, and the like.
[0154] The memory 200 stores a program for executing the technical solution of the present application, and may also store an operating system and other key services. Specifically, the program may include program code, and the program code includes computer operating instructions. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, disk storage, flash, etc.
[0155] The input device 230 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.
[0156] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speakers, etc.
[0157] The communication interface 220 may include any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0158] The first processor 210 executes the program stored in the memory 200 and calls other devices, and can be used to implement each step of the image processing method provided in the above embodiment of the present application.
[0159] Another embodiment of the present application also provides a scanning pen. Figure 14 As shown, the scanning pen includes a second processor 300 and a posture detection component 310 connected to the second processor 300;
[0160] The posture detection component 310 is used to detect the posture of the scanning pen when scanning an image, and send the detected scanning pen posture data to the second processor 300;
[0161] The second processor 300 is used to obtain the scanning angle when the scanning pen scans to obtain the scanned image based on the scanning pen posture data sent by the posture detection component 310. If the scanning angle is detected to be outside the preset standard scanning angle range, the image area to be cropped is determined from the scanned image based on the scanning angle; the image area to be cropped includes the area in the scanned image that is outside the effective fill light range of the corresponding scanning terminal; the image area to be cropped in the scanned image is cropped and deleted.
[0162] The posture detection component 310 may include a gyroscope.
[0163] The second processor 300 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, or the like, or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component.
[0164] In an embodiment of the present application, when the user's holding motion of the scanning terminal is not standard, resulting in a scanning angle outside the preset standard scanning angle range, the scanning angle when the scanning terminal scans the scanned image can be used to determine the dark, distorted, and blurred image area to be cropped in the scanned image and crop and delete the image area to be cropped to ensure the scanning effect.
[0165] As an optional implementation, another embodiment of the present application discloses that the second processor 300 determines the image area to be cropped from the scanned image according to the scanning angle, including:
[0166] The cropping length of the scanned image is determined based on the scanning angle and the length of the blind zone at the scanning angle; wherein the blind zone at the scanning angle is the length of the blind zone of the fill light of the scanning terminal when the scanning terminal operates at the scanning angle;
[0167] An image area to be cropped is determined from the scanned image according to the cropping length and the scanning direction of the scanning terminal.
[0168] As an optional implementation, another embodiment of the present application discloses that the length of the illumination blind zone under the scanning angle includes:
[0169] Any one of the distance between the first end and the second end of the scanning window of the scanning terminal, the length between the second end of the scanning window and the target position when generating the scan image, and a preset length;
[0170] The first end of the scanning window is the end of the scanning window close to the scanning camera, and the second end of the scanning window is the end of the scanning window away from the scanning camera;
[0171] The target position is the intersection of the optical axis of the scanning terminal's fill light and the scan object when the scanning terminal is working at a scanning angle.
[0172] As an optional implementation, another embodiment of the present application discloses that the second processor 300 determines the cropping length of the scanned image based on the scanning angle and the length of the illumination blind zone under the scanning angle, including:
[0173] The product of the cosine value of the scanning angle and the length of the illumination blind area is determined as the cropping length of the scanned image.
[0174] As an optional implementation, another embodiment of the present application discloses that the second processor 300 determines the image area to be cropped from the scanned image based on the scanning angle, the cropping length, and the scanning direction of the scanning terminal, including:
[0175] Determine the scanning starting end of the scanned image according to the scanning direction of the scanning terminal;
[0176] Starting from the initial end of the scan, an image area with the same length as the cropping length is selected from the scanned image as the image area to be cropped.
[0177] As an optional implementation, another embodiment of the present application discloses that the second processor 300 obtains the scanning angle when the scanning pen scans to obtain the scanned image based on the scanning pen posture data sent by the posture detection component 310, including:
[0178] Get the Euler angle when the scanning terminal scans the scanned image;
[0179] Determine whether the roll angle in the Euler angle is less than the preset roll angle threshold;
[0180] If the roll angle is less than a preset roll angle threshold, the pitch angle in the Euler angle is determined as the scanning angle when the scanning terminal scans to obtain the scanned image.
[0181] The scanning pen provided in this embodiment belongs to the same application concept as the image processing method provided in the above embodiments of this application, can execute the image processing method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects for executing the above image processing method. For technical details that are not fully described in this embodiment, please refer to the specific processing content of the image processing method provided in the above embodiments of this application, and will not be repeated here.
[0182] Another embodiment of the present application further provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program implements the various steps of the image processing method provided in any of the above embodiments.
[0183] Specifically, the specific working contents of each part of the above-mentioned electronic device and scanning pen, as well as the specific processing contents of the computer program on the above-mentioned storage medium when being executed by the processor, can be found in the contents of the various embodiments of the above-mentioned image processing method, and will not be repeated here.
[0184] For the sake of simplicity, the aforementioned method embodiments are described as a series of action combinations. However, those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0185] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similarities between the various embodiments can be referred to in conjunction with each other. For device embodiments, since they are generally similar to method embodiments, their description is relatively simple, and for relevant details, reference can be made to the description of the method embodiments.
[0186] The steps in the methods of each embodiment of the present application can be adjusted in sequence, merged, and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0187] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be merged, divided, and deleted according to actual needs.
[0188] In the several embodiments provided in this application, it should be understood that the disclosed terminals, devices, and methods can be implemented in other ways. For example, the terminal embodiments described above are merely illustrative. For example, the division of modules or submodules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or module, which can be electrical, mechanical or other forms.
[0189] The modules or submodules described as separate components may or may not be physically separate, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place or distributed across multiple network modules or submodules. Some or all of the modules or submodules may be selected to achieve the purpose of this embodiment according to actual needs.
[0190] In addition, each functional module or submodule in each embodiment of the present application may be integrated into a processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into a single module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or software functional modules or submodules.
[0191] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0192] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, software units executed by a processor, or a combination of the two. The software units may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0193] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0194] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for processing an image, characterized in that: include: Obtaining the scanning angle when the scanning terminal scans and obtains the scanned image; If the scanning angle is outside the preset standard scanning angle range, determining an image area to be cropped from the scanned image based on the scanning angle; the image area to be cropped includes an area in the scanned image that is outside the effective fill light range of the scanning terminal; The image area to be cropped in the scanned image is cropped and deleted.
2. The method according to claim 1, characterized in that Determining an image region to be cropped from the scanned image according to the scanning angle includes: Determining a cropping length of the scanned image according to the scanning angle and a length of an illumination blind zone at the scanning angle; wherein the length of the illumination blind zone at the scanning angle is a length of an illumination blind zone of a fill light of the scanning terminal when the scanning terminal operates at the scanning angle; An image area to be cropped is determined from the scanned image according to the cropping length and the scanning direction of the scanning terminal.
3. The method according to claim 2, characterized in that The length of the blind area under the scanning angle includes: The distance length or the preset length between the first end and the second end of the scanning window of the scanning terminal; The first end of the scanning window is an end of the scanning window close to the scanning camera, and the second end of the scanning window is an end of the scanning window away from the scanning camera.
4. The method according to claim 2, characterized in that Determining a cropping length of the scanned image according to the scanning angle and the length of the illumination blind zone under the scanning angle includes: The product of the cosine value of the scanning angle and the length of the illumination blind area is determined as the cropping length of the scanned image.
5. The method according to claim 2, characterized in that Determining an image area to be cropped from the scanned image according to the cropping length and a scanning direction of the scanning terminal includes: determining a scanning initial end of the scanned image according to a scanning direction of the scanning terminal; Starting from the initial end of the scan, an image region having the same length as the cropping length is selected from the scanned image as the image region to be cropped.
6. The method according to claim 1, characterized in that The method of obtaining the scanning angle when the scanning terminal scans and obtains the scanned image includes: Get the Euler angle when the scanning terminal scans the scanned image; Determining whether the roll angle in the Euler angle is less than a preset roll angle threshold; If the roll angle is less than a preset roll angle threshold, the pitch angle in the Euler angle is determined as the scanning angle when the scanning terminal scans to obtain the scanned image.
7. An image processing device, characterized in that: include: An acquisition module is used to acquire a scanning angle when a scanning terminal scans and obtains a scanned image; a determination module configured to determine, if the scanning angle is outside a preset standard scanning angle range, an image region to be cropped from the scanned image based on the scanning angle; the image region to be cropped includes an area in the scanned image that is outside an effective fill light range corresponding to the scanning terminal; The cropping module is used to crop and delete the image area to be cropped in the scanned image.
8. An electronic device, characterized in that: include: a memory and a first processor; Wherein, the memory is used to store programs; The processor is configured to implement the image processing method according to any one of claims 1 to 6 by running the program in the memory.
9. A scanning pen, characterized in that: comprising a second processor, and a posture detection component connected to the second processor; The posture detection component is used to detect the posture of the scanning pen when scanning an image, and send the detected scanning pen posture data to the second processor; The second processor is used to obtain the scanning angle when the scanning pen scans to obtain the scanned image based on the scanning pen posture data sent by the posture detection component. If it is detected that the scanning angle is outside the preset standard scanning angle range, the image area to be cropped is determined from the scanned image based on the scanning angle; the image area to be cropped includes the area in the scanned image that is outside the effective fill light range corresponding to the scanning terminal; the image area to be cropped in the scanned image is cropped and deleted.
10. A storage medium, characterized in that: include: The storage medium stores a computer program, and when the computer program is executed by the processor, the computer program implements the steps of the image processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Dark image corner cutting scope determining method, dark image corner compensating method and apparatus
CN106815846A
Character recognition method based on scanning software and scanning system
CN114419303A