File scanning method and device, computer equipment and storage medium

By creating local library files and TWAIN API technology, the stability and low efficiency issues of file scanning solutions are solved, cross-platform operation and data security are achieved, and scanning efficiency and compatibility with file management systems are improved.

CN120653701APending Publication Date: 2025-09-16School of Political Science, National Defense University of the Chinese People's Liberation Army +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510613890.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-13
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The existing file scanning solutions have problems with low stability and efficiency, difficulty in achieving cross-platform operation, insufficient data security, and poor integration and compatibility.

Method used

By creating a local library file, including functions and calling interfaces for obtaining scanner information and calling the scanner driver, and using JNI header files to load these interfaces in the Java program, combined with TWAIN API technology, the binary stream data of the scanner is obtained and parsed, and converted into images for storage.

Benefits of technology

It improves the stability and efficiency of scanning, reduces user operating costs, and achieves seamless connection with the archive management system and secure data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653701A_ABST
    Figure CN120653701A_ABST
Patent Text Reader

Abstract

The invention relates to a file scanning method and device, computer equipment and a storage medium, and the method comprises the steps: creating a local library file, which comprises a function used for obtaining scanner information and a calling interface thereof, and a function used for calling a scanner driver and a calling interface thereof; creating a JNI header file, and loading a local library file in a Java program; calling a calling interface of a function for acquiring scanner information, acquiring all available scanners, and outputting the scanners to a browser for a user to select and confirm; after the user selects and confirms the target scanner, calling a calling interface for calling a function driven by the scanner, and starting scanning by the target scanner; obtaining and analyzing binary stream data returned by the target scanner; and converting the binary stream data into pictures for storage. Through the file scanning method and device, the problem that a file scanning scheme in the related technology is low in stability and efficiency is solved, and the effects of reducing the user operation cost and improving the scanning stability and efficiency are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a file scanning method, device, computer equipment and storage medium. Background Art

[0002] Digital processing of personnel records is a crucial task in personnel file management. Traditionally, scanning personnel records relies on manual labor, using a scanner to scan each page of paper documents and then saving the scans to a computer. This method is inefficient and susceptible to human error. Improper operation can result in poor scan quality and even damage or loss of file information. With the continuous advancement of information technology, developing an efficient, accurate, and secure method for scanning personnel records has become an urgent need within the industry.

[0003] While some automated scanning solutions currently available on the market can improve scanning efficiency, they still have numerous shortcomings. These solutions often rely on specific hardware devices or software platforms, making cross-platform operation difficult. Furthermore, data security protection is insufficient, posing the risk of information leakage or tampering. Furthermore, due to a lack of unified standards and specifications, these solutions lack integration and compatibility, making it difficult to seamlessly integrate with existing archive management systems.

[0004] Currently, the file scanning solutions in related technologies have problems of low stability and efficiency, and no effective solutions have been proposed yet. Summary of the Invention

[0005] The purpose of this application is to address the deficiencies in the prior art and provide a file scanning method, apparatus, computer equipment and storage medium to at least solve the problems of low stability and efficiency of file scanning solutions in related technologies.

[0006] To achieve the above objectives, the technical solutions adopted in this application are:

[0007] In a first aspect, an embodiment of the present application provides a file scanning method, comprising:

[0008] Creating a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling a scanner driver and its calling interface;

[0009] Create a JNI header file and load the native library file in the Java program;

[0010] Calling the calling interface of the function for obtaining scanner information in the local library file to obtain all available scanners, and outputting all available scanners to the browser for user selection and confirmation;

[0011] After the user selects and confirms a target scanner from all available scanners, a calling interface for invoking a scanner driver function is called, and the target scanner starts scanning;

[0012] Obtain and parse the binary stream data returned by the target scanner;

[0013] The binary stream data is converted into a picture for storage.

[0014] In some embodiments, creating a local library file includes:

[0015] Create a header file to define the functions that can be called by the Java program;

[0016] Writing the source file of the callable function;

[0017] The source file is compiled into a dynamic link library, wherein the dynamic link library is loaded in a Java program through JNI, and the callable function is called.

[0018] In some embodiments, the design process of the function for obtaining scanner information includes:

[0019] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0020] Use the TWAIN API's enumeration function to output all available scanners;

[0021] Selecting a target scanner from all available scanners through the user interface;

[0022] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0023] Use the query function of the TWAIN API to query the attribute parameters of the target scanner;

[0024] After acquiring the attribute parameters of the target scanner, calling the close function of the TWAIN API to close the connection with the target scanner;

[0025] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0026] In some embodiments, the design process for invoking a scanner driver function includes:

[0027] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0028] Use the TWAIN API's enumeration function to output all available scanners;

[0029] Selecting a target scanner from all available scanners through the user interface;

[0030] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0031] Configuring scanning parameters of the target scanner;

[0032] After configuring the scanning parameters of the target scanner, starting the target scanner to scan and receive scan data;

[0033] After the target scanner finishes scanning, the scan data is acquired using the TWAIN API;

[0034] After acquiring the scanned data, calling the close function of the TWAIN API to close the connection with the target scanner;

[0035] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0036] In some embodiments, obtaining and parsing the binary stream data returned by the target scanner includes:

[0037] Using the java.io.InputStream object to read the binary stream data;

[0038] Parsing and verifying the binary stream data;

[0039] If the verification passes, the step of converting the binary stream data into a picture for storage is performed.

[0040] In some embodiments, parsing and verifying the binary stream data includes:

[0041] Read a specified number of bytes of the binary stream data to verify the file signature;

[0042] Parsing the markers in the binary stream data to verify whether the markers comply with the JPEG standard;

[0043] Parsing data segments in the binary stream data to verify whether the data segments comply with the JPEG standard;

[0044] Monitor whether there are any abnormalities in the reading and parsing process of the binary stream data.

[0045] In some embodiments, converting the binary stream data into a picture for storage includes:

[0046] Convert the binary stream data in InputStream into a byte array;

[0047] Create a FileOutputStream pointing to the target file path;

[0048] The byte array is written into the FileOutputStream to save the image corresponding to the binary stream data to the target file path.

[0049] In a second aspect, an embodiment of the present application provides a document scanning device, comprising:

[0050] A first creating unit is configured to create a local library file, wherein the local library file includes: a function for obtaining scanner information and a calling interface thereof, a function for calling a scanner driver and a calling interface thereof;

[0051] The second creation unit is used to create a JNI header file and load the native library file in the Java program;

[0052] A first calling unit is configured to call the calling interface of the function for obtaining scanner information in the local library file, obtain all available scanners, and output all available scanners to the browser for user selection and confirmation;

[0053] A second calling unit is configured to call a calling interface for invoking a scanner driver function after the user selects and confirms a target scanner from all available scanners, and the target scanner starts scanning;

[0054] an acquisition unit, configured to acquire and parse the binary stream data returned by the target scanner;

[0055] The storage unit is used to convert the binary stream data into images for storage.

[0056] In a third aspect, an embodiment of the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the file scanning method as described in the first aspect above is implemented.

[0057] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the file scanning method as described in the first aspect above.

[0058] The present application adopts the above technical solution. Compared with the existing technology, the file scanning method provided by the embodiment of the present application creates a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling the scanner driver and its calling interface; creates a JNI header file and loads the local library file in a Java program; calls the calling interface of the function for obtaining scanner information in the local library file to obtain all available scanners, and outputs all the available scanners to the browser for user selection and confirmation; after the user selects and confirms the target scanner from all the available scanners, calls the calling interface of the function for calling the scanner driver, and the target scanner starts scanning; obtains and parses the binary stream data returned by the target scanner; converts the binary stream data into images for storage, thereby solving the problems of low stability and efficiency of the file scanning solution in the related technology, and achieving the effect of reducing user operation costs and improving scanning stability and efficiency.

[0059] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0061] Figure 1 is a structural block diagram of a mobile terminal according to an embodiment of the present application;

[0062] Figure 2 is a flowchart of a file scanning method according to an embodiment of the present application;

[0063] Figure 3 Schematic diagram of the execution process of the personnel file material scanning method according to the preferred embodiment of the present application;

[0064] Figure 4 is a structural block diagram of a document scanning device according to an embodiment of the present application;

[0065] Figure 5 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is described and illustrated below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely used to explain this application and are not intended to limit this application. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without making any creative efforts are within the scope of protection of this application.

[0067] Obviously, the drawings described below are merely examples or embodiments of the present application. Those skilled in the art can, without inventive effort, apply the present application to other similar scenarios based on these drawings. Furthermore, it is also understood that, although the effort involved in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, changes in design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as an insufficiency of the content disclosed in this application.

[0068] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.

[0069] Unless otherwise defined, the technical or scientific terms used in this application should have the ordinary meaning understood by a person of ordinary skill in the technical field to which this application belongs. The words "one", "a", "the" and the like used in this application do not indicate a limit on quantity and may indicate the singular or plural. The terms "include", "comprise", "have" and any variations thereof used in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units that are inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The word "multiple" used in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.

[0070] This embodiment provides a mobile terminal. Figure 1 : is a structural block diagram of a mobile terminal according to an embodiment of the present application. Figure 1 As shown, the mobile terminal includes components such as a radio frequency (RF) circuit 110, a memory 120, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a wireless fidelity (WiFi) module 170, a processor 180, and a power supply 190. Those skilled in the art will understand that Figure 1 The structure of the mobile terminal shown in the figure does not constitute a limitation to the mobile terminal, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0071] The following combination Figure 1 A detailed introduction to the various components of the mobile terminal:

[0072] The RF circuit 110 can be used to receive and send signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is sent to the processor 180 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 110 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0073] The memory 120 can be used to store software programs and modules. The processor 180 executes various functional applications and data processing of the mobile terminal by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created based on the use of the mobile terminal (such as audio data, a phone book, etc.). In addition, the memory 120 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0074] The input unit 130 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile terminal. Specifically, the input unit 130 may include a touch panel 131 and other input devices 132. The touch panel 131, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 131) and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 131 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal caused by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 180, and can receive commands sent by the processor 180 and execute them. In addition, the touch panel 131 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 131, the input unit 130 may further include other input devices 132. Specifically, the other input devices 132 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick.

[0075] The display unit 140 can be used to display information input by the user or information provided to the user and various menus of the mobile terminal. The display unit 140 may include a display panel 141. Optionally, the display panel 141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 131 may cover the display panel 141. When the touch panel 131 detects a touch operation on or near it, it is transmitted to the processor 180 to determine the type of touch event. Subsequently, the processor 180 provides corresponding visual output on the display panel 141 according to the type of touch event. Although in Figure 1 In the embodiment, the touch panel 131 and the display panel 141 are used as two independent components to implement the input and output functions of the mobile terminal. However, in some embodiments, the touch panel 131 and the display panel 141 can be integrated to implement the input and output functions of the mobile terminal.

[0076] The mobile terminal may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 141 and / or the backlight when the mobile terminal is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile terminal (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile terminal, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be described here.

[0077] The speaker 161 and microphone 162 in the audio circuit 160 provide an audio interface between the user and the mobile terminal. The audio circuit 160 converts received audio data into electrical signals and transmits them to the speaker 161, which then converts the signals into sound signals for output. Furthermore, the microphone 162 converts the collected sound signals into electrical signals, which are then received by the audio circuit 160 and converted into audio data. The audio data is then processed by the processor 180 and transmitted to, for example, another mobile terminal via the RF circuit 110, or the audio data is output to the memory 120 for further processing.

[0078] WiFi is a short-range wireless transmission technology. Mobile terminals can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 170. It provides users with wireless broadband Internet access. Figure 1 A WiFi module 170 is shown, but it is understandable that it is not an essential component of the mobile terminal and can be omitted as needed without changing the essence of the invention, or replaced with other short-range wireless transmission modules, such as a Zigbee module or a WAPI module.

[0079] The processor 180 is the control center of the mobile terminal, connecting all components of the mobile terminal using various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 120 and accessing data stored in the memory 120, it executes various functions of the mobile terminal and processes data, thereby providing overall monitoring of the mobile terminal. Optionally, the processor 180 may include one or more processing units; preferably, the processor 180 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 180.

[0080] The mobile terminal also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 180 through a power management system, thereby managing charging, discharging, and power consumption through the power management system.

[0081] Although not shown, the mobile terminal may further include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0082] In this embodiment, the processor 180 is configured to:

[0083] Creating a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling a scanner driver and its calling interface;

[0084] Create a JNI header file and load the native library file in the Java program;

[0085] Calling the calling interface of the function for obtaining scanner information in the local library file to obtain all available scanners, and outputting all available scanners to the browser for user selection and confirmation;

[0086] After the user selects and confirms a target scanner from all available scanners, a calling interface for invoking a scanner driver function is called, and the target scanner starts scanning;

[0087] Obtain and parse the binary stream data returned by the target scanner;

[0088] The binary stream data is converted into a picture for storage.

[0089] In some embodiments, the processor 180 is further configured to:

[0090] Create a header file to define the functions that can be called by the Java program;

[0091] Writing the source file of the callable function;

[0092] The source file is compiled into a dynamic link library, wherein the dynamic link library is loaded in a Java program through JNI, and the callable function is called.

[0093] In some embodiments, the processor 180 is further configured to:

[0094] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0095] Use the TWAIN API's enumeration function to output all available scanners;

[0096] Selecting a target scanner from all available scanners through the user interface;

[0097] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0098] Use the query function of the TWAIN API to query the attribute parameters of the target scanner;

[0099] After acquiring the attribute parameters of the target scanner, calling the close function of the TWAIN API to close the connection with the target scanner;

[0100] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0101] In some embodiments, the processor 180 is further configured to:

[0102] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0103] Use the TWAIN API's enumeration function to output all available scanners;

[0104] Selecting a target scanner from all available scanners through the user interface;

[0105] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0106] Configuring scanning parameters of the target scanner;

[0107] After configuring the scanning parameters of the target scanner, starting the target scanner to scan and receive scan data;

[0108] After the target scanner finishes scanning, the scan data is acquired using the TWAIN API;

[0109] After acquiring the scanned data, calling the close function of the TWAIN API to close the connection with the target scanner;

[0110] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0111] In some embodiments, the processor 180 is further configured to:

[0112] Using the java.io.InputStream object to read the binary stream data;

[0113] Parsing and verifying the binary stream data;

[0114] If the verification passes, the step of converting the binary stream data into a picture for storage is performed.

[0115] In some embodiments, the processor 180 is further configured to:

[0116] Read a specified number of bytes of the binary stream data to verify the file signature;

[0117] Parsing the markers in the binary stream data to verify whether the markers comply with the JPEG standard;

[0118] Parsing data segments in the binary stream data to verify whether the data segments comply with the JPEG standard;

[0119] Monitor whether there are any abnormalities in the reading and parsing process of the binary stream data.

[0120] In some embodiments, the processor 180 is further configured to:

[0121] Convert the binary stream data in InputStream into a byte array;

[0122] Create a FileOutputStream pointing to the target file path;

[0123] The byte array is written into the FileOutputStream to save the image corresponding to the binary stream data to the target file path.

[0124] This embodiment provides a file scanning method. Figure 2 is a flowchart of a file scanning method according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:

[0125] Step S201: creating a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling a scanner driver and its calling interface;

[0126] Step S202, creating a JNI header file and loading the native library file in the Java program;

[0127] Step S203, calling the calling interface of the function for obtaining scanner information in the local library file to obtain all available scanners, and outputting all available scanners to the browser for user selection and confirmation;

[0128] Step S204: After the user selects and confirms a target scanner from all available scanners, a calling interface for invoking a scanner driver function is called, and the target scanner starts scanning.

[0129] Step S205, acquiring and parsing the binary stream data returned by the target scanner;

[0130] Step S206: Convert the binary stream data into a picture for storage.

[0131] In the above step S201, the embodiment of the present application uses C language to write a native library for Java to call. The specific creation process may include:

[0132] Create a header file to define the functions that can be called by the Java program;

[0133] Writing the source file of the callable function;

[0134] The source file is compiled into a dynamic link library, wherein the dynamic link library is loaded in a Java program through JNI, and the callable function is called.

[0135] This embodiment of the application creates a C header file (.h) to define the functions called by the Java program (for example, the function " / scan / deviceNames" for obtaining scanner information and the function " / scan / do" for calling the scanner driver); writes a source file (.c) to implement the functions declared in the header file; and compiles the source file into a dynamic link library (.dll). Java then loads and uses these functions through the JNI (Java Native Interface). This embodiment of the application enables Java code to load a dynamic link library through JNI and call functions in the native library.

[0136] In some embodiments, the design process of the function for obtaining scanner information and its calling interface " / scan / deviceNames" may include:

[0137] Initialize the TWAIN environment: call the TWAIN API initialization function DS_Entry() to start the TWAIN data source manager;

[0138] Enumerate data sources: Use the TWAIN API enumeration function DSM_EnumDataSources() to output all available data sources (scanners);

[0139] Select data source: select a specific data source DSM_SelectDataSource() through the user interface (UI), that is, select the target scanner from all available scanners;

[0140] Open the data source: call the open function DSM_OpenDS() of the TWAIN API to open the selected data source (i.e., the target scanner) and establish a connection with the target scanner;

[0141] Get scanner information: Use the query function DSM_Capability() of the TWAIN API to query the attribute parameters of the target scanner, such as resolution, color mode, etc.;

[0142] Close the data source: after obtaining the attribute parameters of the target scanner, call the TWAIN API close function DSM_CloseDS() to close the connection with the target scanner;

[0143] Clean up the TWAIN environment: call the exit function DS_Exit() of the TWAIN API to release all resources and exit the TWAIN data source manager.

[0144] The embodiment of the present application uses C language to develop a local library, combined with TWAIN API technology, to obtain the scanner information connected to the computer and define an interface (" / scan / deviceNames", which is the calling interface of the function used to obtain scanner information) for background calling.

[0145] In some embodiments, the design process of the function for invoking the scanner driver and its calling interface (" / scan / do") may include:

[0146] Initialize the TWAIN environment: call the TWAIN API initialization function DS_Entry() to start the TWAIN data source manager;

[0147] Enumerate data sources: Use the TWAIN API enumeration function DSM_EnumDataSources() to output all available data sources (scanners);

[0148] Select data source: select a specific data source DSM_SelectDataSource() through the user interface, that is, select the target scanner from all available scanners;

[0149] Open the selected data source: call the open function DSM_OpenDS() of the TWAIN API, open the target scanner through the data source ID (DSID) obtained from DSM_EnumDataSources(), and establish a connection with the target scanner;

[0150] Configure scanning parameters: Configure scanning parameters as needed, and adjust the configuration directly on the activated scanner driver visual interface, such as resolution, color mode, scanning area, etc.

[0151] Start Scanning: After configuring the scanning parameters for the target scanner, click the Scan button on the scanner driver's visual interface to start the scanning process. The scanner driver starts working, scanning the document and preparing to receive the scanned data.

[0152] Get scan data: Once the scan is complete, use the TWAIN API to get the scanned image data, which usually involves data conversion and buffer management;

[0153] Close the data source: After acquiring the scanned data, call the TWAIN API close function DSM_CloseDS() to close the connection with the target scanner;

[0154] Clean up the TWAIN environment: call the exit function DS_Exit() of the TWAIN API to release all resources and exit the TWAIN data source manager.

[0155] The embodiment of the present application utilizes C language to develop a local library, combined with TWAIN API technology, to call up the Windows scanner driver and define an interface (" / scan / do") for background calling.

[0156] After creating the local library, the background can call the local library. The specific execution process is as follows Figure 3 The specific description is as follows:

[0157] 1. Interface call.

[0158] Create a JNI header file: Use the javac -h command to generate a JNI header file from the Java class, which contains the C language signatures of the " / scan / deviceNames" and " / scan / do" methods declared in Java.

[0159] Loading native libraries in Java: Use the System.loadLibrary method to load the generated dynamic link library.

[0160] When Java executes the " / scan / deviceNames" and " / scan / do" method calls, the corresponding C language functions in the native library are executed instead.

[0161] 2. Get the scanner list by calling the / scan / deviceNames interface in the local library, return the output to the browser, and the user confirms the selection of the scanner.

[0162] 3. The user operates in the browser, and the background calls the interface " / scan / do", which pops up the scan driver interface for scanning.

[0163] 4. Parse the binary stream of the image returned after the scan is completed.

[0164] As an optional embodiment, the step S205 may include: using a java.io.InputStream object to read the binary stream data; parsing and verifying the binary stream data; if the verification passes, executing the step S206.

[0165] Specifically, parsing and verifying the binary stream data may include:

[0166] Read a specified number of bytes of the binary stream data to verify the file signature;

[0167] Parsing the markers in the binary stream data to verify whether the markers comply with the JPEG standard;

[0168] Parsing data segments in the binary stream data to verify whether the data segments comply with the JPEG standard;

[0169] Monitor whether there are any abnormalities in the reading and parsing process of the binary stream data.

[0170] During the above parsing and verification process:

[0171] Check the file signature: Read the first few bytes of the stream to verify the file signature. JPG files start with 0xFF, 0xD8. Use the InputStream.read(byte[]b,int off,int len) method to read the specified number of bytes into an array and then check the value in the array.

[0172] Parsing the JPEG structure: JPG files follow the JPEG standard and consist of a series of markers. Each marker begins with 0xFF and is followed by a marker code. These markers can be parsed to verify compliance with the JPEG specification. The SOF (Start of Frame) marker is examined to determine the basic parameters of the image.

[0173] Verify image data: Continue parsing the data segments in the stream, including the Huffman tables and scan components. Verify that these segments conform to the JPEG standard and check the validity of the quantization tables and Huffman tables.

[0174] Exception handling: During the reading and parsing process, if you encounter an IOException due to reasons such as file corruption, format error, or end of stream, use a try-catch block to catch these exceptions and handle them appropriately, log the error, and return error information.

[0175] After the above verification is performed, a result may be returned, that is, a Boolean value is returned according to the verification result, indicating whether the JPG image of this binary stream is available.

[0176] 5. Convert binary stream and store the image.

[0177] As an optional embodiment, step S206 may include:

[0178] Convert the binary stream data in InputStream into a byte array;

[0179] Create a FileOutputStream pointing to the target file path;

[0180] The byte array is written into the FileOutputStream to save the image corresponding to the binary stream data to the target file path.

[0181] In the embodiment of the present application, the InputStream.read(buffer) method can be used to convert the binary stream in the InputStream into a byte array byte[]buffer, create a FileOutputStream to point to the target file path, and use the write(byte[],int,int) method to write the byte array to the output stream, and finally save the image to the hard disk.

[0182] In this application, users only need to simply select the scanner and scanning method to easily complete single-page or multi-page continuous scanning, and finally scan and save the files (such as personnel file materials) directly into the system, which greatly reduces the user's operating costs and improves the stability and efficiency of scanning.

[0183] This application effectively avoids scanning quality problems caused by human operation through excellent scanning process design, and improves the accuracy of archival information.

[0184] This application uses WIA programming to call Windows drivers, which is safer and more reliable than traditional scanning methods, and effectively avoids the risk of file information loss or damage.

[0185] The scanning method in this application has good integration and compatibility, and can be easily connected with various file management systems to achieve seamless transmission and sharing of data.

[0186] To sum up, this application can be applied in the field of personnel file material scanning, has significant advantages and innovations, and provides strong technical support for the digitalization process in the industry.

[0187] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0188] This embodiment provides a document scanning device for implementing the above-described embodiments and preferred implementations. Details already described will not be repeated. As used below, terms such as "module," "unit," and "subunit" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented using software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.

[0189] Figure 4 is a structural block diagram of a file scanning device according to an embodiment of the present application, such as Figure 4 As shown, the device includes:

[0190] The first creation unit 41 is used to create a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling a scanner driver and its calling interface;

[0191] The second creating unit 42 is used to create a JNI header file and load the native library file in the Java program;

[0192] A first calling unit 43 is configured to call the calling interface of the function for obtaining scanner information in the local library file, obtain all available scanners, and output all available scanners to the browser for user selection and confirmation;

[0193] The second calling unit 44 is configured to call a calling interface for invoking a scanner driver function after the user selects and confirms a target scanner from all available scanners, and the target scanner starts scanning;

[0194] An acquisition unit 45 is configured to acquire and parse the binary stream data returned by the target scanner;

[0195] The storage unit 46 is configured to convert the binary stream data into images for storage.

[0196] In some embodiments, the first creating unit 41 includes:

[0197] The first creation module is used to create a header file and define functions that can be called by the Java program;

[0198] A writing module for writing the source file of the callable function;

[0199] A compiling module is used to compile the source file into a dynamic link library, wherein the dynamic link library is loaded in a Java program through JNI and the callable function is called.

[0200] In some embodiments, the design process of the function for obtaining scanner information includes:

[0201] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0202] Use the TWAIN API's enumeration function to output all available scanners;

[0203] Selecting a target scanner from all available scanners through the user interface;

[0204] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0205] Use the query function of the TWAIN API to query the attribute parameters of the target scanner;

[0206] After acquiring the attribute parameters of the target scanner, calling the close function of the TWAIN API to close the connection with the target scanner;

[0207] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0208] In some embodiments, the design process for invoking a scanner driver function includes:

[0209] Call the initialization function of the TWAIN API to start the TWAIN data source manager;

[0210] Use the TWAIN API's enumeration function to output all available scanners;

[0211] Selecting a target scanner from all available scanners through the user interface;

[0212] Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner;

[0213] Configuring scanning parameters of the target scanner;

[0214] After configuring the scanning parameters of the target scanner, starting the target scanner to scan and receive scan data;

[0215] After the target scanner finishes scanning, the scan data is acquired using the TWAIN API;

[0216] After acquiring the scanned data, calling the close function of the TWAIN API to close the connection with the target scanner;

[0217] The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

[0218] In some embodiments, the obtaining unit 45 includes:

[0219] A reading module, configured to read the binary stream data using a java.io.InputStream object;

[0220] A verification module, configured to parse and verify the binary stream data;

[0221] The execution module is used to execute the step of converting the binary stream data into a picture for storage if the verification passes.

[0222] In some embodiments, the verification module includes:

[0223] A first verification submodule is configured to read a specified number of bytes of the binary stream data to verify a file signature;

[0224] A second verification submodule is configured to parse the mark in the binary stream data and verify whether the mark complies with the JPEG standard;

[0225] a third verification submodule, configured to parse data segments in the binary stream data and verify whether the data segments comply with the JPEG standard;

[0226] The monitoring submodule is used to monitor whether there are any abnormalities in the reading and parsing process of the binary stream data.

[0227] In some embodiments, the storage unit 46 includes:

[0228] The conversion module is used to convert the binary stream data in InputStream into a byte array;

[0229] The second creation module is used to create a FileOutputStream pointing to the target file path;

[0230] A writing module is used to write the byte array into the FileOutputStream to save the image corresponding to the binary stream data to the target file path.

[0231] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0232] The embodiment provides a computer device. In conjunction with the file scanning method of the embodiment of the present application, the computer device can be used to implement the file scanning method. Figure 5 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application.

[0233] The computer device may include a processor 51 and a memory 52 storing computer program instructions.

[0234] Specifically, the processor 51 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0235] Among them, the memory 52 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 52 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 52 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 52 may be inside or outside the data processing device. In a specific embodiment, the memory 52 is a non-volatile memory. In a specific embodiment, the memory 52 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), where the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0236] The memory 52 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 51 .

[0237] The processor 51 reads and executes computer program instructions stored in the memory 52 to implement any one of the file scanning methods in the above embodiments.

[0238] In some embodiments, the computer device may further include a communication interface 53 and a bus 50. Figure 5 As shown, the processor 51, the memory 52, and the communication interface 53 are connected via a bus 50 and communicate with each other.

[0239] The communication interface 53 is used to implement communication between the various modules, devices, units, and / or devices in the embodiments of the present application. The communication interface 53 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.

[0240] The bus 50 includes hardware, software, or both, and couples components of a computer device to each other. The bus 50 includes, but is not limited to, at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 50 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Bus 50 may include one or more buses, where appropriate. Although embodiments herein describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.

[0241] In addition, in conjunction with the file scanning method in the above embodiments, the present application embodiment can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any of the file scanning methods in the above embodiments is implemented.

[0242] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0243] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A file scanning method, characterized in that: include: Creating a local library file, wherein the local library file includes: a function for obtaining scanner information and its calling interface, a function for calling a scanner driver and its calling interface; Create a JNI header file and load the native library file in the Java program; Calling the calling interface of the function for obtaining scanner information in the local library file to obtain all available scanners, and outputting all available scanners to the browser for user selection and confirmation; After the user selects and confirms a target scanner from all available scanners, a calling interface for invoking a scanner driver function is called, and the target scanner starts scanning; Obtain and parse the binary stream data returned by the target scanner; The binary stream data is converted into a picture for storage.

2. The method according to claim 1, characterized in that The creation of a local library file includes: Create a header file to define the functions that can be called by the Java program; Writing the source file of the callable function; The source file is compiled into a dynamic link library, wherein the dynamic link library is loaded in a Java program through JNI, and the callable function is called.

3. The method according to claim 2, characterized in that The design process of the function for obtaining scanner information includes: Call the initialization function of the TWAIN API to start the TWAIN data source manager; Use the TWAIN API's enumeration function to output all available scanners; Selecting a target scanner from all available scanners through the user interface; Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner; Use the query function of the TWAIN API to query the attribute parameters of the target scanner; After acquiring the attribute parameters of the target scanner, calling the close function of the TWAIN API to close the connection with the target scanner; The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

4. The method according to claim 2, characterized in that The design process of the function for calling the scanner driver includes: Call the initialization function of the TWAIN API to start the TWAIN data source manager; Use the TWAIN API's enumeration function to output all available scanners; Selecting a target scanner from all available scanners through the user interface; Calling the open function of the TWAIN API to open the target scanner and establish a connection with the target scanner; Configuring scanning parameters of the target scanner; After configuring the scanning parameters of the target scanner, starting the target scanner to scan and receive scan data; After the target scanner finishes scanning, the scan data is acquired using the TWAIN API; After acquiring the scanned data, calling the close function of the TWAIN API to close the connection with the target scanner; The exit function of the TWAIN API is called to release all resources and exit the TWAIN data source manager.

5. The method according to claim 1, characterized in that The acquiring and parsing of the binary stream data returned by the target scanner includes: Using the java.io.InputStream object to read the binary stream data; Parsing and verifying the binary stream data; If the verification passes, the step of converting the binary stream data into a picture for storage is performed.

6. The method according to claim 5, characterized in that The parsing and checking of the binary stream data includes: Read a specified number of bytes of the binary stream data to verify the file signature; Parsing the markers in the binary stream data to verify whether the markers comply with the JPEG standard; Parsing data segments in the binary stream data to verify whether the data segments comply with the JPEG standard; Monitor whether there are any abnormalities in the reading and parsing process of the binary stream data.

7. The method according to claim 5, characterized in that The converting the binary stream data into a picture for storage includes: Convert the binary stream data in InputStream into a byte array; Create a FileOutputStream pointing to the target file path; The byte array is written into the FileOutputStream to save the image corresponding to the binary stream data to the target file path.

8. A document scanning device, characterized in that: include: A first creating unit is configured to create a local library file, wherein the local library file includes: a function for obtaining scanner information and a calling interface thereof, a function for calling a scanner driver and a calling interface thereof; The second creation unit is used to create a JNI header file and load the native library file in the Java program; A first calling unit is configured to call the calling interface of the function for obtaining scanner information in the local library file, obtain all available scanners, and output all available scanners to the browser for user selection and confirmation; A second calling unit is configured to call a calling interface for invoking a scanner driver function after the user selects and confirms a target scanner from all available scanners, and the target scanner starts scanning; an acquisition unit, configured to acquire and parse the binary stream data returned by the target scanner; The storage unit is used to convert the binary stream data into images for storage.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Image acquisition method based on virtual hardware device

    CN102289416A

  • Embedded device and method for rapidly detecting whether JPEG picture files are right or not

    CN104536843A

  • A device scanning method and a device based on a TWAIN protocol

    CN109086087A

  • Scanner mapping method on cloud desktop and terminal thereof

    CN116156069A

  • System and methods for acquiring images from imaging devices

    US20030177448A1