Method for fast trapezoidal correction of images of biometric photoelectric scanning devices
By manually adjusting the optical path mechanical parameters and generating correction control information, combined with DMA and interrupt priority management, the image distortion problem of biometric photoelectric scanning devices was solved, achieving efficient and low-cost image correction.
Patent Information
- Application Number
- CN202211010822.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-08-23
AI Technical Summary
Existing biometric photoelectric scanning devices suffer from image distortion due to mechanical errors during image correction, especially trapezoidal distortion. Furthermore, the fast correction methods of low-cost devices do not produce high-quality images, resulting in jagged or broken shape distortions.
By manually adjusting the optical path mechanical parameters during the production correction setting stage, the four corners of the fixture image are selected as correction control points, correction control information is generated and saved, and the correction image is calculated and output using a low-cost processor. DMA and interrupt priority are used to manage the image data stream processing.
It achieves efficient correction of image distortion at low cost, avoids image stitching breaks, and improves image quality and processing efficiency.
Smart Images

Figure CN115375575B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of biometric technology, specifically a method for rapid trapezoidal correction of images from biometric photoelectric scanning devices. Background Technology
[0002] The technology of automatically identifying and determining the identity of a person by collecting biometric features such as fingerprints, palm prints, faces, and irises through photoelectric scanning has the advantages of being easy to operate, non-invasive, and fast. It has been widely applied in fields such as security authentication, financial payment, attendance management, and public security criminal investigation. Biometric identification usually involves an electronic device scanning specific parts of the human body to obtain digitized information data, which is then sent to a host computer to extract feature points. The data is then retrieved from a sample database and compared with various pre-stored samples to determine the identity of the person.
[0003] Currently, existing biometric optical scanning devices mainly consist of an optical array, a photoelectric imaging chip, a data processor, a memory, and a host computer interface. The optical array consists of a series of optical lenses, which are mechanically installed in the optical path of the acquisition device to image the light emitted from the scanned part of the human body onto the photosensitive surface of the photoelectric imaging chip. The processor caches the image data output by the photoelectric chip into the memory and then forwards it to the host computer for feature recognition through the host computer interface. Due to mechanical errors in the optical array, the output image always has drum-shaped distortion, pincushion distortion, trapezoidal distortion, and rotational distortion. These distortions can affect each other. When the mechanical parameters are finely adjusted to reduce one type of distortion, the other distortions become more severe, making it difficult to find a solution that minimizes all types of distortion simultaneously.
[0004] In practice, digital image correction technology can correct mechanical errors in the original distorted image and improve image accuracy. For example, matrix multiplication can be used to multiply the distorted image with the correction matrix to achieve image correction. Since generating each pixel of the corrected image requires multiplication of the image width and height product and addition of the image width and height product, a high-end processor with a hardware floating-point multiplier is needed to handle such a large amount of computation. Some existing image correction methods that can achieve low-cost devices mainly use the method of extracting the nearest pixel. The image quality output by this method is not high enough, and the image will have jagged distortion in some areas, or even some broken image distortion. Therefore, a fast trapezoidal correction method for biometric photoelectric scanning devices is proposed to address the above problems. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies and address the issue of rapid image correction methods for low-cost devices, which mainly rely on extracting the nearest pixel, the image quality is not high enough. The image may exhibit jagged distortion in some areas, or even fragmented image distortion. Therefore, this invention proposes a rapid trapezoidal correction method for biometric photoelectric scanning devices.
[0006] The technical solution adopted by this invention to solve its technical problem is: the rapid trapezoidal correction method for images of the biometric photoelectric scanning device of this invention, comprising the following steps:
[0007] S1: During the production correction setting stage, the staff first places a standard fixture on the scanning device, and then uses software on the computer to display the scanned image of the fixture captured by the photoelectric camera chip in real time. The staff manually adjusts the mechanical parameters of the optical path, prioritizing the reduction of drum-shaped distortion, pincushion distortion, and rotational distortion. Trapezoidal distortion does not need much correction. After manually selecting the four corners of the edge trapezoid in the fixture image as four correction control points by clicking the mouse, the coordinates of these correction control points are sent to the scanning device for permanent storage.
[0008] S2: In the stage of generating correction control information, the processor in the scanning device calculates a set of data for image correction based on the saved coordinates of the correction control points, saves it to random access memory, and calls this set of image correction data image correction information. Although the computational load is large when generating image correction information, since these calculations are only performed once when the scanning device is reset and started, a low-cost processor can meet the actual needs. Because the calculated result data, i.e., the image correction information, needs to be repeatedly and quickly retrieved in the scanning image correction output stage, the correction information data needs to be saved to a random access memory that can be read quickly.
[0009] S3: Image correction and output stage. The processor in the scanning device uses image correction information to calculate the distorted image data of the photoelectric camera chip and convert it into an image with acceptable error, which is then output to the host computer or processor. This process is the main function of the scanning device and is executed repeatedly. Because high execution efficiency is required here, there cannot be too many time-consuming complex calculations such as floating-point division.
[0010] Preferably, during the production correction setting stage, the scanning device needs to be connected to the computer, a standard fixture with a size equal to the scanning window size of the device is placed on the scanning device, and production test software is run on the computer to display the fixture image captured by the photoelectric camera chip in real time; the standard fixture is a rectangular plane with square grids on the surface, and some hollow and solid grids are arranged in an alternating pattern to mark the reference position.
[0011] The fixture pattern is mainly composed of hollow areas, which can visually show whether the position of the scanned image is correct. The focus is on observing whether there is obvious distortion in the grid lines. If the grid lines are bent or the square grid is deformed, it indicates that the image has been distorted. When the scanned image is distorted, the grid in this fixture pattern can be used to immediately identify which area of the scanning acquisition optical path the distortion is located in, which can be used to indicate the orientation of the fine-tuning mechanism when correcting mechanical errors.
[0012] The production correction settings first adjust the mechanical position of the optical bench. Although these image distortions are difficult to completely eliminate, the mechanical position should be adjusted as much as possible to reduce distortion. The smaller the distortion reduction by mechanical adjustment, the better it is to improve the quality of the final output correction image. Prioritize reducing drum distortion, pincushion distortion, and rotational distortion, while trapezoidal distortion does not need to be corrected too much. The requirement is to adjust it so that all four vertices of the rectangular fixture are displayed in the scanned image.
[0013] Preferably, the four vertices of the original fixture are A, B, C, and D; in the scanned image transmitted to the computer by the scanning device, the four vertices E, F, G, and H correspond to the four vertices of the original fixture; it is required that the mechanical adjustment makes the EF line and GH line in the scanned image both horizontal straight lines, while the EG line and FH line do not need to be perpendicular, they only need to be straight lines; thus, the image formed by vertices E, F, G, and H is an arbitrary trapezoid with the top and bottom edges in the horizontal direction;
[0014] On the interface of the production testing software, after clicking on the scanned image with the mouse to select the four vertices of the rectangular fixture as correction control points, the production testing software sends the coordinates of these four correction control points on the fixture scanned image to the scanning device, which permanently saves them in the device, thus completing the production correction setting.
[0015] Preferably, in the stage of generating correction control information, the width of the original image acquired by the photoelectric camera chip is W1 and the height is H1; the width of the output image after the original image is reduced and corrected is W2 and the height is H2; the stage of generating correction control information is executed once whenever the scanning device is powered on and reset or when the coordinates of the four correction control points on the jig scanning image are updated.
[0016] The stage of generating correction control information uses the coordinates of the four correction control points stored in the device's jig scan image during the production correction setting stage to calculate a set of correction data, which is then stored in the random access memory of the scanning device. The correction data includes three sets of information: top all-loss data information, horizontal all-loss line information, and trapezoidal horizontal fusion line information.
[0017] The top-level data loss information consists of only one value, denoted by GT, which is equal to the number of pixels above the EF line in the fixture scan image. Although mechanical adjustment is required to make the EF line and GH line in the fixture scan image horizontal, errors will still exist in actual production, namely, the coordinates of point E (E... X E Y ) and the coordinates of point F (F X ,F Y E Y With F Y The values may differ; therefore, the calculation method for discarding all data at the top is as follows:
[0018]
[0019] Similarly, due to the existence of machine model errors, the coordinates of point G (G X G Y ) and H-point coordinates (H X H Y ) of G Y With H Y The numerical values can also differ; the method for calculating the trapezoidal height LN is as follows:
[0020]
[0021] The horizontal line loss information includes three types of data: horizontal line loss count TC, horizontal line loss number array TA, and horizontal line loss marker array TS. The horizontal line loss count TC is a numerical value representing the number of horizontal lines reduced during the vertical scaling of the image. The number of elements in the horizontal line loss number array TA is defined as equal to H1 minus H2, and the actual number of valid data stored is equal to TC. The number of elements in the horizontal line loss marker array TS is defined as equal to H2.
[0022] The trapezoidal horizontal fusion row information includes a one-dimensional pixel coordinate array PS with a member number equal to the width W2 multiplied by the height H2, and an array PL with an element number equal to H2; each element in array PL is a data structure containing two members, namely the row start coordinate SS and the row width WS.
[0023] Preferably, the specific steps for generating the correction control information are as follows:
[0024] A1. Set all elements of the horizontal all-drop row marker array TS to zero, and also set the horizontal all-drop row count TC to zero; calculate the top all-drop data information GT, and the trapezoidal height LN; define a constant XN. Although a larger XN value is more beneficial to improving accuracy, if the number of binary bits of the result XN*H2 exceeds the processor bit width, an overflow will occur; moreover, when XN exceeds 16 times the image width, it no longer significantly improves accuracy; therefore, the value of XN must be limited to not be too large. For example, in a 32-bit processor, XN can be set to 1,000,000.
[0025] A2. Define variables LB, LS, and yTar, and set their initial values to zero.
[0026] A3. Define variable SP and set its initial value to XN;
[0027] A4. Define variables U, V, and W to store temporary intermediate calculation results;
[0028] A5. Define the variable STEP and set its value to ;
[0029]
[0030] A6. After adding STEP to SP, if the value of SP is greater than XN, then execute step A7; otherwise, execute step A11.
[0031] A7. Shift LS left by four bits, then multiply by G. X The result is stored in variable U; after subtracting LS from LN, the result is shifted left by four bits and then multiplied by E. X The result is stored in variable V; then, yTar is used as the index of array PL, denoted by PL[yTar]. The result of adding variable U to variable V and then dividing by LN is stored in the member SS of PL[yTar].
[0032] A8. Shift LS left by four bits, then multiply by H. X The result is stored in variable U; after subtracting LS from LN, the result is shifted left by four bits and then multiplied by F. X Store the result in variable V; calculate the value of U plus V divided by LN and store it in variable W.
[0033] A9. Using yTar as the index of array PL, calculate the value of variable W minus the value of member SS of PL[yTar] and save it to member WS of PL[yTar].
[0034] A10. Subtract XN from SP; increment yTar by 1; then execute A13;
[0035] A11. If the value of yTar is greater than or equal to H2, then proceed directly to A12. Otherwise, first use yTar as the index of the array TS, represented by TS[yTar]. After setting the value of TS[yTar] to 1, then proceed to step A12.
[0036] A12. Array TA with index TC, denoted as TA[TC]. Calculate the value of variable LS minus the value of variable LB and store it in TA[TC]. Then store the value of variable LS in variable LB. Finally, increment the value of the number of horizontally dropped rows TC by 1.
[0037] A13. Compare the size of variables LS and LN. If LS is less than LN, then proceed to step A6; otherwise, proceed to step A14.
[0038] A14. Set the variable yTar to zero and define the variable xTar;
[0039] A15. Set the value of variable xTar to zero;
[0040] A16. In the array PL indexed by yTar, calculate the value of PL[yTar] member WS, multiply it by the variable xTar, divide it by W2, and finally add the value of PL[yTar] member SS, and store it in the variable U.
[0041] A17. Calculate the value of variable yTar multiplied by W2, add it to the value of variable xTar, and store it in variable V;
[0042] A18. A pixel coordinate array PS indexed by variable V, denoted by PS[V], sets the value of PS[V] to be equal to the variable U;
[0043] A19. Increment the variable xTar by 1. If the value of variable xTar is less than W2, then proceed to step A16; otherwise, proceed to step A20.
[0044] A20. Increment the variable yTar by 1. If the value of variable yTar is less than H2, then proceed to step A15; otherwise, complete the correction control information stage.
[0045] Preferably, in the image data stream processing stage of the scanning image correction output, the image data stream in the scanning device first generates the original image by the photoelectric chip, then enters the random access memory (RAM1) for temporary storage via the bus, and after being processed by the processor, it becomes the corrected image and is then saved to RAM2. Finally, it is sent to the host computer interface via the bus output interface. RAM1 and RAM2 can be two different memory locations or two different address spaces of the same memory location. DMA is typically used to complete the transfer of the original image and the corrected image. Because the correction calculation speed of a low-cost processor is not necessarily faster than the speed at which the original image is generated, and the output speed of the corrected image is not necessarily faster than the speed at which the corrected image is generated, the data transfer of the original image and the corrected image must adopt an image speed matching method when scanning moving images. Otherwise, the final image will have a broken stitching between the old and new images.
[0046] The image speed matching of the original image and the corrected image adopts the same strategy, but the details of the specific steps are different. The common point is that three image buffers are defined. At any time, the operation on each buffer is only data writing, data reading, and idle. That is, it is not possible to perform both writing and reading operations on a buffer at the same time. When the DMA starts to transfer the last data of an image, the processor is notified by an interrupt.
[0047] The photoelectric chip triggers DMA1 to transfer the raw image data to RAM1, and the bus output interface triggers DMA2 to send the corrected image data to the host computer interface. DMA1 has a higher priority than DMA2. When DMA1 starts transferring the last byte of a raw image, it triggers interrupt 1 and executes the interrupt 1 service routine. When DMA2 starts transferring the last byte of a corrected image, it triggers interrupt 2 and executes the interrupt 2 service routine. The priority of interrupt 1 is set to be higher than that of interrupt 2. This setting of DMA and interrupt priorities ensures that even if the data processing or output speed is lower than the photoelectric chip's acquisition speed, image stitching will not be broken.
[0048] The original image data of the optoelectronic chip is sent to RAM1 via DMA1. In the main program loop of the processor, the data reading step is executed. The original image data is converted into corrected image data using the correction data. After being saved to RAM2, the data sending step is executed, and the data is sent to the upper interface using DMA2. The process is mainly divided into three parts: original image speed adaptation, corrected image output adaptation, and correction processing.
[0049] Preferably, the original image speed adaptation often uses global variables as coordination to make RAM1, DMA1, interrupt 1, and data reading steps work together to achieve this process; specifically, a one-dimensional array BUF1 with three elements is defined, the three elements respectively store the starting addresses of the three image buffers in RAM1, and are represented by BUF1[0], BUF1[1], and BUF1[2] respectively; two global variables WR1 and RD1 are defined and set to the initial value of zero;
[0050] The service processing steps of interrupt 1 are used to switch the original image buffer. On the one hand, the buffer is prepared for DMA1 to start saving a new original image data. On the other hand, the latest saved image data is prepared for the data reading step. The specific steps are as follows:
[0051] B1. After incrementing the variable WR1 by 1, if the value of WR1 is greater than 2, then set WR1 to zero.
[0052] B2. If the value of WR1 is equal to the value of RD1, then execute step B1; otherwise, proceed to step B3.
[0053] B3. Use WR1 as the index of array BUF1, represented by BUF1[WR1], and the value is the starting address of the original image buffer.
[0054] B4. Send the value of BUF1[WR1] to the DMA1 controller. After starting the DMA1 controller, exit the interrupt 1 service and complete the interrupt 1 service processing steps.
[0055] The specific steps for reading data are as follows:
[0056] C1. Compare the values of variables WR1 and RD1. If they are equal, it means that there is no original image data available for reading, so exit directly. Otherwise, proceed to step C2.
[0057] C2. Define variable R and set its initial value to WR1;
[0058] C3. After subtracting one from the value of variable R, if the value of R is less than zero, then set the value of R to 2.
[0059] C4. Set the value of variable RD1 to equal the value of R;
[0060] C5. Using RD1 as the index of array BUF1, represented by BUF1[RD1], the value is the starting address of the latest original image data, which is sent to the correction process.
[0061] Preferably, the image speed adaptation for image correction often uses global variables as coordination to enable RAM2, DMA2, interrupt 2, and data transmission steps to operate in tandem to achieve this process; specifically, a one-dimensional array BUF2 with three elements is defined, and the three elements respectively store the starting addresses of the three image buffers in RAM2, represented by BUF2[0], BUF2[1], and BUF2[2] respectively; two global variables WR2 and RD2 are defined and set to the initial value of zero;
[0062] The service processing steps for interrupt 2 are used to switch the correction image buffer. On the one hand, the buffer is prepared for DMA2 to send a new correction image data. On the other hand, the correction image data is prepared for the data transmission step to be written into the safest buffer. The specific steps are as follows:
[0063] D1. After incrementing the value of variable RD2 by 1, if the value of RD2 is greater than 2, then set RD2 to zero.
[0064] D2. If the value of RD2 is equal to the value of WR2, it indicates that there is no image data to be sent because the speed of DMA2 is higher than that of the correction process. The service process of interrupt 2 can be exited directly. Otherwise, proceed to step D3.
[0065] D3. Using RD2 as the index of array BUF2, represented by BUF2[RD2], the value is the starting address of the latest corrected image data, which is sent to the DMA2 controller.
[0066] D4. After starting DMA2 and beginning to send data, the interrupt 2 service is exited, completing the service processing steps of interrupt 2.
[0067] The specific steps for sending data are as follows:
[0068] E1. Use WR2 as the index of array BUF2, represented by BUF2[WR2]. The value is the starting address of a buffer in RAM2 that can store correction data.
[0069] E2. Save the latest corrected image data to the buffer corresponding to the value of BUF2[WR2];
[0070] E3. After sending the BUF2[WR2] value to the DMA2 controller, start DMA2 to begin sending data;
[0071] E4. After incrementing the value of variable WR2 by 1, if the value of WR2 is greater than 2, then set the value of WR2 to zero.
[0072] E5. Compare the values of variable WR2 and variable RD2. If they are equal, proceed to step E4; otherwise, the data transmission is complete.
[0073] Meanwhile, in the processor's main program loop, error correction processing needs to be performed. The error correction process is as follows:
[0074] F1. Use the data reading step to obtain an original image from RAM1. If a new image cannot be obtained, repeat step F1.
[0075] F2. The original image data is used to calculate the correction data to generate a correction image;
[0076] F3. After the corrected image is saved to RAM2, the data transmission step is executed.
[0077] F4. After the data sending step is completed, it is not necessary to wait for the image data to be sent completely before re-executing step F1.
[0078] Steps F1 to F4 are executed in an infinite loop; when the original image data acquisition speed is higher than the correction data processing speed, the original image speed adaptation can ensure that the splicing of the old and new data in the original image data will not be broken; when the host computer interface speed is lower than the correction image speed, the correction image speed adaptation can ensure that the image data received by the host computer will not be spliced of the old and new data.
[0079] The specific steps for generating a corrected image using the corrected data are as follows:
[0080] G1. Define variables x and y, and set all of them to zero;
[0081] G2. Define variable TW and set its value to the top data information GT; define variable TL and set its value to the address of the first element of the horizontal row number array TA.
[0082] G3, define variables TLE, TLD, TLU, and PUC; then add the starting address of the original image to TL;
[0083] G4. Use the value of TL as the address in RAM1 to obtain a horizontal full-line number; multiply this horizontal full-line number by the width W1 of the original image, add the value of variable TW, and then save it back to variables TW and PUC.
[0084] G5. Add the original image width W1 to the value of variable TW and save it to variables TLE and TLD; subtract the original image width W1 from the value of variable TW and save it to variable TLU.
[0085] G6. Obtain the value of variable PUC as the address of RAM1, and retrieve the pixel CA of the original image from RAM1;
[0086] G7. Obtain the value of variable TLU as the address of RAM1, retrieve the pixel CB of the original image from RAM1; calculate the average value CC of CA and CB, and then save CC back to the value of TLU as the storage address of RAM1; then increment the variable TLU by 1.
[0087] G8. Obtain the value of variable TLD as the address of RAM1, retrieve the pixel CD of the original image from RAM1; calculate the average value CE of CA and CD, and then save CE back to the value of TLD as the storage address of RAM1; then increment variable TLD by 1.
[0088] G9. After incrementing the variable PUC by 1, if the value of variable PUC is less than that of variable PLE, then execute step G6; otherwise, execute step G10.
[0089] G10. After incrementing variable TL by 1, increment the value of variable y by 1. If the value of variable y is less than the total number of rows lost in the horizontal direction TC, then execute step G4; otherwise, execute step G11.
[0090] G11. Define variable I and set its initial value to zero; define variable PT and set the value of variable PT to the starting address of the correction image data;
[0091] G12. Define variable TX and set the value of variable TX to be equal to the starting address of the original image data plus the value of the top all-lost data information GT;
[0092] G13, Set the value of variable y to zero;
[0093] G14. Use variable y as the index of the horizontal full-row mark array TS, denoted by TS[y]. If the value of TS[y] is not equal to zero, then increase the value stored in variable TX by W1.
[0094] G15. Set the value of variable x to zero;
[0095] G16. Use variable I as the index of pixel coordinate array PS, denoted as PS[I]; obtain the value IX of PS[I], calculate the value of IX after clearing the lowest 4 bits of the binary representation and save it as ILEFT, and calculate the value of IX after setting the lowest 4 bits of the binary representation to 1 and save it as IRIGHT.
[0096] G17. Shift ILEFT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VL of the original image; shift IRIGHT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VR of the original image.
[0097] G18. After incrementing the value of variable I by 1, calculate the value of IX minus ILEFT as XL; calculate the value of IX minus IRIGHT as XR; calculate VAL;
[0098] VAL = VR * XL - VL * XR
[0099] G19. After shifting VAL 4 bits to the right, store it in the correction image buffer area with PT as the RAM2 address;
[0100] G20. After incrementing the value of PT by 1, increment the value of variable x by 1. If the value of variable x is not greater than the width W2 of the corrected image, proceed to step G17; otherwise, proceed to step G18.
[0101] G21. Add the original image width W1 to the value of variable TX and save it back to variable TX;
[0102] G22. After incrementing the value of variable y by 1, if the value of variable y is less than the corrected image H2, then execute step G14; otherwise, the correction process is complete, and proceed to the data sending step to send the corrected image to the host computer interface.
[0103] The beneficial effects of this invention are:
[0104] 1. This invention provides a fast trapezoidal correction method for images from a biometric photoelectric scanning device. When the original image data acquisition speed is higher than the correction data processing speed, the original image speed matching can ensure that the splicing of old and new data in the original image data will not be interrupted. When the speed of the host computer interface is lower than the correction image speed, the correction image speed matching can ensure that the image data received by the host computer will not be spliced or interrupted.
[0105] 2. This invention provides a method for rapid trapezoidal correction of images from a biometric photoelectric scanning device. By triggering interrupt 2, the process switches to the interrupt 2 service processing step. The priority of interrupt 1 is set to be higher than that of interrupt 2. This setting of the priority of DMA and interrupts can ensure that even if the data processing or output speed is lower than the acquisition speed of the photoelectric chip, there will be no image stitching breakage. Attached Figure Description
[0106] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0107] Figure 1 This is a flowchart of the method in Embodiment 1;
[0108] Figure 2 This is a scanned image of the fixture in this embodiment. Detailed Implementation
[0109] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0110] Example 1
[0111] Please see Figure 1-2 As shown, the rapid trapezoidal correction method for images from a biometric photoelectric scanning device includes the following steps:
[0112] S1: During the production correction setting stage, the staff first places a standard fixture on the scanning device, and then uses software on the computer to display the scanned image of the fixture captured by the photoelectric camera chip in real time. The staff manually adjusts the mechanical parameters of the optical path, prioritizing the reduction of drum-shaped distortion, pincushion distortion, and rotational distortion. Trapezoidal distortion does not need much correction. After manually selecting the four corners of the edge trapezoid in the fixture image as four correction control points by clicking the mouse, the coordinates of these correction control points are sent to the scanning device for permanent storage.
[0113] S2: In the stage of generating correction control information, the processor in the scanning device calculates a set of data for image correction based on the saved coordinates of the correction control points, saves it to random access memory, and calls this set of image correction data image correction information. Although the computational load is large when generating image correction information, since these calculations are only performed once when the scanning device is reset and started, a low-cost processor can meet the actual needs. Because the calculated result data, i.e., the image correction information, needs to be repeatedly and quickly retrieved in the scanning image correction output stage, the correction information data needs to be saved to a random access memory that can be read quickly.
[0114] S3: Image correction and output stage. The processor in the scanning device uses image correction information to calculate the distorted image data of the photoelectric camera chip and convert it into an image with acceptable error, which is then output to the host computer or processor. This process is the main function of the scanning device and is executed repeatedly. Because high execution efficiency is required here, there cannot be too many time-consuming complex calculations such as floating-point division.
[0115] During the production correction setting stage, the scanning device needs to be connected to the computer. A standard fixture with a size equal to the scanning window of the device is placed on the scanning device. Production test software is run on the computer to display the fixture image captured by the photoelectric camera chip in real time. The standard fixture is a rectangular plane with square grids on the surface. There may be some hollow and solid grids arranged in an alternating pattern to mark the reference position.
[0116] The fixture pattern is mainly composed of hollow areas, which can visually show whether the position of the scanned image is correct. The focus is on observing whether there is obvious distortion in the grid lines. If the grid lines are bent or the square grid is deformed, it indicates that the image has been distorted. When the scanned image is distorted, the grid in this fixture pattern can be used to immediately identify which area of the scanning acquisition optical path the distortion is located in, which can be used to indicate the orientation of the fine-tuning mechanism when correcting mechanical errors.
[0117] The production correction settings first adjust the mechanical position of the optical bench. Although these image distortions are difficult to completely eliminate, the mechanical position should be adjusted as much as possible to reduce distortion. The smaller the distortion reduction by mechanical adjustment, the better it is to improve the quality of the final output correction image. Prioritize reducing drum distortion, pincushion distortion, and rotational distortion, while trapezoidal distortion does not need to be corrected too much. The requirement is to adjust it so that all four vertices of the rectangular fixture are displayed in the scanned image.
[0118] The four vertices of the original fixture are A, B, C, and D. In the scanned image transmitted to the computer by the scanning device, the four vertices E, F, G, and H correspond to the four vertices of the original fixture. The mechanical adjustment is required so that the EF and GH lines in the scanned image are both horizontal straight lines, while the EG and FH lines do not need to be perpendicular, only straight lines. Thus, the image formed by vertices E, F, G, and H is an arbitrary trapezoid with horizontal top and bottom edges.
[0119] On the interface of the production testing software, after clicking on the scanned image with the mouse to select the four vertices of the rectangular fixture as correction control points, the production testing software sends the coordinates of these four correction control points on the fixture scanned image to the scanning device, which permanently saves them in the device, thus completing the production correction setting.
[0120] During the generation of correction control information stage, the original image acquired by the photoelectric camera chip has a width of W1 and a height of H1; after the original image is reduced and corrected, the output image has a width of W2 and a height of H2; the generation of correction control information stage is performed every time the scanning device is powered on and reset or when the coordinates of the four correction control points on the jig scanning image are updated.
[0121] The stage of generating correction control information uses the coordinates of the four correction control points stored in the device's jig scan image during the production correction setting stage to calculate a set of correction data, which is then stored in the random access memory of the scanning device. The correction data includes three sets of information: top all-loss data information, horizontal all-loss line information, and trapezoidal horizontal fusion line information.
[0122] The top-level data loss information consists of only one value, denoted by GT, which is equal to the number of pixels above the EF line in the fixture scan image. Although mechanical adjustment is required to make the EF line and GH line in the fixture scan image horizontal, errors will still exist in actual production, namely, the coordinates of point E (E... X E Y ) and the coordinates of point F (F X ,F Y E Y With F Y The values may differ; therefore, the calculation method for discarding all data at the top is as follows:
[0123]
[0124] Similarly, due to the existence of machine model errors, the coordinates of point G (G X G Y ) and H-point coordinates (H X H Y ) of G Y With H Y The numerical values can also differ; the method for calculating the trapezoidal height LN is as follows:
[0125]
[0126] The horizontal line loss information includes three types of data: horizontal line loss count TC, horizontal line loss number array TA, and horizontal line loss marker array TS. The horizontal line loss count TC is a numerical value representing the number of horizontal lines reduced during the vertical scaling of the image. The number of elements in the horizontal line loss number array TA is defined as equal to H1 minus H2, and the actual number of valid data stored is equal to TC. The number of elements in the horizontal line loss marker array TS is defined as equal to H2.
[0127] The trapezoidal horizontal fusion row information includes a one-dimensional pixel coordinate array PS with a member number equal to the width W2 multiplied by the height H2, and an array PL with an element number equal to H2; each element in array PL is a data structure containing two members, namely the row start coordinate SS and the row width WS.
[0128] The specific steps for generating the correction control information are as follows:
[0129] A1. Set all elements of the horizontal all-drop row marker array TS to zero, and also set the horizontal all-drop row count TC to zero; calculate the top all-drop data information GT, and the trapezoidal height LN; define a constant XN. Although a larger XN value is more beneficial to improving accuracy, if the number of binary bits of the result XN*H2 exceeds the processor bit width, an overflow will occur; moreover, when XN exceeds 16 times the image width, it no longer significantly improves accuracy; therefore, the value of XN must be limited to not be too large. For example, in a 32-bit processor, XN can be set to 1,000,000.
[0130] A2. Define variables LB, LS, and yTar, and set their initial values to zero.
[0131] A3. Define variable SP and set its initial value to XN;
[0132] A4. Define variables U, V, and W to store temporary intermediate calculation results;
[0133] A5. Define the variable STEP and set its value to ;
[0134]
[0135] A6. After adding STEP to SP, if the value of SP is greater than XN, then execute step A7; otherwise, execute step A11.
[0136] A7. Shift LS left by four bits, then multiply by G. X The result is stored in variable U; after subtracting LS from LN, the result is shifted left by four bits and then multiplied by E. X The result is stored in variable V; then, yTar is used as the index of array PL, denoted by PL[yTar]. The result of adding variable U to variable V and then dividing by LN is stored in the member SS of PL[yTar].
[0137] A8. Shift LS left by four bits, then multiply by H. X The result is stored in variable U; after subtracting LS from LN, the result is shifted left by four bits and then multiplied by F. X Store the result in variable V; calculate the value of U plus V divided by LN and store it in variable W.
[0138] A9. Using yTar as the index of array PL, calculate the value of variable W minus the value of member SS of PL[yTar] and save it to member WS of PL[yTar].
[0139] A10. Subtract XN from SP; increment yTar by 1; then execute A13;
[0140] A11. If the value of yTar is greater than or equal to H2, then proceed directly to A12. Otherwise, first use yTar as the index of the array TS, represented by TS[yTar]. After setting the value of TS[yTar] to 1, then proceed to step A12.
[0141] A12. Array TA with index TC, denoted as TA[TC]. Calculate the value of variable LS minus the value of variable LB and store it in TA[TC]. Then store the value of variable LS in variable LB. Finally, increment the value of the number of horizontally dropped rows TC by 1.
[0142] A13. Compare the size of variables LS and LN. If LS is less than LN, then proceed to step A6; otherwise, proceed to step A14.
[0143] A14. Set the variable yTar to zero and define the variable xTar;
[0144] A15. Set the value of variable xTar to zero;
[0145] A16. In the array PL indexed by yTar, calculate the value of PL[yTar] member WS, multiply it by the variable xTar, divide it by W2, and finally add the value of PL[yTar] member SS, and store it in the variable U.
[0146] A17. Calculate the value of variable yTar multiplied by W2, add it to the value of variable xTar, and store it in variable V;
[0147] A18. A pixel coordinate array PS indexed by variable V, denoted by PS[V], sets the value of PS[V] to be equal to the variable U;
[0148] A19. Increment the variable xTar by 1. If the value of variable xTar is less than W2, then proceed to step A16; otherwise, proceed to step A20.
[0149] A20. Increment the variable yTar by 1. If the value of variable yTar is less than H2, then proceed to step A15; otherwise, complete the correction control information stage.
[0150] In the image data stream processing stage of the scanning image correction output, the image data stream in the scanning device first generates the original image by the photoelectric chip, then enters the random access memory (RAM1) for temporary storage via the bus, and after being processed by the processor, it becomes the corrected image and is then saved to RAM2. Finally, it is sent to the host computer interface via the bus output interface. RAM1 and RAM2 can be two different memory locations or two different address spaces of the same memory location. DMA is typically used to complete the transfer of the original image and the corrected image. Because the correction calculation speed of a low-cost processor is not necessarily faster than the original image generation speed, and the output speed of the corrected image is not necessarily faster than the generation speed, when scanning moving images, the data transmission of the original image and the corrected image must adopt an image speed matching method. Otherwise, the final image will have a broken stitching between the old and new images.
[0151] The image speed matching of the original image and the corrected image adopts the same strategy, but the details of the specific steps are different. The common point is that three image buffers are defined. At any time, the operation on each buffer is only data writing, data reading, and idle. That is, it is not possible to perform both writing and reading operations on a buffer at the same time. When the DMA starts to transfer the last data of an image, the processor is notified by an interrupt.
[0152] The photoelectric chip triggers DMA1 to transfer the raw image data to RAM1, and the bus output interface triggers DMA2 to send the corrected image data to the host computer interface. DMA1 has a higher priority than DMA2. When DMA1 starts transferring the last byte of a raw image, it triggers interrupt 1 and executes the interrupt 1 service routine. When DMA2 starts transferring the last byte of a corrected image, it triggers interrupt 2 and executes the interrupt 2 service routine. The priority of interrupt 1 is set to be higher than that of interrupt 2. This setting of DMA and interrupt priorities ensures that even if the data processing or output speed is lower than the photoelectric chip's acquisition speed, image stitching will not be broken.
[0153] The original image data of the optoelectronic chip is sent to RAM1 via DMA1. In the main program loop of the processor, the data reading step is executed. The original image data is converted into corrected image data using the correction data. After being saved to RAM2, the data sending step is executed, and the data is sent to the upper interface using DMA2. The process is mainly divided into three parts: original image speed adaptation, corrected image output adaptation, and correction processing.
[0154] The original image speed adaptation often uses global variables as coordination to make RAM1, DMA1, interrupt 1, and data reading steps work together to achieve this process; specifically, a one-dimensional array BUF1 with three elements is defined, and the three elements respectively store the starting addresses of the three image buffers in RAM1, represented by BUF1[0], BUF1[1], and BUF1[2] respectively; two global variables WR1 and RD1 are defined and set to the initial value of zero;
[0155] The service processing steps of interrupt 1 are used to switch the original image buffer. On the one hand, the buffer is prepared for DMA1 to start saving a new original image data. On the other hand, the latest saved image data is prepared for the data reading step. The specific steps are as follows:
[0156] B1. After incrementing the variable WR1 by 1, if the value of WR1 is greater than 2, then set WR1 to zero.
[0157] B2. If the value of WR1 is equal to the value of RD1, then execute step B1; otherwise, proceed to step B3.
[0158] B3. Use WR1 as the index of array BUF1, represented by BUF1[WR1], and the value is the starting address of the original image buffer.
[0159] B4. Send the value of BUF1[WR1] to the DMA1 controller. After starting the DMA1 controller, exit the interrupt 1 service and complete the interrupt 1 service processing steps.
[0160] The specific steps for reading data are as follows:
[0161] C1. Compare the values of variables WR1 and RD1. If they are equal, it means that there is no original image data available for reading, so exit directly. Otherwise, proceed to step C2.
[0162] C2. Define variable R and set its initial value to WR1;
[0163] C3. After subtracting one from the value of variable R, if the value of R is less than zero, then set the value of R to 2.
[0164] C4. Set the value of variable RD1 to equal the value of R;
[0165] C5. Using RD1 as the index of array BUF1, represented by BUF1[RD1], the value is the starting address of the latest original image data, which is sent to the correction process.
[0166] The image speed adaptation for image correction often uses global variables as coordination to enable RAM2, DMA2, interrupt 2, and data transmission steps to operate in tandem to achieve this process; specifically, a one-dimensional array BUF2 with three elements is defined, and the three elements respectively store the starting addresses of the three image buffers in RAM2, represented by BUF2[0], BUF2[1], and BUF2[2] respectively; two global variables WR2 and RD2 are defined and set to the initial value of zero;
[0167] The service processing steps for interrupt 2 are used to switch the correction image buffer. On the one hand, the buffer is prepared for DMA2 to send a new correction image data. On the other hand, the correction image data is prepared for the data transmission step to be written into the safest buffer. The specific steps are as follows:
[0168] D1. After incrementing the value of variable RD2 by 1, if the value of RD2 is greater than 2, then set RD2 to zero.
[0169] D2. If the value of RD2 is equal to the value of WR2, it indicates that there is no image data to be sent because the speed of DMA2 is higher than that of the correction process. The service process of interrupt 2 can be exited directly. Otherwise, proceed to step D3.
[0170] D3. Using RD2 as the index of array BUF2, represented by BUF2[RD2], the value is the starting address of the latest corrected image data, which is sent to the DMA2 controller.
[0171] D4. After starting DMA2 and beginning to send data, the interrupt 2 service is exited, completing the service processing steps of interrupt 2.
[0172] The specific steps for sending data are as follows:
[0173] E1. Use WR2 as the index of array BUF2, represented by BUF2[WR2]. The value is the starting address of a buffer in RAM2 that can store correction data.
[0174] E2. Save the latest corrected image data to the buffer corresponding to the value of BUF2[WR2];
[0175] E3. After sending the BUF2[WR2] value to the DMA2 controller, start DMA2 to begin sending data;
[0176] E4. After incrementing the value of variable WR2 by 1, if the value of WR2 is greater than 2, then set the value of WR2 to zero.
[0177] E5. Compare the values of variable WR2 and variable RD2. If they are equal, proceed to step E4; otherwise, the data transmission is complete.
[0178] Meanwhile, in the processor's main program loop, error correction processing needs to be performed. The error correction process is as follows:
[0179] F1. Use the data reading step to obtain an original image from RAM1. If a new image cannot be obtained, repeat step F1.
[0180] F2. The original image data is used to calculate the correction data to generate a correction image;
[0181] F3. After the corrected image is saved to RAM2, the data transmission step is executed.
[0182] F4. After the data sending step is completed, it is not necessary to wait for the image data to be sent completely before re-executing step F1.
[0183] Steps F1 to F4 are executed in an infinite loop; when the original image data acquisition speed is higher than the correction data processing speed, the original image speed adaptation can ensure that the splicing of the old and new data in the original image data will not be broken; when the host computer interface speed is lower than the correction image speed, the correction image speed adaptation can ensure that the image data received by the host computer will not be spliced of the old and new data.
[0184] The specific steps for generating a corrected image using the corrected data are as follows:
[0185] G1. Define variables x and y, and set all of them to zero;
[0186] G2. Define variable TW and set its value to the top data information GT; define variable TL and set its value to the address of the first element of the horizontal row number array TA.
[0187] G3, define variables TLE, TLD, TLU, and PUC; then add the starting address of the original image to TL;
[0188] G4. Use the value of TL as the address in RAM1 to obtain a horizontal full-line number; multiply this horizontal full-line number by the width W1 of the original image, add the value of variable TW, and then save it back to variables TW and PUC.
[0189] G5. Add the original image width W1 to the value of variable TW and save it to variables TLE and TLD; subtract the original image width W1 from the value of variable TW and save it to variable TLU.
[0190] G6. Obtain the value of variable PUC as the address of RAM1, and retrieve the pixel CA of the original image from RAM1;
[0191] G7. Obtain the value of variable TLU as the address of RAM1, retrieve the pixel CB of the original image from RAM1; calculate the average value CC of CA and CB, and then save CC back to the value of TLU as the storage address of RAM1; then increment the variable TLU by 1.
[0192] G8. Obtain the value of variable TLD as the address of RAM1, retrieve the pixel CD of the original image from RAM1; calculate the average value CE of CA and CD, and then save CE back to the value of TLD as the storage address of RAM1; then increment variable TLD by 1.
[0193] G9. After incrementing the variable PUC by 1, if the value of variable PUC is less than that of variable PLE, then execute step G6; otherwise, execute step G10.
[0194] G10. After incrementing variable TL by 1, increment the value of variable y by 1. If the value of variable y is less than the total number of rows lost in the horizontal direction TC, then execute step G4; otherwise, execute step G11.
[0195] G11. Define variable I and set its initial value to zero; define variable PT and set the value of variable PT to the starting address of the correction image data;
[0196] G12. Define variable TX and set the value of variable TX to be equal to the starting address of the original image data plus the value of the top all-lost data information GT;
[0197] G13, Set the value of variable y to zero;
[0198] G14. Use variable y as the index of the horizontal full-row mark array TS, denoted by TS[y]. If the value of TS[y] is not equal to zero, then increase the value stored in variable TX by W1.
[0199] G15. Set the value of variable x to zero;
[0200] G16. Use variable I as the index of pixel coordinate array PS, denoted as PS[I]; obtain the value IX of PS[I], calculate the value of IX after clearing the lowest 4 bits of the binary representation and save it as ILEFT, and calculate the value of IX after setting the lowest 4 bits of the binary representation to 1 and save it as IRIGHT.
[0201] G17. Shift ILEFT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VL of the original image; shift IRIGHT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VR of the original image.
[0202] G18. After incrementing the value of variable I by 1, calculate the value of IX minus ILEFT as XL; calculate the value of IX minus IRIGHT as XR; calculate VAL;
[0203] VAL = VR * XL - VL * XR
[0204] G19. After shifting VAL 4 bits to the right, store it in the correction image buffer area with PT as the RAM2 address;
[0205] G20. After incrementing the value of PT by 1, increment the value of variable x by 1. If the value of variable x is not greater than the width W2 of the corrected image, proceed to step G17; otherwise, proceed to step G18.
[0206] G21. Add the original image width W1 to the value of variable TX and save it back to variable TX;
[0207] G22. After incrementing the value of variable y by 1, if the value of variable y is less than the corrected image H2, then execute step G14; otherwise, the correction process is complete, and proceed to the data sending step to send the corrected image to the host computer interface.
[0208] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0209] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A rapid trapezoidal correction method for images from a biometric photoelectric scanning device, characterized in that: The rapid trapezoidal correction method for images from biometric photoelectric scanning devices includes the following steps: S1: During the production correction setting stage, the staff first places a standard fixture on the scanning device, and then uses software on the computer to display the scanned image of the fixture captured by the photoelectric camera chip in real time. The staff manually adjusts the mechanical parameters of the optical path, prioritizing the reduction of drum-shaped distortion, pincushion distortion, and rotational distortion. Trapezoidal distortion does not need much correction. After manually selecting the four corners of the edge trapezoid in the fixture image as four correction control points by clicking the mouse, the coordinates of these correction control points are sent to the scanning device for permanent storage. S2: In the stage of generating correction control information, the processor in the scanning device calculates a set of data for image correction based on the saved coordinates of the correction control points, saves it to random access memory, and calls this set of image correction data image correction information. Although the computational load is large when generating image correction information, since these calculations are only performed once when the scanning device is reset and started, a low-cost processor can meet the actual needs. Because the calculated result data, i.e., the image correction information, needs to be repeatedly and quickly retrieved in the scanning image correction output stage, the correction information data needs to be saved to a random access memory that can be read quickly. S3: Scanning image correction output stage. The processor in the scanning device uses the image correction information to calculate the distorted image data of the photoelectric camera chip and convert it into an image with acceptable error, which is then output to the host computer or processor. This process is the main function execution process of the scanning device and is in a state of repeated loop execution. Because high execution efficiency is required here, fixed-point arithmetic and DMA transfer mechanism are used to achieve efficient correction calculation. During the generation of correction control information stage, the original image acquired by the photoelectric camera chip has a width of W1 and a height of H1; after the original image is reduced and corrected, the output image has a width of W2 and a height of H2; the generation of correction control information stage is performed every time the scanning device is powered on and reset or when the coordinates of the four correction control points on the jig scanning image are updated. The stage of generating correction control information uses the coordinates of the four correction control points stored in the device's jig scan image during the production correction setting stage to calculate a set of correction data, which is then stored in the random access memory of the scanning device. The correction data includes three sets of information: top all-loss data information, horizontal all-loss line information, and trapezoidal horizontal fusion line information.
2. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 1, characterized in that: During the production correction setting stage, the scanning device needs to be connected to the computer. A standard fixture with a size equal to the scanning window of the device is placed on the scanning device. Production test software is run on the computer to display the fixture image captured by the photoelectric camera chip in real time. The standard fixture is a rectangular plane with square grids on the surface. There may be some hollow and solid grids arranged in an alternating pattern to mark the reference position. The fixture pattern is mainly composed of hollow areas, which can visually show whether the position of the scanned image is correct. The focus is on observing whether there is obvious distortion in the grid lines. If the grid lines are bent or the square grid is deformed, it indicates that the image has been distorted. When the scanned image is distorted, the grid in this fixture pattern can be used to immediately identify which area of the scanning acquisition optical path the distortion is located in, which can be used to indicate the orientation of the fine-tuning mechanism when correcting mechanical errors. The production correction settings first adjust the mechanical position of the optical bench. Although these image distortions are difficult to completely eliminate, the mechanical position should be adjusted as much as possible to reduce distortion. The smaller the distortion reduction by mechanical adjustment, the better it is to improve the quality of the final output correction image. Prioritize reducing drum distortion, pincushion distortion, and rotational distortion, while trapezoidal distortion does not need to be corrected too much. The requirement is to adjust it so that all four vertices of the rectangular fixture are displayed in the scanned image.
3. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 2, characterized in that: The four vertices of the original fixture are A, B, C, and D; in the scanned image transmitted to the computer by the scanning device, the four vertices E, F, G, and H correspond to the four vertices of the original fixture. The mechanical adjustment is required so that the EF and GH lines in the scanned image are both horizontal straight lines, while the EG and FH lines do not need to be perpendicular, they only need to be straight lines; thus, the image formed by vertices E, F, G, and H is an arbitrary trapezoid with the top and bottom edges in the horizontal direction. On the interface of the production testing software, after clicking on the scanned image with the mouse to select the four vertices of the rectangular fixture as correction control points, the production testing software sends the coordinates of these four correction control points on the fixture scanned image to the scanning device, which permanently saves them in the device, thus completing the production correction setting.
4. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 1, characterized in that: During the stage of generating correction control information, the original image acquired by the photoelectric camera chip has a width of W1 and a height of H1; after the original image is reduced and corrected, the output image has a width of W2 and a height of H2. The top-level data loss information consists of only one value, denoted by GT, which is equal to the number of pixels above the EF line in the fixture scan image. Although mechanical adjustment is required to make the EF line and GH line in the fixture scan image horizontal, errors will still exist in actual production, namely, the coordinates of point E (E... X E Y ) and the coordinates of point F (F X ,F Y E Y With F Y The values may differ; therefore, the calculation method for discarding all data at the top is as follows: Similarly, due to the existence of machine model errors, the coordinates of point G (G X G Y ) and H-point coordinates (H X H Y ) of G Y With H Y The numerical values can also differ; the method for calculating the trapezoidal height LN is as follows: The horizontal line loss information includes three types of data: horizontal line loss count TC, horizontal line loss number array TA, and horizontal line loss marker array TS. The horizontal line loss count TC is a numerical value representing the number of horizontal lines reduced during the vertical scaling of the image. The horizontal line loss number array TA is defined with the number of elements equal to H1 minus H2, and the actual number of valid data stored is equal to TC. The horizontal line loss marker array TS is defined with the number of elements equal to H2. The trapezoidal horizontal fusion row information includes a one-dimensional pixel coordinate array PS with a member number equal to the width W2 multiplied by the height H2, and an array PL with an element number equal to H2; each element in array PL is a data structure containing two members, namely the row start coordinate SS and the row width WS.
5. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 4, characterized in that: The specific steps for generating the correction control information are as follows: A1. Set all elements of the horizontal all-lost row marker array TS to zero, and also set the horizontal all-lost row count TC to zero; calculate the top all-lost data information GT, and the trapezoidal height LN; define a constant XN; A2. Define variables LB, LS, and yTar, and set their initial values to zero. A3. Define variable SP and set its initial value to XN; A4. Define variables U, V, and W to store temporary intermediate calculation results; A5. Define the variable STEP and set its value to ; A6. After adding STEP to SP, if the value of SP is greater than XN, then execute step A7; otherwise, execute step A11. A7. Shift LS left by four bits, then multiply by G. X The result is stored in variable U; After subtracting LS from LN, shift the result four bits to the left and then multiply by E. X The result is stored in variable V; then, yTar is used as the index of array PL, denoted by PL[yTar]. The result of adding variable U to variable V and then dividing by LN is stored in the member SS of PL[yTar]. A8. Shift LS left by four bits, then multiply by H. X The result is stored in variable U; After subtracting LS from LN, shift the result four bits to the left and then multiply by F. X Store the result in variable V; Calculate the value of U plus V divided by LN, and store it in variable W; A9. Using yTar as the index of array PL, calculate the value of variable W minus the value of member SS of PL[yTar] and save it to member WS of PL[yTar]. A10. Subtract XN from SP; increment yTar by 1; then execute A13; A11. If the value of yTar is greater than or equal to H2, then proceed directly to A12. Otherwise, first use yTar as the index of the array TS, represented by TS[yTar]. After setting the value of TS[yTar] to 1, then proceed to step A12. A12. Array TA with index TC, denoted as TA[TC]. Calculate the value of variable LS minus the value of variable LB and store it in TA[TC]. Then store the value of variable LS in variable LB. Finally, increment the value of the number of horizontally dropped rows TC by 1. A13. Compare the size of variables LS and LN. If LS is less than LN, then proceed to step A6; otherwise, proceed to step A14. A14. Set the variable yTar to zero and define the variable xTar; A15. Set the value of variable xTar to zero; A16. In the array PL indexed by yTar, calculate the value of PL[yTar] member WS, multiply it by the variable xTar, divide it by W2, and finally add the value of PL[yTar] member SS, and store it in the variable U. A17. Calculate the value of variable yTar multiplied by W2, add it to the value of variable xTar, and store it in variable V; A18. A pixel coordinate array PS indexed by variable V, denoted by PS[V], sets the value of PS[V] to be equal to the variable U; A19. Increment the variable xTar by 1. If the value of variable xTar is less than W2, then proceed to step A16; otherwise, proceed to step A20. A20. Increment the variable yTar by 1. If the value of variable yTar is less than H2, then proceed to step A15; otherwise, complete the correction control information stage.
6. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 1, characterized in that: In the image data stream processing stage of the scanning image correction output, the image data stream in the scanning device first generates the original image by the photoelectric chip, then enters the random access memory (RAM1) for temporary storage via the bus, and after being processed by the processor, it becomes the corrected image and is then saved to RAM2. Finally, it is sent to the host computer interface via the bus output interface. RAM1 and RAM2 can be two different memory locations or two different address spaces of the same memory location. DMA is typically used to complete the transfer of the original image and the corrected image. Because the correction calculation speed of a low-cost processor is not necessarily faster than the original image generation speed, and the output speed of the corrected image is not necessarily faster than the generation speed, when scanning moving images, the data transmission of the original image and the corrected image must adopt an image speed matching method. Otherwise, the final image will have a broken stitching between the old and new images. The image speed matching of the original image and the corrected image adopts the same strategy, but the details of the specific steps are different. The common point is that three image buffers are defined. At any time, the operation on each buffer is only data writing, data reading, and idle. That is, it is not possible to perform both writing and reading operations on a buffer at the same time. When the DMA starts to transfer the last data of an image, the processor is notified by an interrupt. The photoelectric chip triggers DMA1 to transfer the original image data to RAM1, and the bus output interface triggers DMA2 to send the corrected image data to the host computer interface. DMA1 has a higher priority than DMA2. When DMA1 starts transferring the last byte of an original image, it triggers interrupt 1 and executes the interrupt 1 service routine. When DMA2 starts transferring the last byte of a corrected image, it triggers interrupt 2 and executes the interrupt 2 service routine. The priority of interrupt 1 is set to be higher than that of interrupt 2. The original image data of the optoelectronic chip is sent to RAM1 via DMA1. In the main program loop of the processor, the data reading step is executed. The original image data is converted into corrected image data using the correction data. After being saved to RAM2, the data sending step is executed, and the data is sent to the upper interface using DMA2. The process is mainly divided into three parts: original image speed adaptation, corrected image output adaptation, and correction processing.
7. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 6, characterized in that: The original image speed adaptation often uses global variables as coordination to make RAM1, DMA1, interrupt 1, and data reading steps work together to achieve this process; specifically, a one-dimensional array BUF1 with three elements is defined, and the three elements respectively store the starting addresses of the three image buffers in RAM1, represented by BUF1[0], BUF1[1], and BUF1[2] respectively; two global variables WR1 and RD1 are defined and set to the initial value of zero; The service processing steps of interrupt 1 are used to switch the original image buffer. On the one hand, the buffer is prepared for DMA1 to start saving a new original image data. On the other hand, the latest saved image data is prepared for the data reading step. The specific steps are as follows: B1. After incrementing the variable WR1 by 1, if the value of WR1 is greater than 2, then set WR1 to zero. B2. If the value of WR1 is equal to the value of RD1, then execute step B1; otherwise, proceed to step B3. B3. Use WR1 as the index of array BUF1, represented by BUF1[WR1], and the value is the starting address of the original image buffer. B4. Send the value of BUF1[WR1] to the DMA1 controller. After starting the DMA1 controller, exit the interrupt 1 service and complete the interrupt 1 service processing steps. The specific steps for reading data are as follows: C1. Compare the values of variables WR1 and RD1. If they are equal, it means that there is no original image data available for reading, so exit directly. Otherwise, proceed to step C2. C2. Define variable R and set its initial value to WR1; C3. After subtracting one from the value of variable R, if the value of R is less than zero, then set the value of R to 2. C4. Set the value of variable RD1 to equal the value of R; C5. Using RD1 as the index of array BUF1, represented by BUF1[RD1], the value is the starting address of the latest original image data, which is sent to the correction process.
8. The rapid trapezoidal correction method for images from a biometric photoelectric scanning device according to claim 7, characterized in that: The image speed adaptation for image correction often uses global variables as coordination to enable RAM2, DMA2, interrupt 2, and data transmission steps to operate in tandem to achieve this process; specifically, a one-dimensional array BUF2 with three elements is defined, and the three elements respectively store the starting addresses of the three image buffers in RAM2, represented by BUF2[0], BUF2[1], and BUF2[2] respectively; two global variables WR2 and RD2 are defined and set to the initial value of zero; The service processing steps for interrupt 2 are used to switch the correction image buffer. On the one hand, the buffer is prepared for DMA2 to send a new correction image data. On the other hand, the correction image data is prepared for the data transmission step to be written into the safest buffer. The specific steps are as follows: D1. After incrementing the value of variable RD2 by 1, if the value of RD2 is greater than 2, then set RD2 to zero. D2. If the value of RD2 is equal to the value of WR2, it indicates that there is no image data to be sent because the speed of DMA2 is higher than that of the correction process. The service process of interrupt 2 can be exited directly. Otherwise, proceed to step D3. D3. Using RD2 as the index of array BUF2, represented by BUF2[RD2], the value is the starting address of the latest corrected image data, which is sent to the DMA2 controller. D4. After starting DMA2 and beginning to send data, the interrupt 2 service is exited, completing the service processing steps of interrupt 2. The specific steps for sending data are as follows: E1. Use WR2 as the index of array BUF2, represented by BUF2[WR2]. The value is the starting address of a buffer in RAM2 that can store correction data. E2. Save the latest corrected image data to the buffer corresponding to the value of BUF2[WR2]; E3. After sending the BUF2[WR2] value to the DMA2 controller, start DMA2 to begin sending data; E4. After incrementing the value of variable WR2 by 1, if the value of WR2 is greater than 2, then set the value of WR2 to zero. E5. Compare the values of variable WR2 and variable RD2. If they are equal, proceed to step E4; otherwise, the data transmission is complete. Meanwhile, in the processor's main program loop, error correction processing needs to be performed. The error correction process is as follows: F1. Use the data reading step to obtain an original image from RAM1. If a new image cannot be obtained, repeat step F1. F2. The original image data is used to calculate the correction data to generate a correction image; F3. After the corrected image is saved to RAM2, the data transmission step is executed. F4. After the data sending step is completed, it is not necessary to wait for the image data to be sent completely before re-executing step F1. Steps F1 to F4 are executed in an infinite loop; The specific steps for generating a corrected image using the corrected data are as follows: G1. Define variables x and y, and set all of them to zero; G2. Define variable TW and set its value to the top data information GT; define variable TL and set its value to the address of the first element of the horizontal row number array TA. G3, define variables TLE, TLD, TLU, and PUC; then add the starting address of the original image to TL; G4. Use the value of TL as the address in RAM1 to obtain a horizontal full-line number; multiply this horizontal full-line number by the width W1 of the original image, add the value of variable TW, and then save it back to variables TW and PUC. G5. Add the original image width W1 to the value of variable TW and save it to variables TLE and TLD; subtract the original image width W1 from the value of variable TW and save it to variable TLU. G6. Obtain the value of variable PUC as the address of RAM1, and retrieve the pixel CA of the original image from RAM1; G7. Obtain the value of variable TLU as the address of RAM1, retrieve the pixel CB of the original image from RAM1; calculate the average value CC of CA and CB, and then save CC back to the value of TLU as the storage address of RAM1; then increment the variable TLU by 1. G8. Obtain the value of variable TLD as the address of RAM1, retrieve the pixel CD of the original image from RAM1; calculate the average value CE of CA and CD, and then save CE back to the value of TLD as the storage address of RAM1; then increment variable TLD by 1. G9. After incrementing the variable PUC by 1, if the value of variable PUC is less than that of variable PLE, then execute step G6; otherwise, execute step G10. G10. After incrementing variable TL by 1, increment the value of variable y by 1. If the value of variable y is less than the total number of rows lost in the horizontal direction TC, then execute step G4; otherwise, execute step G11. G11. Define variable I and set its initial value to zero; define variable PT and set the value of variable PT to the starting address of the correction image data; G12. Define variable TX and set the value of variable TX to be equal to the starting address of the original image data plus the value of the top all-lost data information GT; G13, Set the value of variable y to zero; G14. Use variable y as the index of the horizontal full-row mark array TS, denoted by TS[y]. If the value of TS[y] is not equal to zero, then increase the value stored in variable TX by W1. G15. Set the value of variable x to zero; G16. Use variable I as the index of pixel coordinate array PS, denoted as PS[I]; obtain the value IX of PS[I], calculate the value of IX after clearing the lowest 4 bits of the binary representation and save it as ILEFT, and calculate the value of IX after setting the lowest 4 bits of the binary representation to 1 and save it as IRIGHT. G17. Shift ILEFT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VL of the original image; shift IRIGHT right by 4 bits, add the value of variable TX, and use this as the address in RAM1 to obtain a pixel VR of the original image. G18. After incrementing the value of variable I by 1, calculate the value of IX minus ILEFT as XL; calculate the value of IX minus IRIGHT as XR; calculate VAL; VAL = VR * XL - VL * XR G19. After shifting VAL 4 bits to the right, store it in the correction image buffer area with PT as the RAM2 address; G20. After incrementing the value of PT by 1, increment the value of variable x by 1. If the value of variable x is not greater than the width W2 of the corrected image, proceed to step G17; otherwise, proceed to step G18. G21. Add the original image width W1 to the value of variable TX and save it back to variable TX; G22. After incrementing the value of variable y by 1, if the value of variable y is less than the corrected image H2, then execute step G14; otherwise, the correction process is complete, and proceed to the data sending step to send the corrected image to the host computer interface.
Citation Information
Patent Citations
Real-time trapezoidal distortion correction method and system for optical fingerprint sensor
CN104077586A