Image acquisition method and device for avoiding cutting edge, electronic equipment and storage medium

By displaying a guide box and generating a cropping box on the shooting interface, the problems of low efficiency and poor adaptability of image detection models in detecting cropping edges are solved, achieving efficient and accurate image acquisition.

CN116597449BActive Publication Date: 2026-07-21PING AN TECH (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN TECH (SHENZHEN) CO LTD
Filing Date
2023-05-17
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In existing technologies, image detection models are inefficient at detecting whether an image has cropped edges and are difficult to adapt to diverse shooting scenarios, resulting in low detection accuracy.

Method used

By displaying a guide box on the shooting interface, screen coordinates are obtained and converted into image coordinates to generate a cropping box. The image to be tested is cropped, and it is determined whether there are cut edges in the cropped image. The coordinate relationship between the cropping box and the detection box is used to filter out images with cut edges.

Benefits of technology

It improves the quality of image acquisition, effectively avoids the problem of low edge accuracy caused by the diversity of shooting scenarios, and improves the efficiency and accuracy of image acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116597449B_ABST
    Figure CN116597449B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing and digital medical technology, and provides an image acquisition method and device avoiding edge cutting, electronic equipment and storage medium, the method comprises the following steps: displaying a guide frame on a shooting interface, and capturing a to-be-measured image of a to-be-measured target in the shooting interface in real time; obtaining the screen coordinates of the guide frame, and converting the screen coordinates into image coordinates according to the to-be-measured image; generating a clipping frame according to the image coordinates; clipping the region corresponding to the clipping frame in the to-be-measured image to obtain a clipped image; and determining the clipped image without edge cutting as the target image of the to-be-measured target according to the clipping frame. The present application effectively avoids the problem of low accuracy of edge cutting caused by the diversification of the shooting scene, and improves the effect of acquiring the image of the to-be-measured target.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically to an image acquisition method, apparatus, electronic device, and storage medium that avoids edge cropping. Background Technology

[0002] With the development of computer technology, more and more technologies, such as cloud computing and blockchain, are being applied in the financial sector, and the traditional financial industry is gradually transforming into fintech. However, both traditional finance and modern fintech require obtaining user identification documents and performing optical character recognition (OCR) on them. Furthermore, in the field of digital healthcare, OCR recognition is also needed for various documents, including medical insurance cards, photographs, and scans. These documents include various receipts, examination reports, and images generated by medical instruments. Before performing OCR on documents or medical materials, images of the documents or materials must first be captured using an image acquisition device, and the images must be checked to ensure they meet requirements, such as clarity and the absence of cropped edges. After confirming that the image meets the requirements, OCR is then performed on the image.

[0003] In the process of realizing this invention, the inventors discovered that the existing methods for detecting whether an image has a cut edge are implemented through a detection model. However, the detection model requires a lot of training and parameter adjustment, which is very time-consuming and results in low efficiency in detecting cut edges. In addition, since there are many different shooting scenarios for images, the trained detection model is difficult to apply to all complex shooting scenarios, and therefore has poor practicality. Summary of the Invention

[0004] In view of the above, it is necessary to propose an image acquisition method, apparatus, electronic device and storage medium that avoids edge clipping, which can obtain images without edge clipping and improve the quality of image acquisition.

[0005] A first aspect of the present invention provides an image acquisition method that avoids edge cropping, the method comprising:

[0006] A guide box is displayed on the shooting interface, and the image of the target to be tested in the shooting interface is captured in real time.

[0007] Obtain the screen coordinates of the guide box, and convert the screen coordinates into image coordinates based on the image to be tested;

[0008] Generate a cropping box based on the image coordinates;

[0009] The region corresponding to the cropping box in the image to be tested is cropped to obtain a cropped image;

[0010] Determine whether the cropped image has a cut edge based on the cropping frame;

[0011] When the cropping image is identified as having no cut edges based on the cropping frame, the cropping image is determined as the target image of the target to be tested.

[0012] According to an optional embodiment of the present invention, the step of converting the screen coordinates into image coordinates based on the image to be tested includes:

[0013] The coordinate transformation factor is determined based on the size of the display screen and the size of the image to be tested;

[0014] The screen coordinates are converted into image coordinates according to the coordinate transformation factor.

[0015] According to an optional embodiment of the present invention, generating the cropping box based on the image coordinates includes:

[0016] Obtain the first specified coordinate and the second specified coordinate from the image coordinates;

[0017] The first specified coordinate is moved a preset first distance along a preset first moving direction to obtain the target first specified coordinate;

[0018] The second specified coordinate is moved a preset second distance along a preset second moving direction to obtain the target second specified coordinate;

[0019] The cropping frame is generated based on the first specified coordinates and the second specified coordinates of the target.

[0020] According to an optional embodiment of the present invention, determining whether the cropped image has a cut edge based on the cropping frame includes:

[0021] Generate a detection box based on the cropping box;

[0022] Obtain multiple edge coordinates of the target object in the cropped image;

[0023] Determine whether each of the plurality of edge coordinates is within the detection box;

[0024] When each of the plurality of edge coordinates is determined to be within the detection box, it is determined that the cropped image has no cut edges;

[0025] When it is determined that at least one of the multiple edge coordinates is not within the detection box, it is determined that the cropped image has a cut edge.

[0026] According to an optional embodiment of the present invention, generating a detection box based on the cropping box includes:

[0027] Obtain the third and fourth specified coordinates from the image coordinates of the cropping frame;

[0028] The third specified coordinate is moved along a preset third moving direction by a preset third distance to obtain the target third specified coordinate;

[0029] The fourth specified coordinate is moved along the preset fourth moving direction by a preset fourth distance to obtain the target fourth specified coordinate;

[0030] The detection box is generated based on the third and fourth specified coordinates of the target.

[0031] According to an optional embodiment of the present invention, the method further includes:

[0032] Optical character recognition is performed on the target image to obtain multiple target strings;

[0033] Generate a first string image based on each of the target strings;

[0034] The target image is cut into characters to obtain multiple second string images;

[0035] A difference image is calculated based on each of the first string images and the corresponding second string images;

[0036] Each of the difference images is compared with a preset threshold to obtain a comparison result;

[0037] The optical character recognition result is obtained based on the comparison results.

[0038] According to an optional embodiment of the present invention, displaying the guide box on the shooting interface includes:

[0039] The shooting interface displays multiple preset target type options;

[0040] Detect whether the multiple preset target type options have received a selection instruction;

[0041] The guide box corresponding to the preset target type option that receives the selected instruction will be displayed on the shooting interface.

[0042] A second aspect of the present invention provides an image acquisition apparatus that avoids edge cropping, the apparatus comprising:

[0043] The display module is used to display a guide box on the shooting interface and capture the image of the target to be tested in the shooting interface in real time.

[0044] The conversion module is used to obtain the screen coordinates of the guide box and convert the screen coordinates into image coordinates according to the image to be tested;

[0045] The generation module is used to generate a cropping box based on the image coordinates;

[0046] The cropping module is used to crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image;

[0047] The judgment module is used to determine whether the cropped image has a cut edge based on the cropping frame;

[0048] The cropping module is further configured to determine the cropped image as the target image of the target to be tested when the cropped image is identified as having no cut edges according to the cropping frame.

[0049] A third aspect of the present invention provides an electronic device comprising a processor and a memory, wherein the processor is configured to implement the image acquisition method for avoiding edge cutting when executing a computer program stored in the memory.

[0050] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the image acquisition method for avoiding edge clipping.

[0051] The present invention provides an image acquisition method, apparatus, electronic device, and storage medium that avoids edge cropping. It displays a guide frame on a shooting interface and captures the image of the target object in real time. By acquiring the screen coordinates of the guide frame and converting them into image coordinates based on the image, a cropping frame is generated based on the image coordinates. This cropping is then applied to the area corresponding to the cropping frame in the image, resulting in a cropped image. Finally, images with cropped edges are filtered out by detecting whether the edge coordinates of the cropped image are within the cropping frame. This effectively avoids the problem of low accuracy in edge cropping caused by the diversity of shooting scenes, thus improving the image acquisition effect of the target object. Attached Figure Description

[0052] Figure 1 This is a schematic diagram of an image of an ID card with cropped edges.

[0053] Figure 2 This is a flowchart of the image acquisition method for avoiding edge trimming provided in Embodiment 1 of the present invention.

[0054] Figure 3 This is a schematic diagram of the guide frame provided in an embodiment of the present invention.

[0055] Figure 4 This is a schematic diagram illustrating the positional relationship between the cropping frame and the guide frame provided in an embodiment of the present invention.

[0056] Figure 5 This is a structural diagram of the image acquisition device for avoiding edge cutting provided in Embodiment 2 of the present invention.

[0057] Figure 6 This is a schematic diagram of the structure of the electronic device provided in Embodiment 3 of the present invention. Detailed Implementation

[0058] To better understand the above-mentioned objects, features, and advantages of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. Unless otherwise specified, the embodiments of the present invention and the features thereof can be combined with each other.

[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for descriptive purposes only and is not intended to be limiting of the invention.

[0060] The image acquisition method for avoiding edge cutting provided in this embodiment of the invention is executed by an electronic device, and correspondingly, the image acquisition device for avoiding edge cutting operates in the electronic device.

[0061] This invention can standardize data processing based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0062] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0063] Example 1

[0064] Figure 2 This is a flowchart of an image acquisition method for avoiding edge clipping provided in Embodiment 1 of the present invention. The image acquisition method for avoiding edge clipping specifically includes the following steps. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0065] S21, a guide box is displayed on the shooting interface, and the image of the target to be tested in the shooting interface is captured in real time.

[0066] The target to be tested refers to the object that needs to be edge-checked, and the image to be tested is the image obtained by photographing the target to be tested. The target to be tested can be a certificate or document used to prove identity, experience, etc., such as an ID card, driver's license, Hong Kong and Macao travel permit, passport, accounting certificate, work permit, student ID, graduation certificate, health certificate, etc.

[0067] When this invention is applied to the field of digital healthcare, the target to be tested also includes medical insurance cards, various data generated during the diagnosis and treatment process, etc.

[0068] When identifying the content of a target object, an image of the target object can be captured first, and then optical character recognition (OCR) technology can be used to identify the content of the target object. Before performing OCR on the image, it can be determined whether the image has cropped edges to determine its completeness. Detecting cropped edges in an image is mostly done using detection models. However, some targets have less obvious features; for example, a Hong Kong and Macau travel permit, whose back is almost entirely text, may have cropped edges even if the image shows them. Figure 1 The detection model can be used to detect images of Hong Kong and Macao travel permits, and the detection results are normal, meaning that the detection results show that the images of Hong Kong and Macao travel permits are complete and have no cropped edges.

[0069] In existing technologies, the low detection accuracy of the aforementioned detection models is generally addressed by optimizing the model through extensive training and parameter adjustments. However, the optimization process is very time-consuming, resulting in low efficiency in edge detection. Furthermore, due to the diverse shooting scenarios for ID card images, the optimized detection model is difficult to apply to all complex shooting scenarios, leading to poor practicality.

[0070] This embodiment uses a guide frame to capture or acquire the image of the target to be tested, so that the edge detection of the image to be tested has a reference coordinate, thereby inferring whether the image to be tested has a cut edge.

[0071] In an optional implementation, displaying the guide box on the shooting interface includes:

[0072] The shooting interface displays multiple preset target type options;

[0073] Detect whether the multiple preset target type options have received a selection instruction;

[0074] The guide box corresponding to the preset target type option that receives the selected instruction will be displayed on the shooting interface.

[0075] Users can trigger the camera function of an electronic device by touching or clicking it. After the camera function is activated, the electronic device displays the shooting interface, which includes a guide box.

[0076] like Figure 3 As shown, the electronic device captures a full-screen image and generates and displays a guide box in the shooting interface. This guide box can be rectangular. Displaying the guide box guides the user to adjust the electronic device so that the target being tested is displayed within the guide box.

[0077] When displaying the shooting interface, the electronic device also displays multiple preset target type options within the shooting interface, allowing the user to select any one of these options. The size of the guide box displayed on the shooting interface is then determined based on the user's selected preset target type option. These multiple preset target type options can be displayed in a list format or as virtual buttons; this invention does not impose any limitations. The multiple preset target type options may include, but are not limited to: ID card, driver's license, Hong Kong and Macau travel permit, passport, accounting certificate, work permit, student ID, graduation certificate, health certificate, medical insurance card, etc. Different target type options correspond to different sized guide boxes. For example, when the target type option is an ID card, the aspect ratio of the guide box is the same as that of the ID card document; when the target type option is a health certificate, the aspect ratio of the guide box is the same as that of the health certificate document.

[0078] S22, obtain the screen coordinates of the guide frame, and convert the screen coordinates into image coordinates according to the image to be tested.

[0079] The screen coordinates of the guide frame are the coordinates of the guide frame in the display screen coordinate system. Converting the screen coordinates of the guide frame to image coordinates means converting the coordinates of the guide frame in the display screen coordinate system into image coordinates in the camera coordinate system.

[0080] Since the guide frame is displayed on the screen of the electronic device, its coordinates are actually the coordinates of the screen. The size of the image of the target being measured captured by the camera of the electronic device differs from the size of the screen. Therefore, it is necessary to convert the screen coordinates of the guide frame into image coordinates (i.e., camera coordinates).

[0081] The display screen coordinate system is based on the top-left corner of the electronic device's screen, with the origin (0, 0). Horizontal movement to the right represents the positive X-direction, and vertical movement downwards represents the positive Y-direction. The electronic device can obtain the screen coordinates of the guide box by calling the `getLocationOnScreen` method.

[0082] In an optional implementation, converting the screen coordinates into image coordinates based on the image to be tested includes:

[0083] The coordinate transformation factor is determined based on the size of the display screen and the size of the image to be tested;

[0084] The screen coordinates are converted into image coordinates according to the coordinate transformation factor.

[0085] The size of the display screen of an electronic device refers to the actual size of the display screen, which can be obtained from the system parameters of the electronic device.

[0086] The size of the image to be tested refers to the size of the image captured by the camera of the electronic device. The size of the image to be tested can be determined by parameters transmitted from the camera to the electronic device, such as sharpness. The sharper the image to be tested, the larger the image to be tested; the blurrier the image to be tested, the smaller the image to be tested.

[0087] The coordinate transformation factor scale can be calculated using the following formula:

[0088] scale = size of the image to be measured / size of the display screen.

[0089] The image coordinates of the guide box are calculated by multiplying the coordinate transformation factor and the screen coordinates.

[0090] For example, suppose the screen coordinates of the four vertices of the guide box are:

[0091] Top left: (x1, y1);

[0092] Top right: (x2, y2);

[0093] Bottom right: (x3, y3);

[0094] Bottom left: (x4, y4).

[0095] The image coordinates of the guide box in the camera coordinate system are:

[0096] Top left: (xx1, yy1) = (x1*scale, y1*scale);

[0097] Upper right: (xx2, yy2) = (x2*scale, y2*scale);

[0098] Lower right: (xx3, yy3) = (x3*scale, y3*scale);

[0099] Bottom left: (xx4, yy4) = (x4*scale, y4*scale).

[0100] S23, Generate a cropping box based on the image coordinates.

[0101] The cropping frame is obtained by expanding the guide frame outward based on the image coordinates of the guide frame in the camera coordinate system. If the guide frame is not expanded outward, even if the image to be tested has a cropped edge, the coordinates of the cropped edge will be within the range of the guide frame, making it impossible to determine whether the image to be tested has a cropped edge through edge detection.

[0102] See Figure 4 As shown, the area of ​​the clipping box is larger than the area of ​​the guide box, and the geometric center of the clipping box is the same as the geometric center of the guide box.

[0103] In an optional implementation, generating the cropping box based on the image coordinates includes:

[0104] Obtain the first specified coordinate and the second specified coordinate from the image coordinates;

[0105] The first specified coordinate is moved a preset first distance along a preset first moving direction to obtain the target first specified coordinate;

[0106] The second specified coordinate is moved a preset second distance along a preset second moving direction to obtain the target second specified coordinate;

[0107] The cropping frame is generated based on the first specified coordinates and the second specified coordinates of the target.

[0108] Wherein, the first specified coordinate can be the coordinate of the top left vertex of the guide box image coordinate, and the second specified coordinate can be the coordinate of the bottom right vertex of the guide box image coordinate.

[0109] The preset first moving direction can be the upper left direction, and the preset second moving direction can be the lower right direction.

[0110] The preset first distance may be the same as or different from the preset second distance; the present invention does not impose any specific restrictions on this.

[0111] Once the first and second specified coordinates of the target are determined, the first specified coordinates of the target can be used as the coordinates of the top left vertex of the cropping box, and the second specified coordinates of the target can be used as the coordinates of the bottom right vertex of the cropping box. Thus, the position of the cropping box can be determined based on the coordinates of the top left and bottom right vertex of the cropping box, and the area corresponding to the cropping box can be used as the detection area.

[0112] In some implementations, movement of a first specified coordinate along a preset first movement direction and movement of a second specified coordinate along a preset second movement direction can be achieved according to the following formulas:

[0113] The first specified coordinate of the target is newP1 = P1 – D1;

[0114] The second specified coordinate of the target is newP2 = P2 + D2;

[0115] Wherein, D1 is the preset first distance, D2 is the preset second distance, P1 is the first specified coordinate in the image coordinates of the guide box, P2 is the second specified coordinate in the image coordinates of the guide box, newP1 is the first specified coordinate of the target, and newP2 is the second specified coordinate of the target.

[0116] In some implementations, the preset first distance and preset second distance cannot be set too small. If they are too small, the edges of the image under test will be indistinct, thus affecting the accuracy of recognition. If the preset first distance and preset second distance are set too large, the background will be too large, which will also affect the accuracy of recognition.

[0117] For example, assuming that both the preset first distance and the preset second distance are 20 pixels, moving the first specified coordinate by 20 pixels along the preset first moving direction and moving the second specified coordinate by 20 pixels along the preset second moving direction will result in the following cropping box coordinates:

[0118] Top left: (xxx1, yyy1) = (xx1-20, yy1-20);

[0119] Top right: (xxx2, yyy2) = (xx2+20, yy2-20);

[0120] Bottom right: (xxx3, yyy3) = (xx3+20, yy3+20);

[0121] Bottom left: (xxx4, yyy4) = (xx4-20, yy4+20).

[0122] In the above optional implementation, the guide frame is moved bidirectionally along a preset first movement direction using the lower left vertex coordinate of the guide frame in the image coordinate system, and along a preset second movement direction using the upper right vertex coordinate of the guide frame in the image coordinate system, thereby expanding the guide frame. The cropping frame obtained by the bidirectional expansion of the guide frame is used to detect the image under test, which effectively improves the accuracy of detecting the cropped edges of the image under test.

[0123] S24, crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image.

[0124] Electronic devices can call an Application Programming Interface (API) to crop the region corresponding to the cropping box in the image under test. An API is defined as a standard set of information and commands that an application can use to exchange with a computer operating system.

[0125] In practice, the coordinates of the four vertices of the cropping frame (xxx1, yyy1), (xxx2, yyy2), (xxx3, yyy3), and (xxx4, yyy4) are used as input parameters for the application programming interface (API) of the cropping image. This allows the API to determine the cropping frame based on the input coordinates of the four vertices and crop the image as the cropped image.

[0126] S25, determine whether the cropped image has a cut edge based on the cropping frame.

[0127] After obtaining the cropped image, edge detection can be performed on the cropped image to obtain the edge coordinates of the cropped image. By judging the size relationship between the edge coordinates and the image coordinates of the cropping box, it can be determined whether the target to be tested is within the cropping box, that is, whether the cropped image has a cut edge.

[0128] In an optional implementation, determining whether the cropped image has a cut edge based on the cropping frame includes:

[0129] Generate a detection box based on the cropping box;

[0130] Obtain multiple edge coordinates of the target object in the cropped image;

[0131] Determine whether each of the plurality of edge coordinates is within the detection box;

[0132] When each of the plurality of edge coordinates is determined to be within the detection box, it is determined that the cropped image has no cut edges;

[0133] When it is determined that at least one of the multiple edge coordinates is not within the detection box, it is determined that the cropped image has a cut edge.

[0134] When determining whether the multiple edge coordinates of the target in the cropped image are within the cropping box, a detection box needs to be generated based on the cropping box to leave a certain buffer space. This prevents the target from being captured if it is close to the cropping box and slightly outside the cropping box, which would increase the difficulty of shooting and reduce the user experience.

[0135] The area of ​​the detection frame is larger than the area of ​​the clipping frame, and the geometric center of the detection frame is the same as the geometric center of the clipping frame.

[0136] When all of the multiple edge coordinates are within the detection box, it indicates that the target is within the detection box, and the cropped image is determined to have no cut edges. When one or more of the multiple edge coordinates are not within the detection box, it indicates that the target is not completely within the detection box, and the cropped image is determined to have cut edges.

[0137] In an optional implementation, generating a detection box based on the cropping box includes:

[0138] Obtain the third and fourth specified coordinates from the image coordinates of the cropping frame;

[0139] The third specified coordinate is moved along a preset third moving direction by a preset third distance to obtain the target third specified coordinate;

[0140] The fourth specified coordinate is moved along the preset fourth moving direction by a preset fourth distance to obtain the target fourth specified coordinate;

[0141] The detection box is generated based on the third and fourth specified coordinates of the target.

[0142] The image coordinates of the cropping frame are obtained by extending the image coordinates of the guide frame, for example, the coordinates of the four vertices (xxx1, yyy1), (xxx2, yyy2), (xxx3, yyy3), and (xxx4, yyy4) in the above embodiment. The third specified coordinate can be the coordinate of the upper left vertex of the cropping frame image coordinates, and the fourth specified coordinate can be the coordinate of the lower right vertex of the cropping frame image coordinates.

[0143] The preset third moving direction can be the upper left direction, and the preset fourth moving direction can be the lower right direction.

[0144] The preset third distance may be the same as or different from the preset fourth distance; this invention does not impose specific limitations on this. The preset third distance is smaller than the preset first distance, and the preset fourth distance is smaller than the preset second distance. In some embodiments, both the preset third distance and the preset fourth distance are smaller than the preset first distance and both are smaller than the preset second distance.

[0145] Once the third and fourth specified coordinates of the target are determined, the third specified coordinate can be used as the coordinates of the top-left vertex of the detection box, and the fourth specified coordinate can be used as the coordinates of the bottom-right vertex of the detection box. Thus, the position of the detection box can be determined based on the coordinates of the top-left and bottom-right vertex of the detection box.

[0146] In some implementations, movement of a third specified coordinate along a preset third movement direction and movement of a fourth specified coordinate along a preset second movement direction can be achieved according to the following formulas:

[0147] The target's third specified coordinates are newP3 = P3 – D3;

[0148] The fourth target is specified to have coordinates newP4 = P4 + D4;

[0149] Where D3 is the preset third distance, D4 ​​is the preset fourth distance, P3 is the third specified coordinate in the image coordinates of the cropping box, P4 is the fourth specified coordinate in the image coordinates of the cropping box, newP3 is the third specified coordinate of the target, and newP4 is the fourth specified coordinate of the target.

[0150] For example, assuming that both the preset third distance and the preset fourth distance are 10 pixels, moving the third specified coordinate by 10 pixels along the preset third moving direction and moving the fourth specified coordinate by 10 pixels along the preset fourth moving direction will result in the following coordinates of the detection box:

[0151] Top left: (xxxx1, yyyy1) = (xxx1-10, yyy1-10);

[0152] Top right: (xxxx2, yyyy2) = (xxx2+10, yyy2-10);

[0153] Bottom right: (xxxx3, yyyy3) = (xxx3 + 10, yyy3 + 10);

[0154] Bottom left: (xxxx4, yyyy4) = (xxx4-10, yyy4+10).

[0155] Assume the coordinates of multiple edges of the target object in the cropped image are as follows:

[0156] Top left: (tx1, ty1);

[0157] Top right: (tx2, ty2);

[0158] Bottom right: (tx3, ty3);

[0159] Lower left: (tx4, ty4);

[0160] Therefore, when the following formula is satisfied, it indicates that each of the multiple edge coordinates is within the detection box:

[0161] Top left: tx1>xxxx1; ty1>yyyy1;

[0162] Top right: tx2<xxxx2;ty2> yyyy2;

[0163] Bottom right: tx3 <xxxx3;ty3<yyyy3;

[0164] Lower left: tx4<xxxx4;ty4> yyyy4.

[0165] When the cropping image is identified as having no cut edges based on the cropping frame, S26 is executed; when the cropping image is identified as having cut edges based on the cropping frame, S27 is executed.

[0166] S26, the cropped image is determined as the target image of the target to be tested.

[0167] When the cropping image is identified as having no cut edges according to the cropping frame, it indicates that the cropping image is complete and qualified. The electronic device then determines the cropping image as the target image of the target to be tested and stores it in the local database or sends it to other electronic devices.

[0168] S27, a preset prompt text is displayed on the shooting interface.

[0169] When the cropping frame identifies that the cropped image has a cut edge, it indicates that the cropped image is incomplete and unqualified. In this case, the electronic device can display a preset prompt text on the shooting interface after cropping the image.

[0170] The preset prompt text is a pre-set message used to inform the user that the image obtained from the test target is not up to standard and that it is necessary to re-acquire the test image of the test target and obtain a target image that meets the requirements based on the re-acquired test image.

[0171] In an optional implementation, when the cropping frame identifies that the cropped image has a cut edge, the electronic device can prompt the user to adjust the electronic device so that the target to be tested is displayed within the guide frame of the shooting interface.

[0172] In this embodiment of the invention, a cropping frame is obtained by displaying a guide frame on the shooting interface and expanding it outward, so that the edge detection has reference point coordinates. The cropping frame is then used to crop the image of the target to be tested. Finally, images with cropped edges are filtered out by detecting whether the edge coordinates of the cropped image are within the cropping frame, which effectively avoids the problem of low cropping accuracy caused by the diversity of shooting scenes.

[0173] In an optional implementation, the method further includes:

[0174] Optical character recognition is performed on the target image to obtain multiple target strings;

[0175] Generate a first string image based on each of the target strings;

[0176] The target image is cut into characters to obtain multiple second string images;

[0177] A difference image is calculated based on each of the first string images and the corresponding second string images;

[0178] Each of the difference images is compared with a preset threshold to obtain a comparison result;

[0179] The optical character recognition result is obtained based on the comparison results.

[0180] After obtaining multiple target strings, the electronic device can retrieve a similarity character table from a local database, search for similar characters with a predetermined similarity to each target string in the similarity character table, and generate a first string image based on the retrieved similar characters. The similarity character table stores multiple characters and similar characters with a predetermined similarity to each character.

[0181] When the pixel value in the difference image is less than or equal to a preset threshold, it is determined that the character in the second string image matches the target character in the corresponding first string image, and the target character in the first string image is used as the optical character recognition result. When the pixel value in the difference image is greater than the preset threshold, it is determined that the character in the second string image does not match the target character in the corresponding first string image, and the target character in the first string image can be displayed on the electronic device and highlighted to prompt the user for confirmation.

[0182] The above-described embodiments combine optical character recognition and image comparison, which can effectively improve the accuracy of optical character recognition and eliminate the need for a large number of character templates, thus improving the efficiency of optical character recognition.

[0183] Example 2

[0184] Figure 5 This is a structural diagram of the image acquisition device for avoiding edge cutting provided in Embodiment 2 of the present invention.

[0185] In some embodiments, the image acquisition device 50 that avoids edge cropping may include multiple functional modules composed of computer program segments. The computer programs for each program segment in the image acquisition device 50 that avoids edge cropping may be stored in the memory of an electronic device and executed by at least one processor to perform (see details). Figure 5 (Description) Functionality to avoid cropped edges in image acquisition.

[0186] In this embodiment, the image acquisition device 50 that avoids edge cropping can be divided into multiple functional modules according to its function. These functional modules may include: a display module 501, a conversion module 502, a generation module 503, a cropping module 504, a judgment module 505, and a recognition module 506. The module referred to in this invention is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0187] The display module 501 is used to display a guide box on the shooting interface and capture the image of the target to be tested in the shooting interface in real time.

[0188] The target to be tested refers to the object that needs to be edge-checked, and the image to be tested is the image obtained by photographing the target to be tested. The target to be tested can be a certificate or document used to prove identity, experience, etc., such as an ID card, driver's license, Hong Kong and Macao travel permit, passport, accounting certificate, work permit, student ID, graduation certificate, health certificate, etc.

[0189] When this invention is applied to the field of digital healthcare, the target to be tested also includes medical insurance cards, various data generated during the diagnosis and treatment process, etc.

[0190] When identifying the content of a target object, an image of the target object can be captured first, and then optical character recognition (OCR) technology can be used to identify the content of the target object. Before performing OCR on the image, it can be determined whether the image has cropped edges to determine its completeness. Detecting cropped edges in an image is mostly done using detection models. However, some targets have less obvious features; for example, a Hong Kong and Macau travel permit, whose back is almost entirely text, may have cropped edges even if the image shows them. Figure 1 The detection model can be used to detect images of Hong Kong and Macao travel permits, and the detection results are normal, meaning that the detection results show that the images of Hong Kong and Macao travel permits are complete and have no cropped edges.

[0191] In existing technologies, the low detection accuracy of the aforementioned detection models is generally addressed by optimizing the model through extensive training and parameter adjustments. However, the optimization process is very time-consuming, resulting in low efficiency in edge detection. Furthermore, due to the diverse shooting scenarios for ID card images, the optimized detection model is difficult to apply to all complex shooting scenarios, leading to poor practicality.

[0192] This embodiment uses a guide frame to capture or acquire the image of the target to be tested, so that the edge detection of the image to be tested has a reference coordinate, thereby inferring whether the image to be tested has a cut edge.

[0193] In an optional implementation, displaying the guide box on the shooting interface includes:

[0194] The shooting interface displays multiple preset target type options;

[0195] Detect whether the multiple preset target type options have received a selection instruction;

[0196] The guide box corresponding to the preset target type option that receives the selected instruction will be displayed on the shooting interface.

[0197] Users can trigger the camera function of an electronic device by touching or clicking it. After the camera function is activated, the electronic device displays the shooting interface, which includes a guide box.

[0198] like Figure 3 As shown, the electronic device captures a full-screen image and generates and displays a guide box in the shooting interface. This guide box can be rectangular. Displaying the guide box guides the user to adjust the electronic device so that the target being tested is displayed within the guide box.

[0199] When displaying the shooting interface, the electronic device also displays multiple preset target type options within the shooting interface, allowing the user to select any one of these options. The size of the guide box displayed on the shooting interface is then determined based on the user's selected preset target type option. These multiple preset target type options can be displayed in a list format or as virtual buttons; this invention does not impose any limitations. The multiple preset target type options may include, but are not limited to: ID card, driver's license, Hong Kong and Macau travel permit, passport, accounting certificate, work permit, student ID, graduation certificate, health certificate, medical insurance card, etc. Different target type options correspond to different sized guide boxes. For example, when the target type option is an ID card, the aspect ratio of the guide box is the same as that of the ID card document; when the target type option is a health certificate, the aspect ratio of the guide box is the same as that of the health certificate document.

[0200] The conversion module 502 is used to obtain the screen coordinates of the guide frame and convert the screen coordinates into image coordinates according to the image to be tested.

[0201] The screen coordinates of the guide frame are the coordinates of the guide frame in the display screen coordinate system. Converting the screen coordinates of the guide frame to image coordinates means converting the coordinates of the guide frame in the display screen coordinate system into image coordinates in the camera coordinate system.

[0202] Since the guide frame is displayed on the screen of the electronic device, its coordinates are actually the coordinates of the screen. The size of the image of the target being measured captured by the camera of the electronic device differs from the size of the screen. Therefore, it is necessary to convert the screen coordinates of the guide frame into image coordinates (i.e., camera coordinates).

[0203] The display screen coordinate system is based on the top-left corner of the electronic device's screen, with the origin (0, 0). Horizontal movement to the right represents the positive X-direction, and vertical movement downwards represents the positive Y-direction. The electronic device can obtain the screen coordinates of the guide box by calling the `getLocationOnScreen` method.

[0204] In an optional implementation, converting the screen coordinates into image coordinates based on the image to be tested includes:

[0205] The coordinate transformation factor is determined based on the size of the display screen and the size of the image to be tested;

[0206] The screen coordinates are converted into image coordinates according to the coordinate transformation factor.

[0207] The size of the display screen of an electronic device refers to the actual size of the display screen, which can be obtained from the system parameters of the electronic device.

[0208] The size of the image to be tested refers to the size of the image captured by the camera of the electronic device. The size of the image to be tested can be determined by parameters transmitted from the camera to the electronic device, such as sharpness. The sharper the image to be tested, the larger the image to be tested; the blurrier the image to be tested, the smaller the image to be tested.

[0209] The coordinate transformation factor scale can be calculated using the following formula:

[0210] scale = size of the image to be measured / size of the display screen.

[0211] The image coordinates of the guide box are calculated by multiplying the coordinate transformation factor and the screen coordinates.

[0212] For example, suppose the screen coordinates of the four vertices of the guide box are:

[0213] Top left: (x1, y1);

[0214] Top right: (x2, y2);

[0215] Bottom right: (x3, y3);

[0216] Bottom left: (x4, y4).

[0217] The image coordinates of the guide box in the camera coordinate system are:

[0218] Top left: (xx1, yy1) = (x1*scale, y1*scale);

[0219] Upper right: (xx2, yy2) = (x2*scale, y2*scale);

[0220] Lower right: (xx3, yy3) = (x3*scale, y3*scale);

[0221] Bottom left: (xx4, yy4) = (x4*scale, y4*scale).

[0222] The generation module 503 is used to generate a cropping box based on the image coordinates.

[0223] The cropping frame is obtained by expanding the guide frame outward based on the image coordinates of the guide frame in the camera coordinate system. If the guide frame is not expanded outward, even if the image to be tested has a cropped edge, the coordinates of the cropped edge will be within the range of the guide frame, making it impossible to determine whether the image to be tested has a cropped edge through edge detection.

[0224] See Figure 4 As shown, the area of ​​the clipping box is larger than the area of ​​the guide box, and the geometric center of the clipping box is the same as the geometric center of the guide box.

[0225] In an optional implementation, generating the cropping box based on the image coordinates includes:

[0226] Obtain the first specified coordinate and the second specified coordinate from the image coordinates;

[0227] The first specified coordinate is moved a preset first distance along a preset first moving direction to obtain the target first specified coordinate;

[0228] The second specified coordinate is moved a preset second distance along a preset second moving direction to obtain the target second specified coordinate;

[0229] The cropping frame is generated based on the first specified coordinates and the second specified coordinates of the target.

[0230] Wherein, the first specified coordinate can be the coordinate of the top left vertex of the guide box image coordinate, and the second specified coordinate can be the coordinate of the bottom right vertex of the guide box image coordinate.

[0231] The preset first moving direction can be the upper left direction, and the preset second moving direction can be the lower right direction.

[0232] The preset first distance may be the same as or different from the preset second distance; the present invention does not impose any specific restrictions on this.

[0233] Once the first and second specified coordinates of the target are determined, the first specified coordinates of the target can be used as the coordinates of the top left vertex of the cropping box, and the second specified coordinates of the target can be used as the coordinates of the bottom right vertex of the cropping box. Thus, the position of the cropping box can be determined based on the coordinates of the top left and bottom right vertex of the cropping box, and the area corresponding to the cropping box can be used as the detection area.

[0234] In some implementations, movement of a first specified coordinate along a preset first movement direction and movement of a second specified coordinate along a preset second movement direction can be achieved according to the following formulas:

[0235] The first specified coordinate of the target is newP1 = P1 – D1;

[0236] The second specified coordinate of the target is newP2 = P2 + D2;

[0237] Wherein, D1 is the preset first distance, D2 is the preset second distance, P1 is the first specified coordinate in the image coordinates of the guide box, P2 is the second specified coordinate in the image coordinates of the guide box, newP1 is the first specified coordinate of the target, and newP2 is the second specified coordinate of the target.

[0238] In some implementations, the preset first distance and preset second distance cannot be set too small. If they are too small, the edges of the image under test will be indistinct, thus affecting the accuracy of recognition. If the preset first distance and preset second distance are set too large, the background will be too large, which will also affect the accuracy of recognition.

[0239] For example, assuming that both the preset first distance and the preset second distance are 20 pixels, moving the first specified coordinate by 20 pixels along the preset first moving direction and moving the second specified coordinate by 20 pixels along the preset second moving direction will result in the following cropping box coordinates:

[0240] Top left: (xxx1, yyy1) = (xx1-20, yy1-20);

[0241] Top right: (xxx2, yyy2) = (xx2+20, yy2-20);

[0242] Bottom right: (xxx3, yyy3) = (xx3+20, yy3+20);

[0243] Bottom left: (xxx4, yyy4) = (xx4-20, yy4+20).

[0244] In the above optional implementation, the guide frame is moved bidirectionally along a preset first movement direction using the lower left vertex coordinate of the guide frame in the image coordinate system, and along a preset second movement direction using the upper right vertex coordinate of the guide frame in the image coordinate system, thereby expanding the guide frame. The cropping frame obtained by the bidirectional expansion of the guide frame is used to detect the image under test, which effectively improves the accuracy of detecting the cropped edges of the image under test.

[0245] The cropping module 504 is used to crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image.

[0246] Electronic devices can call an Application Programming Interface (API) to crop the region corresponding to the cropping box in the image under test. An API is defined as a standard set of information and commands that an application can use to exchange with a computer operating system.

[0247] In practice, the coordinates of the four vertices of the cropping frame (xxx1, yyy1), (xxx2, yyy2), (xxx3, yyy3), and (xxx4, yyy4) are used as input parameters for the application programming interface (API) of the cropping image. This allows the API to determine the cropping frame based on the input coordinates of the four vertices and crop the image as the cropped image.

[0248] The judgment module 505 is used to determine whether the cropped image has a cut edge based on the cropping frame.

[0249] After obtaining the cropped image, edge detection can be performed on the cropped image to obtain the edge coordinates of the cropped image. By judging the size relationship between the edge coordinates and the image coordinates of the cropping box, it can be determined whether the target to be tested is within the cropping box, that is, whether the cropped image has a cut edge.

[0250] In an optional implementation, determining whether the cropped image has a cut edge based on the cropping frame includes:

[0251] Generate a detection box based on the cropping box;

[0252] Obtain multiple edge coordinates of the target object in the cropped image;

[0253] Determine whether each of the plurality of edge coordinates is within the detection box;

[0254] When each of the plurality of edge coordinates is determined to be within the detection box, it is determined that the cropped image has no cut edges;

[0255] When it is determined that at least one of the multiple edge coordinates is not within the detection box, it is determined that the cropped image has a cut edge.

[0256] When determining whether the multiple edge coordinates of the target in the cropped image are within the cropping box, a detection box needs to be generated based on the cropping box to leave a certain buffer space. This prevents the target from being captured if it is close to the cropping box and slightly outside the cropping box, which would increase the difficulty of shooting and reduce the user experience.

[0257] The area of ​​the detection frame is larger than the area of ​​the clipping frame, and the geometric center of the detection frame is the same as the geometric center of the clipping frame.

[0258] When all of the multiple edge coordinates are within the detection box, it indicates that the target is within the detection box, and the cropped image is determined to have no cut edges. When one or more of the multiple edge coordinates are not within the detection box, it indicates that the target is not completely within the detection box, and the cropped image is determined to have cut edges.

[0259] In an optional implementation, generating a detection box based on the cropping box includes:

[0260] Obtain the third and fourth specified coordinates from the image coordinates of the cropping frame;

[0261] The third specified coordinate is moved along a preset third moving direction by a preset third distance to obtain the target third specified coordinate;

[0262] The fourth specified coordinate is moved along the preset fourth moving direction by a preset fourth distance to obtain the target fourth specified coordinate;

[0263] The detection box is generated based on the third and fourth specified coordinates of the target.

[0264] The image coordinates of the cropping frame are obtained by extending the image coordinates of the guide frame, for example, the coordinates of the four vertices (xxx1, yyy1), (xxx2, yyy2), (xxx3, yyy3), and (xxx4, yyy4) in the above embodiment. The third specified coordinate can be the coordinate of the upper left vertex of the cropping frame image coordinates, and the fourth specified coordinate can be the coordinate of the lower right vertex of the cropping frame image coordinates.

[0265] The preset third moving direction can be the upper left direction, and the preset fourth moving direction can be the lower right direction.

[0266] The preset third distance may be the same as or different from the preset fourth distance; this invention does not impose specific limitations on this. The preset third distance is smaller than the preset first distance, and the preset fourth distance is smaller than the preset second distance. In some embodiments, both the preset third distance and the preset fourth distance are smaller than the preset first distance and both are smaller than the preset second distance.

[0267] Once the third and fourth specified coordinates of the target are determined, the third specified coordinate can be used as the coordinates of the top-left vertex of the detection box, and the fourth specified coordinate can be used as the coordinates of the bottom-right vertex of the detection box. Thus, the position of the detection box can be determined based on the coordinates of the top-left and bottom-right vertex of the detection box.

[0268] In some implementations, movement of a third specified coordinate along a preset third movement direction and movement of a fourth specified coordinate along a preset second movement direction can be achieved according to the following formulas:

[0269] The target's third specified coordinates are newP3 = P3 – D3;

[0270] The fourth target is specified to have coordinates newP4 = P4 + D4;

[0271] Where D3 is the preset third distance, D4 ​​is the preset fourth distance, P3 is the third specified coordinate in the image coordinates of the cropping box, P4 is the fourth specified coordinate in the image coordinates of the cropping box, newP3 is the third specified coordinate of the target, and newP4 is the fourth specified coordinate of the target.

[0272] For example, assuming that both the preset third distance and the preset fourth distance are 10 pixels, moving the third specified coordinate by 10 pixels along the preset third moving direction and moving the fourth specified coordinate by 10 pixels along the preset fourth moving direction will result in the following coordinates of the detection box:

[0273] Top left: (xxxx1, yyyy1) = (xxx1-10, yyy1-10);

[0274] Top right: (xxxx2, yyyy2) = (xxx2+10, yyy2-10);

[0275] Bottom right: (xxxx3, yyyy3) = (xxx3 + 10, yyy3 + 10);

[0276] Bottom left: (xxxx4, yyyy4) = (xxx4-10, yyy4+10).

[0277] Assume the coordinates of multiple edges of the target object in the cropped image are as follows:

[0278] Top left: (tx1, ty1);

[0279] Top right: (tx2, ty2);

[0280] Bottom right: (tx3, ty3);

[0281] Lower left: (tx4, ty4);

[0282] Therefore, when the following formula is satisfied, it indicates that each of the multiple edge coordinates is within the detection box:

[0283] Top left: tx1>xxxx1; ty1>yyyy1;

[0284] Top right: tx2<xxxx2;ty2> yyyy2;

[0285] Bottom right: tx3 <xxxx3;ty3<yyyy3;

[0286] Lower left: tx4<xxxx4;ty4> yyyy4.

[0287] The cropping module 504 is further configured to determine the cropped image as the target image of the target to be tested when the cropped image is identified as having no cut edges according to the cropping frame.

[0288] When the cropping image is identified as having no cut edges according to the cropping frame, it indicates that the cropping image is complete and qualified. The electronic device then determines the cropping image as the target image of the target to be tested and stores it in the local database or sends it to other electronic devices.

[0289] The display module 501 is also used to display a preset prompt text on the shooting interface when the cropped image is identified to have a cropped edge according to the cropping frame.

[0290] When the cropping frame identifies that the cropped image has a cut edge, it indicates that the cropped image is incomplete and unqualified. In this case, the electronic device can display a preset prompt text on the shooting interface after cropping the image.

[0291] The preset prompt text is a pre-set message used to inform the user that the image obtained from the test target is not up to standard and that it is necessary to re-acquire the test image of the test target and obtain a target image that meets the requirements based on the re-acquired test image.

[0292] In an optional implementation, when the cropping frame identifies that the cropped image has a cut edge, the electronic device can prompt the user to adjust the electronic device so that the target to be tested is displayed within the guide frame of the shooting interface.

[0293] In this embodiment of the invention, a cropping frame is obtained by displaying a guide frame on the shooting interface and expanding it outward, so that the edge detection has reference point coordinates. The cropping frame is then used to crop the image of the target to be tested. Finally, images with cropped edges are filtered out by detecting whether the edge coordinates of the cropped image are within the cropping frame, which effectively avoids the problem of low cropping accuracy caused by the diversity of shooting scenes.

[0294] The recognition module 506 is used to perform optical character recognition on the target image to obtain optical character recognition results.

[0295] In an optional implementation, the recognition module 506 performs optical character recognition on the target image to obtain optical character recognition results including:

[0296] Optical character recognition is performed on the target image to obtain multiple target strings;

[0297] Generate a first string image based on each of the target strings;

[0298] The target image is cut into characters to obtain multiple second string images;

[0299] A difference image is calculated based on each of the first string images and the corresponding second string images;

[0300] Each of the difference images is compared with a preset threshold to obtain a comparison result;

[0301] The optical character recognition result is obtained based on the comparison results.

[0302] After obtaining multiple target strings, the electronic device can retrieve a similarity character table from a local database, search for similar characters with a predetermined similarity to each target string in the similarity character table, and generate a first string image based on the retrieved similar characters. The similarity character table stores multiple characters and similar characters with a predetermined similarity to each character.

[0303] When the pixel value in the difference image is less than or equal to a preset threshold, it is determined that the character in the second string image matches the target character in the corresponding first string image, and the target character in the first string image is used as the optical character recognition result. When the pixel value in the difference image is greater than the preset threshold, it is determined that the character in the second string image does not match the target character in the corresponding first string image, and the target character in the first string image can be displayed on the electronic device and highlighted to prompt the user for confirmation.

[0304] The above-described embodiments combine optical character recognition and image comparison, which can effectively improve the accuracy of optical character recognition and eliminate the need for a large number of character templates, thus improving the efficiency of optical character recognition.

[0305] Example 3

[0306] This embodiment provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the steps in the above-described embodiment of the image acquisition method for avoiding edge cropping. Figure 2 S21-S27 shown:

[0307] S21, Display a guide box on the shooting interface and capture the image of the target to be tested in the shooting interface in real time;

[0308] S22, obtain the screen coordinates of the guide box, and convert the screen coordinates into image coordinates according to the image to be tested;

[0309] S23, Generate a cropping box based on the image coordinates;

[0310] S24, crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image;

[0311] S25, determine whether the cropped image has a cut edge based on the cropping frame;

[0312] When the cropping image is identified as having no cut edges based on the cropping frame, step S26 is executed to determine the cropping image as the target image of the target to be tested.

[0313] When the cropping frame identifies that the cropped image has a cut edge, S27 is executed, and a preset prompt text is displayed on the shooting interface.

[0314] Alternatively, when the computer program is executed by the processor, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 5 Modules 501-506 in the document:

[0315] The display module 501 is used to display a guide box on the shooting interface and capture the image of the target to be tested in the shooting interface in real time.

[0316] The conversion module 502 is used to obtain the screen coordinates of the guide box and convert the screen coordinates into image coordinates according to the image to be tested;

[0317] The generation module 503 is used to generate a cropping box based on the image coordinates;

[0318] The cropping module 504 is used to crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image;

[0319] The judgment module 505 is used to determine whether the cropped image has a cut edge based on the cropping frame;

[0320] The cropping module 504 is further configured to determine the cropped image as the target image of the target to be tested when the cropped image is identified as having no cut edges according to the cropping frame.

[0321] The recognition module 506 is used to perform optical character recognition on the target image to obtain optical character recognition results.

[0322] Example 4

[0323] See Figure 6 The diagram shown is a structural schematic of an electronic device provided in an embodiment of the present invention. In a preferred embodiment of the present invention, the electronic device 6 includes a memory 61, at least one processor 62, at least one communication bus 63, and a transceiver 64.

[0324] Those skilled in the art should understand that Figure 6 The structure of the electronic device shown does not constitute a limitation of the embodiments of the present invention. It can be a bus structure or a star structure. The electronic device 6 may also include more or fewer other hardware or software than shown, or different component arrangements.

[0325] In some embodiments, the electronic device 6 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital processors, and embedded devices. The electronic device 6 may also include client devices, including, but not limited to, any electronic product capable of human-computer interaction with a client via a keyboard, mouse, remote control, touchpad, or voice control device, such as personal computers, tablets, smartphones, and digital cameras.

[0326] The electronic device 6 described herein is merely an example. Other existing or future electronic products that are adaptable to this invention should also be included within the scope of protection of this invention and are incorporated herein by reference.

[0327] In some embodiments, the memory 61 stores a computer program that, when executed by the at least one processor 62, implements all or part of the steps in the image acquisition method for avoiding edge clipping as described. The memory 61 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0328] Furthermore, the computer-readable storage medium may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system, at least one application required for a function, etc.; and the data storage area may store data created based on the use of blockchain nodes, etc.

[0329] The blockchain referred to in this invention is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.

[0330] In some embodiments, the at least one processor 62 is the control unit of the electronic device 6, connecting various components of the electronic device 6 via various interfaces and lines. It executes programs or modules stored in the memory 61 and calls data stored in the memory 61 to perform various functions and process data. For example, when the at least one processor 62 executes a computer program stored in the memory, it implements all or part of the steps of the image acquisition method for avoiding edge cropping described in this embodiment of the invention; or it implements all or part of the functions of the image acquisition device for avoiding edge cropping. The at least one processor 62 may be composed of integrated circuits, such as a single-packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.

[0331] In some embodiments, the at least one communication bus 63 is configured to enable communication between the memory 61 and the at least one processor 62, etc.

[0332] Although not shown, the electronic device 6 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 62 via a power management device, thereby enabling functions such as charging, discharging, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 6 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0333] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) or processor to execute portions of the methods described in the various embodiments of the present invention.

[0334] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0335] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0336] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0337] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other elements, and the singular does not exclude the plural. Multiple elements or devices recited in the specification may also be implemented by a single element or device in software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.

[0338] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. An image acquisition method that avoids edge trimming, characterized in that, The method includes: A guide box is displayed on the shooting interface, and the image of the target to be tested in the shooting interface is captured in real time. Obtain the screen coordinates of the guide box, and convert the screen coordinates into image coordinates based on the image to be tested; Obtain a first specified coordinate and a second specified coordinate from the image coordinates; move the first specified coordinate along a preset first moving direction by a preset first distance to obtain a target first specified coordinate; move the second specified coordinate along a preset second moving direction by a preset second distance to obtain a target second specified coordinate; generate a cropping box based on the target first specified coordinate and the target second specified coordinate, wherein the area of ​​the cropping box is larger than the area of ​​the guide box, and the geometric center of the cropping box is the same as the geometric center of the guide box; The region corresponding to the cropping box in the image to be tested is cropped to obtain a cropped image; Obtain the third and fourth specified coordinates from the image coordinates of the cropping frame; move the third specified coordinates along a preset third moving direction by a preset third distance to obtain the target third specified coordinates; move the fourth specified coordinates along a preset fourth moving direction by a preset fourth distance to obtain the target fourth specified coordinates; generate a detection frame based on the target third and fourth specified coordinates, wherein the area of ​​the detection frame is larger than the area of ​​the cropping frame, and the geometric center of the detection frame is the same as the geometric center of the cropping frame; obtain multiple edge coordinates of the target in the image to be tested; determine whether each edge coordinate is within the detection frame; when it is determined that each edge coordinate is within the detection frame, determine that the cropped image has no cut edges, and determine the cropped image as the target image of the target; when it is determined that at least one edge coordinate is not within the detection frame, determine that the cropped image has cut edges, and display a preset prompt text on the shooting interface.

2. The image acquisition method for avoiding edge trimming as described in claim 1, characterized in that, The step of converting the screen coordinates into image coordinates based on the image to be tested includes: The coordinate transformation factor is determined based on the size of the display screen and the size of the image to be tested; The screen coordinates are converted into image coordinates according to the coordinate transformation factor.

3. The image acquisition method for avoiding edge trimming as described in any one of claims 1 to 2, characterized in that, The method further includes: Optical character recognition is performed on the target image to obtain multiple target strings; Generate a first string image based on each of the target strings; The target image is cut into characters to obtain multiple second string images; A difference image is calculated based on each of the first string images and the corresponding second string images; Each of the difference images is compared with a preset threshold to obtain a comparison result; The optical character recognition result is obtained based on the comparison results.

4. The image acquisition method for avoiding edge trimming as described in any one of claims 1 to 2, characterized in that, The display of the guide box on the shooting interface includes: The shooting interface displays multiple preset target type options; Detect whether the multiple preset target type options have received a selection instruction; The guide box corresponding to the preset target type option that receives the selected instruction will be displayed in the shooting interface.

5. An image acquisition device that avoids edge trimming, characterized in that, The device includes: The display module is used to display a guide box on the shooting interface and capture the image of the target to be tested in the shooting interface in real time. The conversion module is used to obtain the screen coordinates of the guide box and convert the screen coordinates into image coordinates according to the image to be tested; A generation module is used to obtain a first specified coordinate and a second specified coordinate in the image coordinates; move the first specified coordinate along a preset first moving direction by a preset first distance to obtain a target first specified coordinate; move the second specified coordinate along a preset second moving direction by a preset second distance to obtain a target second specified coordinate; generate a cropping box based on the target first specified coordinate and the target second specified coordinate, wherein the area of ​​the cropping box is larger than the area of ​​the guide box, and the geometric center of the cropping box is the same as the geometric center of the guide box; The cropping module is used to crop the region corresponding to the cropping box in the image to be tested to obtain a cropped image; The judgment module is used to obtain a third specified coordinate and a fourth specified coordinate in the image coordinates of the cropping box; move the third specified coordinate along a preset third moving direction by a preset third distance to obtain the target third specified coordinate; move the fourth specified coordinate along a preset fourth moving direction by a preset fourth distance to obtain the target fourth specified coordinate; generate a detection box based on the target third specified coordinate and the target fourth specified coordinate, wherein the area of ​​the detection box is larger than the area of ​​the cropping box, and the geometric center of the detection box is the same as the geometric center of the cropping box; obtain multiple edge coordinates of the target in the image to be tested; and determine whether each edge coordinate is within the detection box. The cropping module is further configured to determine that the cropped image does not have a cut edge when each of the plurality of edge coordinates is within the detection box, and to determine the cropped image as the target image of the target to be tested; and to determine that the cropped image has a cut edge when at least one of the plurality of edge coordinates is not within the detection box, and to display a preset prompt text on the shooting interface.

6. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the image acquisition method for avoiding edge cutting as described in any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the image acquisition method for avoiding edge cutting as described in any one of claims 1 to 4.