Disclosure of Invention
The technical problem to be solved by the invention is how to achieve a good balance between transmission speed and data size.
To this end, according to a first aspect, an example of the present invention provides a data transmission method, including: detecting the type of a transmission interface of the scanning data; when the type of the transmission interface is a network interface, detecting the transmission speed of the current network; and selecting a corresponding data format for transmission according to the current network transmission speed.
Optionally, when the type of the transmission interface is a communication serial bus interface, the uncompressed data format is selected to transmit the scanning data.
Optionally, selecting a corresponding data format for transmission according to the current network transmission speed includes: acquiring scanning parameters; calculating the theoretical transmission speed of the current scanning data according to the scanning parameters; judging whether the current transmission speed is less than the theoretical transmission speed; and when the current transmission speed is lower than the theoretical transmission speed, selecting a compressed data format for transmission.
Optionally, when the current transmission speed is greater than the theoretical transmission speed, the uncompressed data format pair is selected for transmission.
Optionally, selecting the compressed data format for transmission includes: calculating a transmission ratio of the theoretical transmission speed and the actual transmission speed; and determining the compression format and compression ratio of the scanning data according to the transmission ratio.
Optionally, the determining the compression format and the compression ratio of the scan data according to the transmission ratio comprises: detecting a scanning mode of the scanning data; when the scanning mode is continuous multi-page scanning, detecting the memory allowance of the receiving end; and dynamically adjusting the compression format and the compression ratio according to the transmission ratio and the memory margin.
According to a second aspect, an embodiment of the present invention provides a data transmission apparatus, including: the first detection module is used for detecting the transmission interface type of the scanning data; the first detection module is used for detecting the transmission speed of the current network when the first detection module detects that the transmission interface type is a network interface; and the transmission module is used for selecting a corresponding data format for transmission according to the current network transmission speed.
Optionally, the data transmission apparatus further includes: and the selection module is used for selecting a non-compressed data format to transmit the scanning data when the first detection module detects that the transmission interface type is the communication serial bus interface.
Optionally, the transmission module comprises: an acquisition unit configured to acquire a scanning parameter; the calculating unit is used for calculating the theoretical transmission speed of the current scanning data according to the scanning parameters; the judging unit is used for judging whether the current transmission speed is smaller than the theoretical transmission speed or not; and the first selection unit is used for selecting a compressed data format to transmit the scanning data when the judgment unit judges that the current transmission speed is less than the theoretical transmission speed.
Optionally, the second selecting unit is configured to select a uncompressed data format pair for transmission when the determining unit determines that the current transmission speed is greater than the theoretical transmission speed.
Optionally, the first selection unit includes: a calculating subunit, configured to calculate a transmission ratio of the theoretical transmission speed and the actual transmission speed; and the determining subunit is used for determining the compression format and the compression ratio of the scanning data according to the transmission ratio.
Optionally, the determining the subunit comprises: a first detection subunit, configured to detect a scanning pattern of the scanning data; the second detection subunit is used for detecting the memory allowance of the receiving end when the first detection subunit detects that the scanning mode is continuous multi-page scanning; and the adjusting subunit is used for dynamically adjusting the compression format and the compression ratio according to the transmission ratio and the memory margin.
According to a third aspect, an embodiment of the present invention provides an electronic device, including: the data transmission method comprises a memory and a processor, wherein the memory and the processor are connected with each other through a bus, computer instructions are stored in the memory, and the processor executes the computer instructions to execute the data transmission method described in any one of the first aspect.
The embodiment of the invention provides a data transmission method, a data transmission device and electronic equipment. The data transmission method can select different data formats for transmission according to different transmission interfaces, the transmission interface with higher transmission speed can transmit data with larger data volume, for example, uncompressed data is not needed, the output interface with lower or unstable transmission speed can select the corresponding data format for transmission according to the current transmission speed, the transmission speed can be ensured, the problems of scanning pause, image splicing and slow transmission in the scanning transmission process can be avoided, the larger data volume can be transmitted as far as possible under the current transmission condition, and better balance between the transmission speed and the data volume can be achieved.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a data transmission method, as shown in fig. 1, including the following steps:
and S10, detecting the type of a transmission interface of the scanning data. In this embodiment, the type of the transmission interface may be detected before scanning, may be detected in a scanning process, or may be detected after scanning, specifically, the type of the transmission interface may be determined by a communication protocol of the interface, and in this embodiment, the type of the transmission interface may include a universal serial bus interface, that is, a USB interface, and a network interface; wherein the network interface may include a wired network and a wireless network. When detecting that the transmission interface type is a network interface, the flow proceeds to step S20. When detecting that the type of the transmission interface is the universal serial bus interface, the flow proceeds to step S40.
And S20, detecting the transmission speed of the current network. In particular embodiments, the network transport speed may be affected by factors of the printer/scanner hardware or the network transport device, such as the performance of the network card, the material and length of the network link. The network transmission speed may also be affected by a network environment, and meanwhile, when there are many online devices, network delay may be caused, and specifically, in this implementation, an upper limit value of the current network transmission speed may be detected, a lower limit value of the current network transmission speed may also be detected, and an average transmission speed of the network within a period of time may also be detected.
And S30, selecting a corresponding data format for transmission according to the current network transmission speed. In particular embodiments, after detecting the current network transmission speed, the size of the scan data that can be transmitted may be selected based on the current network transmission speed. In the present embodiment, the size of the scan data is related to the scan resolution of the printer/scanner. The higher the resolution, the larger the scan data. The size of the scanning data is also related to the scanning parameters such as pixel bit number, color mode and the like. In the present embodiment, the transmission speed of the scanned data is also related to the amount of data scanned per unit time, i.e., the scanning speed, and the larger the scanning speed, the larger the amount of data scanned per unit time, and the higher the network transmission speed required for data transmission. . The data compression in a certain compression format is much smaller than the data amount of the original scan data which is not processed, specifically, different compression ratios and different compression formats can be adopted for data compression, the data amount after compression is different, and the higher the compression ratio is, the worse the picture quality after compression is. In this embodiment, the specific format to be selected for transmission depends on the transmission speed of the current network. The network transmission speed is high, the data can be transmitted by adopting the RAW data (uncompressed data) with a low compression ratio or even without compressing the data. When the current network transmission speed is low, a higher compression ratio can be adopted for transmission. A reasonable balance between transmission speed and picture quality of the scanned data can be achieved.
And S40, selecting a non-compressed data format to transmit the scanning data. In this embodiment, since the transmission speed of the communication serial bus interface is relatively stable, the transmission speed is relatively high, for example, the USB2.0 transmission rate reaches 480Mbps, which is converted into MB of 60MB/s, the theoretical speed of the USB3.0 is 5.0Gb/s, and currently the USB3.0 can only reach half of the theoretical value, but the transmission speed can also be close to 10 times of the USB 2.0. When the communication serial bus interface is adopted for transmission, the RAW data can be generally adopted for transmission, and the picture quality of the scanning data can be ensured.
Firstly, a transmission interface of scanning data is detected, when the transmission interface is a network interface, the network transmission speed is detected, and a corresponding data format is selected for transmission according to the network transmission speed. The data transmission method can select different data formats for transmission according to different transmission interfaces, the transmission interface with higher transmission speed can transmit data with larger data volume, for example, uncompressed data is not needed, the output interface with lower or unstable transmission speed can select the corresponding data format for transmission according to the current transmission speed, the transmission speed can be ensured, the problems of scanning pause, image splicing and slow transmission in the scanning transmission process are avoided, the larger data volume can be transmitted as far as possible according to the current transmission condition, and better balance between the transmission speed and the data volume can be achieved.
To further illustrate, the transmission policy when the network interface is used for transmission may further include, in an alternative embodiment, as shown in fig. 2, the following steps:
s31, scanning parameters are obtained. In this embodiment, the scan parameter may include a scan resolution; the speed of the scan; the number of pixel bits; color modes, etc. The specific scanning parameters can be determined according to the hardware attributes of the printer or the scanner, and also can be determined according to the setting parameters during scanning.
And S32, calculating the theoretical transmission speed of the current scanning data according to the scanning parameters. In this embodiment, after the scan parameter is determined, the size of the scan data, which is the data amount of the scan data after scanning, may be determined and also related to the scan resolution of the printer or scanner. The higher the resolution, the larger the scan data. The size of the scanning data is also related to the scanning parameters such as pixel bit number, color mode and the like. In this embodiment, the actual size of the scanned data can be calculated according to the scanning parameters such as resolution, pixel bit number, color mode, etc., and the required theoretical network transmission speed can be calculated according to the actual size of the scanned data. In the present embodiment, the transmission speed of the scanned data is also related to the amount of data scanned per unit time, i.e., the scanning speed, and the larger the scanning speed, the larger the amount of data scanned per unit time, and the higher the network transmission speed required for data transmission. In this embodiment, when calculating the theoretical network transmission speed, the parameter of the scanning speed may be used as a reference.
And S33, judging whether the current transmission speed is less than the theoretical transmission speed. The current transmission speed is compared with the theoretical network transmission speed, for example, the required theoretical transmission speed is 10MB/S, and the current network transmission speed is 2MB/S, then the current network transmission speed is less than the theoretical transmission speed, and the process proceeds to step S34. For example, the required theoretical transmission speed is 1MB/S, and the current network transmission speed is 2MB/S, and the current network transmission speed is greater than the theoretical transmission speed, the process proceeds to step S35.
And S34, selecting a compressed data format for transmission. In this embodiment, in order to ensure that scanning pause, image splicing, and transmission jam do not occur in the scanning and transmission process of the scanning data, in this embodiment, when the current network speed is lower than the theoretical transmission speed, the compressed data can be adopted for transmission, the amount of transmitted data is greatly reduced, and the scanning pause, image splicing, and transmission jam can be reduced.
And S35, selecting a non-compressed data format pair for transmission. In this embodiment, when the current network speed is higher than the theoretical transmission speed, if the unprocessed scan data is directly transmitted, the scan and transmission can be smoothly completed. High quality transmission of scan data can be guaranteed.
The data volume corresponding to different compression ratios is different, and the required network transmission speed is also different. In an alternative embodiment, the compression ratio may be determined by a theoretical transfer speed and an actual transfer speed. Specifically, as shown in FIG. 3, determining the compression ratio may include the steps of:
and S341, calculating the transmission ratio of the theoretical transmission speed and the actual transmission speed. In this embodiment, since the theoretical transmission speed transmits uncompressed data, a ratio of the theoretical transmission speed to the actual transmission speed may be used as a reference for measuring how much the scanned data is compressed in proportion.
And S342, determining the compression format and the compression ratio of the scanning data according to the transmission ratio. In this embodiment, after obtaining the transmission ratio, the compression ratio is determined according to the range of the transmission ratio, in this embodiment, the compression ratio may be a fixed value, or may also be a range value, in the actual compression process, the file compression may be in a dynamic process, the compression ratio of the file may not reach or exceed the value of the ideal compression ratio, and in this embodiment, the compression ratio is a range value. In order to ensure that the scanning and transmission processes do not generate the stuck phenomenon, in the embodiment, different scanning modes and corresponding transmission forms are different, if the scanning mode is single-page scanning, the compression rate and the compression mode are determined normally, and dynamic adjustment cannot be performed later; when the scanning mode is continuous multi-page scanning, the memory margin of the receiving end is also considered, and the compression format and the compression ratio are dynamically adjusted according to the transmission ratio and the memory margin. If the memory margin is sufficient, the compression format and the compression ratio can be determined according to the transmission ratio, and if the memory margin is limited, the compression format and the compression ratio can be dynamically adjusted according to the transmission ratio and the memory margin. In this embodiment, the data amount after compression in different compression formats may be different, and flexible selection may be performed during data compression.
An embodiment of the present invention provides a data transmission apparatus, as shown in fig. 4, including: the first detection module 10 is used for detecting the transmission interface type of the scanning data; the second detection module 20 is configured to detect a transmission speed of the current network when the first detection module detects that the transmission interface type is a network interface; and the transmission module 30 is configured to select a corresponding data format according to the current network transmission speed for transmission.
Optionally, the data transmission apparatus further includes: and the selecting module 40 is used for selecting the uncompressed data format to transmit the scanning data when the first detecting module detects that the transmission interface type is the communication serial bus interface.
Optionally, the transmission module comprises: an acquisition unit configured to acquire a scanning parameter; the calculating unit is used for calculating the theoretical transmission speed of the current scanning data according to the scanning parameters; the judging unit is used for judging whether the current transmission speed is smaller than the theoretical transmission speed or not; and the first selection unit is used for selecting a compressed data format to transmit the scanning data when the judgment unit judges that the current transmission speed is less than the theoretical transmission speed.
Optionally, the second selecting unit is configured to select a uncompressed data format pair for transmission when the determining unit determines that the current transmission speed is greater than the theoretical transmission speed.
Optionally, the first selection unit includes: a calculating subunit, configured to calculate a transmission ratio of the theoretical transmission speed and the actual transmission speed; and the determining subunit is used for determining the compression format and the compression ratio of the scanning data according to the transmission ratio, wherein the compression ratio is the ratio of the data amount before compression to the data amount after compression.
Optionally, the determining the subunit comprises: a first detection subunit, configured to detect a scanning pattern of the scanning data; the second detection subunit is used for detecting the memory allowance of the receiving end when the first detection subunit detects that the scanning mode is continuous multi-page scanning; and the adjusting subunit is used for dynamically adjusting the compression format and the compression ratio according to the transmission ratio and the memory margin.
The embodiment of the invention also provides the electronic equipment, and in the embodiment, the electronic equipment can be a server or a terminal. As shown in fig. 5, a controller is included, the controller including one or more processors 51 and a memory 52, one processor 53 being taken as an example in fig. 5.
The electronic device may further include: an input device 53 and an output device 55.
The processor 51, the memory 52, the input device 53 and the output device 55 may be connected by a bus or other means, as exemplified by the bus connection in fig. 5.
The processor 51 may be a Central Processing Unit (CPU). The Processor 51 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 52, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules. The processor 51 executes various functional applications of the server and data processing by running non-transitory software programs, instructions and modules stored in the memory 52, that is, implements the method for calculating the camera-view augmented reality tag according to the above method embodiment.
The memory 52 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of a processing device operated by the server, and the like. Further, the memory 52 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 52 may optionally include memory located remotely from the processor 51, which may be connected to a network connection device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 53 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the processing device of the server. The output device 55 may include a display device such as a display screen.
One or more modules are stored in the memory 52 and, when executed by the one or more processors 51, perform a method as shown in any of fig. 1-3.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.