Image scanning method and device based on contact image sensor
Patent Information
- Application Number
- CN202511763634.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-01-09
AI Technical Summary
Existing contact linear scan technology cannot adapt to the flexible and varied movement speed and triggering requirements of handheld portable devices, resulting in unstable image quality. Furthermore, the existing system has a complex processing chain, high cost, and difficulty in achieving real-time display.
The system employs photoelectric sensors to detect the movement distance of the image scanning device, determines the scanning trigger timing based on displacement data, performs line scanning operations through contact image sensors, and combines scan frame prediction and anti-shake mechanisms to achieve real-time image preview and efficient data processing.
It improves the imaging stability and image quality of handheld scanning devices, reduces equipment costs, and enables real-time display and a simplified system architecture for portable scanning devices.
Smart Images

Figure CN121309734A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image scanning, and more specifically, to an image scanning method and apparatus based on a contact image sensor. Background Technology
[0002] Contact linear array image scanning technology is widely used for the digital acquisition of planar media such as documents and drawings. Existing trigger scanning methods mainly rely on two types of schemes: the first type is common in desktop scanners and other rail-mounted devices, which uses a stepper motor to drive the scanning module to move at a constant speed on the rail and triggers image acquisition based on a timing signal; the second type uses rollers or shafts to drive a high-precision grating inside the encoder to generate a line scanning signal to trigger acquisition.
[0003] However, these existing technologies have some limitations. First, the aforementioned constant-speed trigger scanning method relies heavily on a preset, fixed scanning speed, which makes it only suitable for scanning devices with rigid guide rails and precision motors, and cannot be adapted to the flexible movement speed and free scanning path of handheld and portable scanning devices.
[0004] Secondly, even in devices with specific structures, existing solutions have inherent limitations. For example, the grating detection method disclosed in Chinese patent document CN115866148A can only detect movement distance in a single direction. During manual scanning, even slight tremors from the operator's hand can cause the same area to be scanned repeatedly or missed, severely affecting image quality. Furthermore, the solution disclosed in Chinese patent document CN104580813A requires a specific paper feed base to complete scanning, making it unsuitable for paper wider than the base's dimensions, thus limiting its application scenarios.
[0005] Furthermore, from a system architecture perspective, existing scanning systems often rely on multiple processor chips working together to read and display data, resulting in complex processing links, high costs, and difficulty in achieving truly real-time display of scanned images, thus affecting the user experience.
[0006] There is currently no effective solution to the above problems. Summary of the Invention
[0007] This invention provides an image scanning method and apparatus based on a contact image sensor, which at least solves the technical problem that the fixed-speed trigger scanning mode, which relies on a fixed scanning speed, is only applicable to rail-mounted devices and cannot adapt to the flexible and varied movement speeds and triggering requirements of handheld portable devices.
[0008] According to one aspect of the present invention, an image scanning method based on a contact image sensor is provided, comprising: detecting displacement data characterizing the moving distance of an image scanning device using a photoelectric sensor; determining a next scan trigger timing based on the displacement data, and generating a line scan trigger signal when the next scan trigger timing arrives; and driving the contact image sensor to perform a line scan operation based on the line scan trigger signal to obtain image scan data.
[0009] According to another aspect of the present invention, an image scanning device based on a contact image sensor is also provided, comprising: a detection module configured to detect displacement data characterizing the moving distance of the image scanning device using a photoelectric sensor; a generation module configured to determine the next scan trigger timing based on the displacement data, and generate a line scan trigger signal when the next scan trigger timing arrives; and a driving module configured to drive the contact image sensor to perform a line scan operation based on the line scan trigger signal to obtain image scan data.
[0010] In this embodiment of the invention, a photoelectric sensor is used to detect displacement data characterizing the moving distance of the image scanning device; based on the displacement data, the timing for triggering the next scan is determined, and a line scan trigger signal is generated when the next scan trigger timing arrives; based on the line scan trigger signal, a contact image sensor is driven to perform a line scan operation to obtain image scan data. This solution solves the technical problem that the fixed-speed trigger scanning mode, which relies on a fixed scanning speed, is only suitable for rail-mounted devices and cannot adapt to the flexible and varied moving speeds and triggering requirements of handheld portable devices. Attached Figure Description
[0011] 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:
[0012] Figure 1 This is a diagram showing the electronic components of an optional image scanning device according to an embodiment of the present invention;
[0013] Figure 2 This is a flowchart of an optional image scanning method based on a contact image sensor according to an embodiment of the present invention;
[0014] Figure 3 It is an image rendering of the scanned image when there is jitter, based on the existence of existing technology;
[0015] Figure 4 This is an optional scanning timing signal diagram according to an embodiment of the present invention;
[0016] Figure 5 This is an optional scan rollback rendering effect diagram according to an embodiment of the present invention, wherein (a) is an image rendering effect diagram with scan rollback in the prior art, and (b) is an image rendering effect diagram with scan rollback in an embodiment of the present application;
[0017] Figure 6 This is a framework diagram of an optional image scanning system according to an embodiment of the present invention;
[0018] Figure 7 This is a flowchart of an optional preview data interaction method according to an embodiment of the present invention;
[0019] Figure 8 This is a flowchart of another image scanning method based on a contact image sensor according to an embodiment of the present invention;
[0020] Figure 9 This is a schematic diagram of the structure of an image scanning device based on a contact image sensor according to an embodiment of the present invention;
[0021] Figure 10 A schematic diagram of the structure of a computer device suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. 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 should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0024] This application provides an image scanning device based on a contact image sensor. Figure 1A diagram showing the electronic components of the image scanning device is provided. Figure 1 As shown, the electronic components of the image scanning device include: photoelectric sensor S2, CIS contact image sensor S1, AD conversion chip C1, coprocessor P2, processor P1, display screen D1, and memory and storage chip U1.
[0025] Processor P1 is directly connected to the AD conversion chip C1, coprocessor P2, and photoelectric sensor S2, and is used for scanning condition triggering, image reception and processing, and real-time display of scanning effects. When photoelectric sensor S2 detects that the movement distance has reached a threshold, it reports to processor P1 via an interrupt to initiate image scanning. Processor P1 polls and reads the displacement data of photoelectric sensor S2, and determines whether to trigger line scanning based on this displacement data. If line scanning is triggered, it generates a line scanning trigger signal. After receiving the line scanning trigger signal, coprocessor P2 uses a dedicated timing signal to control the CIS contact image sensor S1 via AD conversion chip C1 to complete the photoelectric conversion of the image signal, and finally transmits the image data to processor P1 via a high-speed bus.
[0026] The above structure enables the CIS contact scanning device provided in this application to be smaller, thinner, and lighter than existing products, and its manufacturing cost is also lower than that of similar products.
[0027] The operation procedure of the image scanning device will be described in detail below, such as Figure 2 As shown, the scanning method of the image scanning device includes the following steps:
[0028] Step S202: Scanning is triggered by photoelectric interruption.
[0029] After the photoelectric sensor S2 detects that the moving distance has reached the threshold, it reports to the processor P1 via an interrupt to initiate image scanning.
[0030] Step S204: The row scan signal is triggered.
[0031] When the photoelectric sensor S2 detects movement of the image scanning device, the processor P1 polls and reads the displacement data dx of the photoelectric sensor S2. The preset minimum spacing of the displacement data dx is proportional to the single-line scanning width (for example, when the single-line scanning width is 0.4mm, the detection unit of the photoelectric sensor S2 is also 0.4mm, that is, dx=1 represents a movement of 0.4mm, dx=2 represents a movement of 0.8mm, and the movement distance D=dx×0.4mm).
[0032] Under ideal scanning conditions, processor P1 reads the displacement data Dx of photoelectric sensor S2. Dx is always 1, which means that it has moved one line in the positive direction of scanning. At this time, processor P1 sends a line scanning signal to coprocessor P2.
[0033] However, in actual handheld scanning, users may encounter non-ideal situations such as scanning too fast or back-and-forth shaking, causing dx to no longer stably equal 1. To ensure more accurate and reliable line scan triggering, this embodiment introduces a scan frame prediction mechanism and a scan anti-shake mechanism on top of the above basic triggering logic, handling the cases of dx>1 and dx exhibiting positive or negative fluctuations respectively.
[0034] 1) Scan frame prediction.
[0035] When processor P1 reads displacement data dx(t0) > 1 from photoelectric sensor S2, it indicates that the current frame scanning speed is too fast, meaning the current distance detection period T (i.e., the time interval between processor P1 reading data from photoelectric sensor S2) is too large. At this point, the system predicts the time to reach the next scanning interval dx = 1, and simultaneously adjusts the detection period. The specific calculation formula is as follows:
[0036] f(t n )=
[0037] Where T(tn) represents the time interval for reading the displacement data of photoelectric sensor S2, |dx(tn)| is the absolute value (non-zero) of the displacement interval read by photoelectric sensor S2, and K is a correction value. When time f(tn) is reached, the system triggers a row scan and updates the current recommended scan interval Td. The time interval for reading the displacement data of photoelectric sensor S2 is the time difference between two consecutive readings where the displacement data is not zero.
[0038] If the Dx value reads is greater than 1 for multiple consecutive detection cycles, the system will automatically adjust the detection threshold to increase the detection resolution. If the system continues to show Dx values greater than 1, it will prompt the user to perform parameter calibration and recovery operations to ensure the device operates in an ideal state.
[0039] 2) Scan anti-shake
[0040] Because different users hold and drag their devices differently, although scanning aids can reduce vertical shaking, slight back-and-forth shaking may still occur in some cases, leading to image abnormalities, such as... Figure 3 As shown. During the row scan triggering process, the current cumulative movement distance Dx is recorded, and a row scan is triggered only when Dx > 0. The specific formula for the current cumulative movement distance is as follows:
[0041] Dx(t) = Dx(t-1) + dx(tn).
[0042] Where Dx(t) is the cumulative distance traveled at the current moment, Dx(t-1) is the cumulative distance traveled at the previous moment, and dx(tn) is the current distance traveled, i.e., the current displacement data.
[0043] For example, when the initial value of Dx is 0, if the displacement data dx1=1 of the photoelectric sensor S2 is read at time t1, then Dx is incremented to 1. At this time, Dx>0, and the processor P1 sends a row scan trigger signal to the coprocessor P2, and then clears Dx to zero after the trigger. Subsequently, at time t2, the displacement data dx2=-1 is read, and Dx is updated to -1, indicating that there is a displacement in the backward direction. In this case, the system will not trigger a scan. When the displacement data dx3=1 is read at time t3, Dx increases from -1 to 0. Since Dx is not greater than 0, a scan is still not triggered. When the displacement data dx4=1 is read at time t4, Dx is incremented to 1. At this time, Dx>0, and the system meets the trigger condition again, thus triggering the row scan operation.
[0044] Step S206: Acquire timing data.
[0045] After the triggering conditions are met, processor P1 sends a line scan trigger signal to coprocessor P2. Coprocessor P2 generates a scan timing signal according to the driving timing of the CIS contact image sensor, controlling the CIS to complete the photoelectric conversion of the line image.
[0046] Specific scan timing signals such as Figure 4 As shown, Pixel is the analog image signal output by the CIS contact image sensor S1 (representing the red, green, and blue color components), and each pixel corresponds to a segment of analog level. SHD (sample and hold signal) is used to lock the analog signal of the current pixel: when SHD is high, the sensor converts the light signal of the corresponding pixel into an analog voltage and holds it, preparing for AD conversion. ADCK (AD conversion clock) is the working clock of the AD conversion chip C1: the pulse trigger chip of ADCK performs analog-to-digital conversion on the "held analog signal", converting the analog voltage into a digital signal. D[7:0] (digital output data) is the digital image data after AD conversion: the RGB components of each pixel are split into "high byte (HB)" and "low byte (LB)" for output. For example, the output order of a certain pixel is "P1_HB, P1_LB, P2_HB, P2_LB, P2_HB, R_LB". This method supports a maximum of 16-bit data mode Data=HB<<8 | LB. In 8-bit mode, only the HB high byte is used, corresponding to the red, green, and blue digital information of the pixel. Due to the pixel arrangement, a single line of red component data is collected when the scanning light is red, a line of blue component data is collected after blue light, and a line of green component data is collected after green light. After the three color components are collected, a complete line of color data is formed.
[0047] Step S208, single-row image data.
[0048] The AD conversion chip C1 and the CIS contact image sensor S1 convert the image information of the current scan line from an optical signal to a digital signal according to the scanning timing signal. The processor P1 receives the digital signal and temporarily stores it in the RAW[] array. The data in the RAW[] array is the raw image scanning data of the CIS contact image sensor S1. After color calibration and RGB value conversion, and then through a preview process, it is displayed in real time on the screen D1 of the scanning device.
[0049] Step S210: Real-time preview of image processing.
[0050] The scan preview function renders the RAW data acquired line by line to the display screen in real time during the scanning process, allowing users to observe the scan results immediately. Preview processing includes two working modes: normal scan mode and rewind scan mode, as detailed below:
[0051] (1) Real-time preview processing under normal conditions
[0052] During normal scanning, i.e., when the displacement dx detected by the photoelectric sensor is positive and the cumulative displacement Dx > 0, the system will acquire the RAW image data of the current line according to the line scan trigger signal. The processor P1 marks this line of data as a valid line, i.e., sets Raws[i].active = true.
[0053] Subsequently, CisService reads all valid rows of data from the RAW[] buffer and sequentially performs image preprocessing steps such as color correction, brightness and gamma adjustment, noise suppression, and geometric and coordinate correction. The processed image data is written to the Display buffer Displaybuff and rendered on the screen by the display module, allowing the user to see the image content that accumulates in real time as the scanning process progresses.
[0054] In this state, the preview screen will increase line by line as the scanning head moves, achieving a real-time preview effect of "scanning and displaying simultaneously".
[0055] (2) Real-time preview processing in rollback mode.
[0056] When the image scanning device continuously moves in the negative direction, the system sets a threshold Db. When the cumulative displacement Dx reaches the threshold Db, it is determined that the user has performed a backscan. The raw image scanning data of the CIS contact image sensor S1 is stored in the RAW[] array, and Raws[] is used to mark the validity of each row of data in RAW[]. When a backscan occurs, Dx is negative, and the system marks the corresponding row as invalid, that is: Raws[i].active=false. When generating a preview image later, the system skips the rendering of invalid rows, thereby achieving the backscan effect, such as... Figure 5 As shown.
[0057] The framework and workflow of the scan preview system will be described below.
[0058] The framework of the scan preview system is as follows: Figure 6 The main components include: CisDriver (driver layer), which is the core layer; CisService (service layer), which is used for data transfer and processing; and the App application layer, which is used for interaction with users.
[0059] The processing flow of the scan preview system is as follows: Figure 7 As shown, during initialization, the user app registers the view for display and the callback function for receiving messages with the CisService in the HAL layer. When the CisService receives the view, it directly obtains its display cache address pointer, DisplayBuff. After the user starts scanning, it is relayed to the underlying driver layer, CisDriver (processor P1), through the HAL service, to start reading the data from the photoelectric sensor S2, and to collect image data in real time according to the aforementioned triggering logic, caching it in RAW[]buffer.
[0060] The HAL layer directly maps the memory address of the Raw[]_buffer using mmap, allowing CisService to directly access the image data in the RAW[]. When CisService detects new data updates, it performs operations such as image color balancing, data filtering, and coordinate transformation, writes the results to DisplayBuff, and then calls the SurfingerPostSync interface for real-time display.
[0061] In the implementation of the preview module, this embodiment preferably uses TextureView as the display container for real-time image preview to meet the requirements of the Android system for high refresh rate, hardware-accelerated rendering, and freely controllable screen rotation and scaling. Of course, this embodiment is not limited to TextureView. In specific application environments, SurfaceView, FrameBuffer, or other graphics rendering components with display capabilities can be selected as alternatives to achieve the same real-time image display effect, depending on the system architecture and performance requirements.
[0062] Regarding the data transmission path, this embodiment employs mmap in conjunction with the HAL (Hardware Abstraction Layer) interface to transmit the raw CIS row data to the image processing module via a shared mapping path, achieving a low-latency, high-throughput row-level data exchange mechanism. In other embedded systems or Android platforms, this can be flexibly replaced with Binder + shared memory, Ashmem, or other zero-copy shared buffer transmission methods supported by the system kernel, depending on the system framework, to achieve consistent data transmission efficiency and stability. All of the above substitution methods are equivalent solutions that can be implemented by those skilled in the art and do not affect the core technical process and implementation effect of this invention.
[0063] Finally, when the user lifts the scanning device or the driver detects a timeout, the system will automatically stop scanning and notify the upper-level service. Alternatively, the user can manually stop the scanning process via an on-screen button.
[0064] This invention significantly improves image stability and imaging quality in handheld scanning by introducing a scanning stabilization mechanism, image quality optimization strategy, and backscan processing flow into a handheld CIS contact scanning device. This makes the scanning process more adaptable to the user's natural movement and provides a smoother overall user experience.
[0065] Furthermore, this invention proposes for the first time a real-time preview solution suitable for CIS contact scanning devices, enabling instant display functionality of "scanning and viewing simultaneously" in portable scanning scenarios. The system adopts a high-efficiency data synchronization architecture based on HIDL and mmap memory mapping, enabling row-level incremental rendering during scanning with "one line acquired, one line displayed." The entire data link involves only one memory copy, and the latency from acquisition trigger to image display can be controlled within approximately 4 milliseconds, significantly better than the segmented splicing mode of traditional area-array CIS, avoiding the latency and system complexity caused by multi-line caching, interval combination, and large data volume processing in area-array structures.
[0066] Furthermore, the triggering and acquisition logic of this invention is executed by the same processor chip, avoiding the clock asynchrony and cross-device latency accumulation problems common in multi-chip collaborative solutions, thus ensuring precise and reliable timing control. At the same time, since it does not require an FPGA or multi-processor architecture, this invention has lower hardware costs and a simpler system architecture, facilitating its widespread application in portable and low-power devices.
[0067] Figure 8 This is another image scanning method based on a contact image sensor according to an embodiment of the present invention, such as... Figure 8 As shown, the method includes the following steps:
[0068] Step S802: Use a photoelectric sensor to detect displacement data that characterizes the moving distance of the image scanning device.
[0069] Step S804: Based on the displacement data, determine the timing of the next scan trigger, and generate a row scan trigger signal when the timing of the next scan trigger arrives.
[0070] 1) Predicting scan frames when moving in one direction.
[0071] When the image scanning device is detected to move in a single direction along the scanning surface, the timing of the next scan is determined based on the displacement data and the time interval between the current reading of the displacement data, wherein the time interval is the time difference between two consecutive readings of the displacement data that are not zero.
[0072] When the displacement data is greater than a preset threshold (dx(t0)>1), the time point at which the target scanning interval is reached next is predicted based on the relationship between the time interval and the change of the displacement data, and this time point is used as the triggering time for the next scan.
[0073] 2) Bidirectional movement with scan anti-shake.
[0074] When the image scanning device is detected to be reciprocating along the scanning surface, the timing for triggering the next scan is determined based on the displacement data and the cumulative movement distance of the image scanning device. For example, if the displacement data is positive and the cumulative movement distance of the displacement data is greater than zero, the current moment is determined as the timing for triggering the next scan; if the displacement data is negative and the cumulative movement distance of the displacement data is less than zero, the image scanning device is determined to be in a reversing movement state, maintaining a scan-awaiting state until the cumulative movement distance is greater than zero, and the current moment is determined as the timing for triggering the next scan when the cumulative movement distance is greater than zero; if the displacement data is positive and the cumulative movement distance of the displacement data is zero, the scan-awaiting state is maintained until the cumulative movement distance is greater than zero, and the current moment is determined as the timing for triggering the next scan when the cumulative movement distance is greater than zero.
[0075] Step S806: Based on the line scan trigger signal, drive the contact image sensor to perform line scan operation to obtain image scan data.
[0076] 1) Real-time preview processing in rollback mode.
[0077] When the movement direction of the image scanning device is detected to be negative, the relative total displacement distance is obtained by accumulating the displacement data detected by the photoelectric sensor. When the relative total displacement distance reaches a preset back-back threshold, a back-back scan is determined to have occurred. After a back-back scan is determined to have occurred, the scan line data corresponding to the back-back scan is marked as invalid data, and the remaining image data after removing the invalid data is used as the image scanning data. The relative total displacement distance is the net displacement value between the starting point and the current position when the processor P1 issues a scan trigger signal.
[0078] Finally, valid data in the original data buffer is read through memory mapping to generate image scan data.
[0079] 2) Real-time preview processing under normal conditions.
[0080] The image scan data is cached in the original data buffer; the image scan data in the original data buffer is read through memory mapping, and color balance, data filtering and coordinate transformation are performed on the image scan data. The processed image scan data is then written into the display buffer; the display synchronization interface is called to preview the image in the display buffer.
[0081] This application also provides an image scanning device based on a contact image sensor, such as... Figure 9As shown, it includes: a detection module 90, configured to detect displacement data characterizing the moving distance of the image scanning device using a photoelectric sensor; a generation module 92, configured to determine the next scan trigger timing based on the displacement data, and generate a line scan trigger signal when the next scan trigger timing arrives; and a driving module 94, configured to drive a contact image sensor to perform a line scan operation based on the line scan trigger signal to obtain image scan data.
[0082] It should be noted that the image scanning device based on a contact image sensor provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the image scanning device based on a contact image sensor provided in the above embodiments and the image scanning method based on a contact image sensor belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0083] This application also provides a scanning method, which differs from the above embodiments mainly in that it introduces a multi-sensor fusion triggering mechanism, specifically including the following steps:
[0084] 1) Photoelectric terminal triggering and multi-source data acquisition.
[0085] When the scanning device begins to move, the processor first reads the displacement data dx output by the photoelectric sensor S2, and simultaneously acquires the acceleration a output by the accelerometer and the angular velocity ω output by the gyroscope, and calculates the image quality index (IQ) of the most recent few rows of RAW images. To improve the stability of trigger judgment, dx, a, and ω are low-pass filtered and normalized to provide a uniform feature scale in subsequent trigger judgments. Specifically, displacement dx represents the actual distance the scanning device moves in the scanning direction; acceleration a reflects whether the user's hand is rapidly shaking or experiencing sudden speed changes; angular velocity ω represents the tilt change of the scanning device; and the image quality score (IQ) is calculated using indicators such as brightness gradient, sharpness, and noise ratio to reflect the quality of the previous row of valid images.
[0086] 2) Triggered by line scan signal
[0087] In this embodiment, the static rule of "dx=1 triggers scanning" is no longer used. Instead, a trigger score T, which integrates multiple features, is constructed based on multi-source data, and it is determined whether this score reaches an adaptive threshold Th. The formula for calculating the trigger score T is:
[0088] in, This represents the normalized displacement, used to measure the effective magnitude of the displacement within the current period. The displacement rate (which can be calculated from dx and the sampling period) is used to measure whether the current movement speed is stable. This represents the normalized acceleration, used to reflect the degree of jitter or sudden velocity changes; The index representing the intensity of hand tremors (generated from the variance of angular velocity ω and the rate of change of acceleration) is used to quantify the degree of hand instability. This is the overall quality score of the previous row of images, used to help determine whether a denser or sparser scan is needed; These are weighted parameters for displacement, velocity, acceleration, jitter, and image quality, which can be fixed or adaptively adjusted according to the mechanical structure of the scanning equipment and user habits.
[0089] Whether to generate a line scan trigger signal is determined by comparing the trigger score T with the adaptive threshold Th. The threshold Th changes dynamically over time, influenced by factors such as the variance of the current scan speed, the average IQ of the most recent few lines of images, and jitter intensity, allowing the judgment criterion of T to automatically adapt to the user's movement rhythm. When T ≥ Th and the cumulative displacement Dx > 0, the system determines that a new scan line position has been reached, and thus sends a line scan trigger signal to the coprocessor. This triggering mechanism effectively avoids false triggers and missed triggers caused by a single displacement signal by fusing multi-dimensional motion and image features.
[0090] 3) Data acquisition timing control.
[0091] Upon receiving the line scan trigger signal, the coprocessor generates the exposure control signal, line synchronization signal, and pixel shift control signal required by the CIS, and inputs them into the AD conversion chip to complete the sampling and digitization of the CIS output analog signal. To compensate for timing offsets caused by high-speed movement, a trigger delay compensation mechanism is added in this embodiment, based on the displacement rate. The timing start point is adjusted forward or backward to more accurately align the sampling position with the actual scanning position. At this point, when dx > 1, indicating that the device has moved more than one line within a single sampling period, the system automatically enters the missing line prediction mode.
[0092] 4) Single-line image data and missing line reconstruction.
[0093] After timing-driven processing is complete, the single-line acquisition data output by the CIS contact image sensor is processed by the AD conversion chip and stored in the RAW[] array. To cope with high-speed movement where dx>1, this embodiment adds a missing line reconstruction function to the traditional "direct writing to RAW array". Based on the data of the previous line and the current real acquisition line, the texture gradient, brightness change rate and other indicators are calculated, and interpolated lines are generated and written to RAW[] to avoid obvious line skipping in the preview image. At this time, the system records the validity of each line through the Raws[] structure, where normal acquisition lines are marked as active=true, interpolated reconstruction lines are marked as estimated=true, and lines that need to be removed due to rollback are marked as active=false. At the same time, the position of continuous rollback segments is recorded through Segments[], which is used to skip or reclaim related lines in subsequent rendering stages.
[0094] 5) Image processing and real-time preview
[0095] In this embodiment, the CisService module performs image enhancement operations such as color calibration, brightness and gamma adjustment, noise reduction, and geometric coordinate correction on the image data of the valid rows in RAW[], and writes the results to the display buffer DisplayBuff, thereby realizing a real-time image preview that grows row by row. Under normal circumstances, as new valid rows are continuously added, the preview area expands synchronously to the bottom, allowing users to see the scanning progress in real time. When the system detects a rollback behavior (i.e., Dx accumulates to a negative value and reaches the preset threshold Db), the corresponding row is marked as invalid. These invalid rows are skipped when generating the preview image, thus presenting an "undo" rollback effect on the user interface. For interpolated reconstructed rows, the system uses a separate rendering strategy based on the estimated flag to keep the transition visually natural without affecting the final image quality. In addition, this embodiment also calculates the IQ value of each row and feeds the result back to step 2) for adaptive updates of the trigger threshold Th for the next scan, thereby forming a closed-loop optimization of "trigger-acquisition-image quality".
[0096] Figure 10 A schematic diagram of a computer device suitable for implementing embodiments of the present disclosure is shown. It should be noted that... Figure 10 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0097] like Figure 10As shown, the computer device includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage section 1008 into a random access memory (RAM) 1003. The RAM 1003 also stores various programs and data required for system operation. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0098] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to I / O interface 1005 as needed. A removable medium 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 1010 as needed so that computer programs read from it can be installed into storage section 1008 as needed.
[0099] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. An image scanning method based on a contact image sensor, characterized in that, include: Displacement data, used to characterize the moving distance of an image scanning device, is detected using photoelectric sensors. Based on the displacement data, the timing for triggering the next scan is determined, and a row scan trigger signal is generated when the timing for triggering the next scan arrives. Based on the row scan trigger signal, the contact image sensor is driven to perform a row scan operation to obtain image scan data.
2. The method according to claim 1, characterized in that, Based on the displacement data, the timing for triggering the next scan is determined, including: When the image scanning device is detected to move in a single direction along the scanning surface, the timing of the next scan is determined based on the displacement data and the time interval between the current reading of the displacement data, wherein the time interval is the time difference between two consecutive readings of the displacement data that are not zero; When the image scanning device is detected to be moving back and forth along the scanning surface, the timing of the next scan is determined based on the displacement data and the cumulative moving distance of the image scanning device.
3. The method according to claim 1, characterized in that, Determining the next scan trigger timing based on the displacement data and the current time interval for reading the displacement data includes: when the displacement data is greater than a preset threshold, predicting the time point at which the target scan interval will be reached next based on the relationship between the time interval and the change in the displacement data, and using this prediction as the next scan trigger timing.
4. The method according to claim 2, characterized in that, Based on the displacement data and the cumulative movement distance of the image scanning device, the timing for triggering the next scan is determined, including: If the displacement data is positive and the cumulative movement distance of the accumulated displacement data is greater than zero, the current moment is determined as the trigger time for the next scan. When the displacement data is negative and the cumulative movement distance of the accumulated displacement data is less than zero, the image scanning device is determined to be in a backward movement state, and the scanning is kept in a waiting state until the cumulative movement distance is greater than zero. When the cumulative movement distance is greater than zero, the current moment is determined as the timing for the next scanning trigger. When the displacement data is positive and the cumulative movement distance of the displacement data is zero, the scanning pending state is maintained until the cumulative movement distance is greater than zero, and when the cumulative movement distance is greater than zero, the current moment is determined as the timing for the next scanning trigger.
5. The method according to claim 1, characterized in that, Drive the contact image sensor to perform line scanning to obtain image scanning data, including: When the movement direction of the image scanning device is detected to be negative, the relative total displacement distance of the previous line scan is obtained by accumulating the displacement data detected by the photoelectric sensor, and when the relative total displacement distance reaches the preset back-back threshold, it is determined that a back-back scan has occurred. Once a backscan is detected, the scan line data corresponding to the backscan is marked as invalid data, and the remaining image data excluding the invalid data is used as the image scan data.
6. The method according to claim 1, characterized in that, After obtaining the image scan data, the method further includes: The image scan data is cached in the original data buffer; Image scan data is read from the original data buffer using memory mapping, and color balance, data filtering, and coordinate transformation are performed on the image scan data. The processed image scan data is then written into the display buffer. Call the display synchronization interface to preview the image in the display buffer.
7. An image scanning device based on a contact image sensor, characterized in that, include: The detection module is configured to use a photoelectric sensor to detect displacement data that characterizes the distance the image scanning device has moved; The generation module is configured to determine the next scan trigger timing based on the displacement data, and generate a row scan trigger signal when the next scan trigger timing arrives; The driving module is configured to drive the contact image sensor to perform a line scanning operation based on the line scanning trigger signal, thereby obtaining image scanning data.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 6.
9. A computer device, characterized in that, include: Memory and processor The memory stores computer programs; The processor is configured to execute a computer program stored in the memory, wherein when the computer program is executed, the processor performs the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
