Network protocol-based data acquisition method and apparatus, and acquisition card
By setting up the receiving and data sending modules in the acquisition card, and determining its processing method according to the type of network data packets, the problem that the acquisition card cannot realize the networking function based on the network port is solved, and the universal network card networking capability of the acquisition card is realized.
Patent Information
- Application Number
- PCT/CN2024/099235
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-17
- Filing Date
- 2024-06-14
- Publication Date
- 2025-02-20
AI Technical Summary
In the prior art, the acquisition card cannot effectively realize the networking function based on the network port, especially when the network data packets do not meet the standard network protocol stack.
By setting up a receiving module and a data sending module in the acquisition card, a network data packet is received and a decision is made based on its type whether to send it to the first processor or standard network protocol stack of the preset terminal.
The networking function of the acquisition card network port is realized, so that the acquisition card can send all data to the preset terminal, and has the networking capability of a general network card.
Smart Images

Figure CN2024099235_20022025_PF_FP_ABST
Abstract
Description
Data acquisition method, device and acquisition card based on network protocol
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on August 17, 2023, with application number 202311040575.1 and invention name “A data acquisition method, device and acquisition card based on network protocol”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of data acquisition technology, and in particular to a data acquisition method, device and acquisition card based on a network protocol. Background Art
[0003] Network protocol-based data acquisition methods utilize a network to collect and transmit data. These technologies utilize the infrastructure and communication specifications of computer networks to exchange data via network protocols, transferring the collected data from a source device to a target device. Taking image acquisition cards as an example, conventional techniques involve transmitting image data from network devices in the form of network packets that include data verification information. If the acquisition card processor determines a transmission error in the network packet based on the data verification information, it sends a retransmission request to the network device that sent the packet. Furthermore, the acquisition card performs network packet parsing and image data framing.
[0004] Currently, in existing technologies, network protocol packet parsing, retransmission requests, and processing tasks are all performed within the capture card. If the data in the network packet does not reach the standard network protocol stack, the pre-set terminal cannot connect to the network via the capture card's network port. Conversely, if the pre-set terminal can connect to the network via the capture card's network port, the capture card can be used as a universal network card to achieve network communication. Therefore, how to implement network connectivity via the capture card's network port has become an urgent problem.
[0005] Summary of the Invention
[0006] The purpose of the embodiments of the present application is to provide a data acquisition method, device, and acquisition card based on a network protocol, so as to realize the networking function based on the network port of the acquisition card. The specific technical solution is as follows:
[0007] In a first aspect, an embodiment of the present application provides a data acquisition method based on a network protocol, wherein the acquisition card is provided in a preset terminal and connected to a preset acquisition device, and the method includes:
[0008] Receive network data packets;
[0009] If the network data packet is designated interception data, the data carried by the network data packet is sent to the first processor of the preset terminal, wherein the designated interception data includes the target data collected by the preset collection device;
[0010] If the network data packet is not the designated interception data, the network data packet is sent to the standard network protocol stack of the preset terminal, so that the standard network protocol stack implements network communication based on the network data packet.
[0011] In a possible implementation, the sending the data carried by the network data packet to the first processor of the preset terminal includes:
[0012] Parsing the network data packet to obtain parsed data;
[0013] Combining the parsed data according to the data combination rule to obtain combined data;
[0014] The combined data is sent to the first processor of the preset terminal.
[0015] In a possible implementation, combining the parsed data according to a data combination rule to obtain combined data includes:
[0016] Combining the parsed data according to the data frames to obtain combined data, wherein each combined data includes the parsed data of a preset number of data frames; or
[0017] The parsed data are combined according to data volume to obtain combined data, wherein the data volume of each combined data is within a preset data volume range.
[0018] In a possible implementation, the sending the data carried by the network data packet to the first processor of the preset terminal includes:
[0019] sending an address allocation request to the acquisition card driver in the preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card;
[0020] In response to the first direct memory access address, the data carried by the network data packet is written to the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor.
[0021] In a possible implementation, after writing the data carried by the network data packet into the first direct memory access address, the method further includes:
[0022] A data read request is sent to the acquisition card and the acquisition card driver, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the data carried by the read network data packet into a preset memory in the preset terminal.
[0023] In one possible implementation, the method further includes:
[0024] receiving a standard network data packet sent by an application running in the preset terminal through the standard network protocol stack;
[0025] The standard network data packet is sent to a destination network device of the standard network data packet.
[0026] In a possible implementation, the receiving of a standard network data packet sent by an application running in the preset terminal through the standard network protocol stack includes:
[0027] In response to a second direct memory access address sent by the capture card driver in the preset terminal, read the standard network data packet stored in the second direct memory access address, wherein the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, an address allocated to the capture card, and the standard network data packet stored in the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, and write the standard network data packet into the second direct memory access address.
[0028] In one possible implementation, the method further includes:
[0029] receiving instruction information sent by the capture card driver, wherein the instruction information is generated by the capture card driver in response to an interception data configuration instruction;
[0030] The data indicated by the indication information is determined as designated interception data.
[0031] In one possible implementation, the method further includes:
[0032] A data combination rule is received from the acquisition card driver, where the data combination rule is generated by the acquisition card driver in response to a configuration instruction.
[0033] In a second aspect, an embodiment of the present application provides a data acquisition device based on a network protocol, which is applied to an acquisition card. The acquisition card is set at a preset terminal and connected to a preset acquisition device. The device includes:
[0034] A receiving module, used for receiving network data packets;
[0035] a data sending module, configured to send the data carried by the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes the target data collected by the preset collection device;
[0036] a data packet sending module, configured to send the network data packet to a standard network protocol stack of the preset terminal if the network data packet is not the designated interception data, so that the standard network protocol stack implements network communication based on the network data packet;
[0037] In a possible implementation, the data sending module includes:
[0038] The parsing submodule is used to parse the network data packet to obtain various parsed data;
[0039] A combining submodule, configured to combine the parsed data according to a data combining rule to obtain combined data;
[0040] a sending submodule, configured to send the combined data to a first processor of the preset terminal;
[0041] In a possible implementation, the combining submodule combines the parsed data according to a data combination rule to obtain combined data, including:
[0042] Combining the parsed data according to the data frames to obtain combined data, wherein each combined data includes the parsed data of a preset number of data frames; or
[0043] Combining the parsed data according to data volume to obtain combined data, wherein the data volume of each combined data is within a preset data volume range;
[0044] In a possible implementation, the data sending module includes:
[0045] an address allocation request sending submodule, configured to send an address allocation request to the acquisition card driver in the preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card;
[0046] a data writing submodule, configured to write the data carried by the network data packet into the first direct memory access address in response to the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor;
[0047] In a possible implementation, the data writing submodule is further configured to, after writing the data carried by the network data packet to the first direct memory access address, send a data read request to the acquisition card and the acquisition card driver, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the read data carried by the network data packet into a preset memory in the preset terminal;
[0048] In a possible implementation, the device further includes:
[0049] a standard network data packet receiving module, configured to receive a standard network data packet sent by an application running in the preset terminal via the standard network protocol stack;
[0050] A standard network data packet sending module, configured to send the standard network data packet to a destination network device of the standard network data packet;
[0051] In a possible implementation, the standard network data packet receiving module is specifically configured to:
[0052] In response to a second direct memory access address sent by the capture card driver in the preset terminal, read the standard network data packet stored in the second direct memory access address, wherein the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, an address allocated to the capture card, and the standard network data packet stored in the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, and write the standard network data packet into the second direct memory access address.
[0053] The device further comprises:
[0054] an indication information receiving module, configured to receive indication information sent by an acquisition card driver, wherein the indication information is generated by the acquisition card driver in response to an interception data configuration instruction;
[0055] The designated interception data determination module is used to determine the data indicated by the indication information as the designated interception data.
[0056] The device further comprises:
[0057] The data combination rule receiving module is used to receive the data combination rule sent by the acquisition card driver, where the data combination rule is generated by the acquisition card driver in response to a configuration instruction.
[0058] In a third aspect, an embodiment of the present application provides an acquisition card, which is disposed at a preset terminal, and includes a second processor and a network port, and is connected to a preset acquisition device via the network port;
[0059] The network port is used to receive network data packets and send the network data packets to the second processor;
[0060] the second processor being configured to send the data carried in the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes image data collected by the preset collection device;
[0061] If the network data packet is not the designated interception data, the network data packet is sent to the standard network protocol stack of the preset terminal, so that the standard network protocol stack implements network communication based on the network data packet.
[0062] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any network protocol-based data acquisition method described in the present application.
[0063] The embodiment of the present application provides a data acquisition method based on a network protocol, which is applied to an acquisition card that is set at a preset terminal and connected to a preset acquisition device. After receiving a network data packet, if the network data packet is designated interception data, the acquisition card sends the data carried by the network data packet to the first processor of the preset terminal. If the network data packet is not designated interception data, the network data packet is sent to the standard network protocol stack of the preset terminal, so that the standard network protocol stack realizes network communication based on the network data packet. Through the method of the embodiment of the present application, the acquisition card can not only send the intercepted designated interception data to the first processor of the preset terminal so that the processor processes the designated interception data, but also send the network data packet that is not designated interception data to the standard network protocol stack of the preset terminal, so that the standard network protocol stack parses the network data packet and sends the data in the parsed network data packet to the preset terminal. In this way, the acquisition card can send all data to the preset terminal, so that the acquisition card has the networking function of a general network card.
[0064] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The drawings described herein are used to provide 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 improper limitations on the present application.
[0066] FIG1 is a schematic diagram of a data acquisition method based on a network protocol according to an embodiment of the present application;
[0067] FIG2 is a detailed schematic diagram of step S12 in FIG1 ;
[0068] FIG3 is an example diagram of a data acquisition method based on a network protocol provided in an embodiment of the present application;
[0069] FIG4 is a schematic structural diagram of a network protocol-based data acquisition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] To make the objectives, technical solutions, and advantages of this application more clearly understood, the present application is further described below with reference to the accompanying drawings and examples. It is apparent that the described examples are only a portion of the embodiments of this application, and not all of them. All other embodiments derived by persons of ordinary skill in the art based on the examples in this application are intended to fall within the scope of protection of this application.
[0071] First, the professional terms in the embodiments of this application are explained:
[0072] PCIe: peripheral component interconnect express, also known as PCI-Express, is a high-speed serial computer expansion bus standard.
[0073] Capture card: A capture card is a capture device that captures external analog signals such as photoelectric, video or audio and digitizes them into a computer for digital processing. It mainly includes image capture cards, video capture cards, audio capture cards (such as sound cards), data acquisition cards, etc. The capture card in this application is a PCIe device.
[0074] DMA (Direct Memory Access) is a feature provided by some computer bus architectures that allows data to be sent directly from an attached device (such as a disk drive) to the computer's mainboard memory. When transferring data between an I / O (Input / Output) device and main memory, the DMA controller handles all data movement, freeing the CPU (Central Processing Unit) to handle other tasks.
[0075] Interrupt: PCIe devices have three types of interrupts: INTx (Interrupt x, line interrupt, x represents a specific interrupt line), MSI (Message Signaled Interrupt, message signal interrupt), and MSI-X (Message Signaled Interrupt Extended, signal interrupt extension).
[0076] MSI: The PCIe device triggers a CPU interrupt by writing a specific message to a specific address, supporting up to 32 interrupts.
[0077] Standard network protocol stack: responsible for computer network communications, enabling computers to exchange data and communicate in the network by implementing various protocols and algorithms.
[0078] Transparent transmission: refers to a data transmission method that is independent of the medium, modulation and demodulation method, transmission method and transmission protocol of the transmission network.
[0079] In order to realize the function of connecting the network port of the acquisition card to the network, a first aspect of the embodiment of the present application provides a data acquisition method based on a network protocol, which is applied to the acquisition card. The acquisition card is set at a preset terminal and connected to a preset acquisition device. Referring to FIG1 , the method includes:
[0080] Step S11, receiving a network data packet;
[0081] Network data packets are collected by the acquisition device and sent to the acquisition card through the acquisition card network port. The acquisition device can be directly connected to the acquisition card network port, or it can be connected to a network device with data transmission function such as a router or switch, and these network devices should be connected to the acquisition card network port.
[0082] Among them, the acquisition card can be an image acquisition card, a video acquisition card, an audio acquisition card, a data acquisition card, etc. Specifically, if the network data packet is collected by the acquisition device and sent to the acquisition card through the acquisition card network port, then when the acquisition card is an image acquisition card, the network data packet is the data packet sent by the image acquisition device, when the acquisition card is a video acquisition card, the network data packet is the data packet sent by the video acquisition device, when the acquisition card is an audio acquisition card, the network data packet is the data packet sent by the audio acquisition device, and when the acquisition card is a data acquisition card, the network data packet is the data packet sent by the data acquisition device.
[0083] When the acquisition card is an image acquisition card, the network data packet includes image data acquired by the image acquisition device; when the acquisition card is a video acquisition card, the network data packet includes video data acquired by the video acquisition device; when the acquisition card is an audio acquisition card, the network data packet includes audio data acquired by the audio acquisition device; when the acquisition card is a data acquisition card, the network data packet includes specified data acquired by the data acquisition device.
[0084] Step S12: If the network data packet is designated interception data, the data carried by the network data packet is sent to a first processor of a preset terminal, wherein the designated interception data includes target data collected by a preset collection device;
[0085] The designated intercepted data is target data that the acquisition card intercepts according to pre-configured interception rules. The acquisition card intercepts data that needs to be sent to the first processor for further processing according to the interception rules, and refuses to intercept data that does not need to be sent to the first processor for further processing. For example, it can be considered that the data collected by each acquisition device is the data carried by the network data packet, and this data needs to be further processed by the first processor. Therefore, in this application, the data collected by each acquisition device (hereinafter referred to as target data) is the designated intercepted data, and according to actual needs, the designated intercepted data may also include other data besides the target data.
[0086] Specifically, when the acquisition card is an image acquisition card, the target data is the image data acquired by the image acquisition device; when the acquisition card is a video acquisition card, the target data is the video data acquired by the video acquisition device; when the acquisition card is an audio acquisition card, the target data is the audio data acquired by the audio acquisition device; when the acquisition card is a data acquisition card, the target data is the specified data acquired by the data acquisition device.
[0087] The acquisition card sends the network data packet to the first processor of the preset terminal, so that the first processor of the preset terminal processes the network data packet after receiving the network data packet sent by the acquisition card. For example, assuming that the preset terminal is a computer and the network data packet is sent by an image acquisition device, after the acquisition card sends the network data packet to the computer, the computer can play, store, and process the image data in the received network data packet, and can also perform machine vision processing such as defect detection and barcode recognition based on the image data. The preset terminal can be a computer terminal or a server terminal, and is not specifically limited in this application.
[0088] When the network data packet is designated for interception, sending the data carried by the network data packet to the first processor of the preset terminal may mean sending the network data packet itself to the first processor of the preset terminal, or sending a backup of the network data packet to the first processor. The specific sending method is shown in Table 1:
[0089] Table 1: How to send network data packets when the network data packets are designated interception data
[0090] When a network data packet is designated for interception, the network data packet may be backed up and then sent to the first processor of a preset terminal, and the network data packet backup may be sent to a standard network protocol stack. Alternatively, the network data packet may not be backed up and the network data packet itself may be directly sent to the first processor of a preset terminal without sending any data of the network data packet to the standard network protocol stack. Alternatively, the network data packet may be backed up and then sent to the first processor of a preset terminal, and the network data packet itself may be sent to the standard network protocol stack. Alternatively, the network data packet backup may be sent to the first processor of a preset terminal without sending any data of the network data packet to the standard network protocol stack. This application is not limited to this.
[0091] In step S13 , if the network data packet is not designated interception data, the network data packet is sent to a standard network protocol stack of a preset terminal, so that the standard network protocol stack implements network communication based on the network data packet.
[0092] The standard network protocol stack for sending the network data packet to the preset terminal refers to the standard network protocol stack for directly sending the network data packet to the preset terminal without performing any processing on the network data packet.
[0093] Since the acquisition card can only parse network data packets of designated intercepted data, but cannot parse network data packets of non-designated intercepted data, the acquisition card in the related art cannot respond to network data packets of non-designated intercepted data. However, in this application, network data packets of non-designated intercepted data can be directly transmitted, so the acquisition card can also respond to network data packets of non-designated intercepted data.
[0094] In a possible embodiment, since there is no need to parse the network data packet during the transparent transmission process, the network data packet can be sent to the standard network protocol stack of the preset terminal in a transparent transmission manner.
[0095] In a possible implementation, when the network data packet is sent to the standard network protocol stack of the preset terminal, the network data packet may be copied for backup.
[0096] Using the method of the embodiments of the present application, the acquisition card can not only send the intercepted designated intercepted data to the first processor of the preset terminal so that the first processor can process the designated intercepted data, but can also, in response to receiving network data packets that are not designated intercepted data, send these network data packets to the standard network protocol stack of the preset terminal so that the standard network protocol stack can parse the network data packets and send the data in the parsed network data packets to the preset terminal. In this way, the acquisition card can send all data to the preset terminal, giving the acquisition card the networking capabilities of a general network card.
[0097] In a possible implementation, as shown in FIG2 , step S12 may specifically include the following steps:
[0098] Step S121, parsing the network data packet to obtain parsed data;
[0099] Since there is at least one acquisition device connected to the acquisition card, and the acquisition device continuously acquires data and sends network data packets to the acquisition card, there are multiple network data packets, and multiple parsed data obtained after parsing the network data packets. For example, the acquisition card is a video acquisition card, and the acquisition device is a camera. The video acquisition card continuously receives data packets sent by the camera, each data packet including different video frame data. After parsing the received data packets, the video acquisition card obtains multiple video frames.
[0100] The parsed data obtained after parsing the network data packet are the data collected by the corresponding preset acquisition device. For example, when the network data packet is a data packet sent by an image acquisition device, the parsed data can be the image frames collected by the image acquisition device.
[0101] In one possible embodiment, the network data packets collected by the preset acquisition device may carry data in multiple different formats. For example, the preset acquisition device is an image acquisition device that can perform code recognition. Therefore, the data packets sent by the image acquisition device may carry both an image and a text description of the recognition result. For another example, the preset acquisition device is an audio acquisition device that can perform speech conversion. Therefore, the data packets sent by the audio acquisition device may include both audio and text generated by the speech conversion.
[0102] Step S122, combining the parsed data according to the data combination rule to obtain combined data;
[0103] In the prior art, the processor of the preset terminal usually processes the complete data. For example, when the capture card is a video capture card, the processor of the preset terminal processes the complete video clipping, analysis, and playback, while the video capture card captures video frames. In order to obtain complete image data, it is necessary to combine each continuous video frame into complete video data.
[0104] Therefore, when obtaining the data frames collected by the acquisition card, it is necessary to combine the data frames according to the data combination rules.
[0105] The data combination rule indicates how the parsed data is to be combined. Specifically, it can indicate that a preset number of frames of data are to be combined, or it can ensure that the size of the combined data is within a preset data size range. For example, the data combination rule can indicate that 20 frames of data are to be combined, or it can ensure that the size of the combined data is controlled between 19M and 20M.
[0106] The data combination rule is pre-configured by the user to the acquisition card network port through the acquisition card driver. The combination method specified by the data combination rule should be the combination method required for further processing of the data collected by the acquisition device.
[0107] In a possible implementation, the user may configure the capture card network port with specified interception data and data combination rules in advance through the capture card driver.
[0108] In an embodiment of the present application, since the acquisition card receives network data packets in an ongoing process, the above-mentioned step S121 and step S122 are not in the order shown in Figure 2. The two steps are performed alternately. For example, assuming that the image acquisition card continuously receives 3 network data packets, the data combination rule is to combine 10 frames of image frames. After the acquisition card parses the first network data packet, the number of image frames in the first network data packet is 8. Then, when the acquisition card combines the 8 frames of image frames in the first network data packet, it parses the second network data packet and obtains that the number of image frames in the second network data packet is 7. The 2 frames of image frames in the second network data packet are combined with the 8 frames of image frames in the first network data packet into a combined data, and then the remaining 5 frames of image frames in the second network data packet are combined. At the same time, the third network data packet is parsed to obtain 5 frames of image data frames, and the 5 frames of image frames in the third network data packet are combined with the remaining 5 frames of image frames in the second network data packet into a combined data.
[0109] Step S123: Send the combined data to the first processor of the preset terminal.
[0110] In one embodiment, before sending the combined data to the first processor of the preset terminal, the capture card determines whether the combined data satisfies the data combination rules. If the combined data satisfies the data combination rules, the combined data is sent. For example, the data combination rule is to combine 30 frames of image data. The capture card parses the currently received network data packet to obtain 10 frames of image data. After combining the 10 frames of image data, if it is determined that the data combination rules are not satisfied, the capture card continues to parse the next network data packet to obtain 20 frames of image data. The 20 frames of image data are combined with the 10 frames of image data in the previous network data packet. If it is again determined that the combined data satisfies the data combination rules, the 30 frames of image data are sent as a combined data.
[0111] According to the embodiment of the present application, the acquisition card parses the network data packet and combines the parsed data according to the data combination rules. Compared with the prior art in which each data frame in the network data packet is sent frame by frame to the processor of the preset terminal, and the processor of the preset terminal combines the data frames, the present application does not require the processor of the preset terminal to combine the data carried by the network data packet, thereby reducing the resource occupation of the processor of the preset terminal.
[0112] In a possible implementation, the method further includes: receiving indication information sent by the capture card driver, wherein the indication information is generated by the capture card driver in response to an interception data configuration instruction; and determining the data indicated by the indication information as designated interception data.
[0113] By adopting the embodiments of the present application, it is possible to intercept and process designated data, thereby improving transmission efficiency.
[0114] In a possible implementation, the method further includes: receiving a data combination rule sent by the acquisition card driver, where the data combination rule is generated by the acquisition card driver in response to a configuration instruction.
[0115] By configuring the data combination rules of the acquisition card network port, the embodiment of the present application can combine and send data according to the data combination rules, compared with the prior art which can only transmit a single frame, thereby further improving the transmission efficiency.
[0116] In a possible implementation, the above step S122 may specifically include:
[0117] Step A, combining the parsed data according to the data frames to obtain combined data, wherein each combined data includes parsed data of a preset number of data frames; or
[0118] Step B: parse the data according to the data volume combination to obtain combined data, wherein the data volume of each combined data is within a preset data volume range.
[0119] Combining the parsed data according to the data frames means combining the parsed data of a preset number of data frames. For example, when the acquisition card is an image acquisition card, the user sets the data combination rule to combine 20 frames of image data. After parsing each network data packet to obtain each image data frame, the acquisition card combines the 20 frames of image data into one combined data each time according to the data combination rule and sends it to the first processor of the preset terminal.
[0120] Parsing data according to data volume combination refers to combining multiple data frames into combined data of a preset data volume. For example, when the acquisition card is an image acquisition card, the user sets the data combination rule to combine 20M image data. After parsing each network data packet to obtain each image data frame, the acquisition card combines multiple image data frames into a combined data of 20M in size according to the data combination rule each time, and sends it to the first processor of the preset terminal.
[0121] By adopting the method of the embodiment of the present application, the transmission efficiency of the acquisition card is improved by combining the parsed data of a preset number of image frames in the acquisition card and sending them to the first processor of the preset terminal, or combining the parsed data of a preset data amount in the acquisition card and sending them to the first processor of the preset terminal.
[0122] In a possible implementation, the above step S12 may specifically include:
[0123] Step C: sending an address allocation request to the acquisition card driver in the preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card;
[0124] If the network data packet is not designated intercept data, the acquisition card first sends an address allocation request to the acquisition card driver in the preset terminal. In response to the address allocation request, the acquisition card driver configures a first direct memory access address for the acquisition card and sends the first direct memory access address to the acquisition card. The first direct memory access address is used by the acquisition card to write data in the network data packet that is not designated intercept data.
[0125] In one embodiment, the acquisition card may send an interrupt request to the acquisition card driver, so that the acquisition card driver configures a first DMA address, i.e., a first direct memory access address, for the acquisition card in response to the interrupt request, and notifies the acquisition card to write data to the configured first DMA address.
[0126] Step D, in response to the first direct memory access address, writes the data carried by the network data packet into the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor.
[0127] By adopting the method of the embodiment of the present application, an address allocation request is sent to the acquisition card driver in the preset terminal. After receiving the first direct memory access address sent by the acquisition card driver in response to the address allocation request, the data carried by the network data packet is written into the first direct memory access address, so that the acquisition card driver can send the data carried by the network data packet in the first direct memory address to the first processor of the preset terminal, thereby reducing the data packet loss rate.
[0128] In a possible implementation, in step D above, after writing the data carried by the network data packet into the first direct memory access address, the method further includes:
[0129] Step c: sending a data read request to the acquisition card driver, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the data carried by the read network data packet into a preset memory in the preset terminal.
[0130] When data is stored in the preset memory of the preset terminal, the first processor of the preset terminal processes the data in the preset memory. For example, the preset terminal is a computer. The capture card driver accesses the first direct memory access address to read one unit of video data and stores the one unit of video data in a specific memory of the computer. When the computer processor receives new video data stored in the specific memory, it processes the one unit of video data.
[0131] By adopting the method of the embodiment of the present application, after the acquisition card writes the data carried by the network data packet into the first direct memory access address, a data read request is immediately sent to the acquisition card driver, so that the acquisition card driver can promptly send the data carried by the network data packet in the first direct memory access address to the preset memory in the preset terminal, thereby improving the transmission efficiency of the acquisition card.
[0132] In a possible implementation, the above method further includes:
[0133] Step S14, receiving a standard network data packet sent by an application running in a preset terminal via a standard network protocol stack;
[0134] The standard network data packet sent by the application running in the preset terminal through the standard network protocol stack refers to the network data sent by the application running in the preset terminal, which is formed into a standard network data packet through the standard network protocol stack.
[0135] Step S15: Send the standard network data packet to the destination network device of the standard network data packet.
[0136] The destination network device of the standard network data packet refers to a network device such as a router or switch connected to the capture card. The network device can transmit the standard network data to the network connected to the router or switch.
[0137] Using the embodiment of the present application, the acquisition card can receive standard network data packets sent by the application running in the preset terminal through the standard network protocol stack, and send the standard network data packets to the destination network device of the standard network data packets. Network communication is realized through the acquisition card, so that the acquisition card can be used as a general network card.
[0138] In a possible implementation, the above step S15 may specifically include:
[0139] Step S151: In response to a second direct memory access address sent by a capture card driver in a preset terminal, read a standard network data packet stored in the second direct memory access address, wherein the second direct memory access address is an address allocated to the capture card, and the standard network data packet stored in the second direct memory access address is a standard network data packet sent by the capture card driver in response to an application running in the preset terminal, and write the standard network data packet into the second direct memory access address.
[0140] Specifically, the standard network protocol stack combines network data sent by an application running in a preset terminal into a standard network data packet and sends the standard network data packet to the capture card driver. The capture card driver then transfers the standard network data packet to a second direct memory access address configured for the capture card by the capture card driver via DMA. Exemplarily, upon receiving the standard network data packet sent by an application running in a preset terminal via the standard network protocol stack, the capture card driver configures a direct memory access address A for the capture card and writes the data in the standard network data packet to the direct memory access address A.
[0141] By adopting the method of the embodiment of the present application, the acquisition card driver responds to the standard network data packet sent by the application running in the preset terminal, allocates a second direct access memory address to the acquisition card, and writes the standard network data packet sent by the application running in the preset terminal into the second direct memory access address, so that the acquisition card can read the standard network data packet from the second direct memory access address, and then send the standard network data packet to the destination network device of the standard network data packet, thereby realizing the networking function of the acquisition card.
[0142] In order to more clearly illustrate the method of the present application, refer to Figure 3, which provides an example diagram of a data acquisition method based on a network protocol. Taking the data combination rule of combining 4 frames of image frames as an example, the acquisition card in the figure is an image acquisition card, the standard network protocol stack is the standard network protocol stack of the preset terminal, the acquisition card driver is set on the preset terminal, the acquisition card is a PCIe device, the acquisition card is connected to some industrial cameras, and is also connected to another part of the industrial cameras through network devices such as switches or routers. When the image acquisition card receives a network data packet directly sent by an industrial camera through the acquisition card network port, or a network data packet collected by an industrial camera sent by a network device through the network port, the acquisition card processor first determines whether the network data packet is image data. If so, it sends an interrupt request to the acquisition card driver in the preset terminal, so that after receiving the interrupt request, the acquisition card driver configures a DMA address (i.e., the first DMA address mentioned above) to the acquisition card; and the acquisition card processor parses the network data packet of the specified intercepted data to obtain each image frame, and combines each image frame in a manner of combining every 4 frames, and writes the combined data into the DMA, and then sends the combined data to the processor of the preset terminal for processing; if the network data packet is not image data, the network data packet is transported and sent to the standard network protocol stack through the PCIe bus, so that the standard network protocol stack parses the received network data packet, and then the application layer in the preset terminal receives the network packet data, thereby realizing network communication.
[0143] Corresponding to the above method embodiment, the embodiment of the present application provides a data acquisition device based on a network protocol, which is applied to an acquisition card. The acquisition card is set at a preset terminal and connected to a preset acquisition device. As shown in FIG4 , the device includes:
[0144] Receiving module 401, configured to receive a network data packet;
[0145] The data sending module 402 is configured to send the data carried by the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes target data collected by the preset collection device;
[0146] The data packet sending module 403 is configured to send the network data packet to a standard network protocol stack of a preset terminal if the network data packet is not designated interception data, so that the standard network protocol stack implements network communication based on the network data packet;
[0147] Using the method of the embodiments of the present application, the acquisition card can not only send the intercepted designated intercepted data to the first processor of the preset terminal, so that the first processor can process the designated intercepted data, but also send network data packets that are not designated intercepted data to the standard network protocol stack of the preset terminal, so that the standard network protocol stack can parse the network data packets and send the data in the parsed network data packets to the preset terminal. In this way, the acquisition card can send all data to the preset terminal, giving the acquisition card the networking capabilities of a general network card.
[0148] In a possible implementation, the data sending module 402 includes:
[0149] The parsing submodule is used to parse network data packets and obtain various parsed data;
[0150] The combining submodule is used to combine the parsed data according to the data combination rules to obtain the combined data;
[0151] a sending submodule, configured to send the combined data to a first processor of a preset terminal;
[0152] In a possible implementation, the combining submodule combines the parsed data according to the data combination rule to obtain combined data, including:
[0153] Combining the parsed data according to the image frames to obtain combined data, wherein each combined data includes parsed data of a preset number of image frames; or
[0154] Parsing the data according to the data volume combination to obtain combined data, wherein the data volume of each combined data is within a preset data volume range;
[0155] In a possible implementation, the data sending module 402 includes:
[0156] an address allocation request sending submodule, configured to send an address allocation request to an acquisition card driver in a preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card;
[0157] a data writing submodule, configured to write the data carried by the network data packet into the first direct memory access address in response to the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor;
[0158] In a possible implementation, the data writing submodule is further configured to, after writing the data carried by the network data packet into the first direct memory access address, send a data read request to the acquisition card driver, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the read data carried by the network data packet into a preset memory in the preset terminal;
[0159] In one possible implementation, the device further includes:
[0160] A standard network data packet receiving module, configured to receive a standard network data packet sent by an application running in a preset terminal via a standard network protocol stack;
[0161] A standard network data packet sending module, used for sending the standard network data packet to the destination network device of the standard network data packet;
[0162] In a possible implementation, the standard network data packet receiving module is specifically configured to:
[0163] In response to a second direct memory access address sent by a capture card driver in a preset terminal, a standard network data packet stored in the second direct memory access address is read, wherein the second direct memory access address is an address allocated to the capture card, and the standard network data packet stored in the second direct memory access address is a standard network data packet sent by the capture card driver in response to the application running in the preset terminal, and the standard network data packet is written into the second direct memory access address.
[0164] In one possible implementation, the device further includes:
[0165] an indication information receiving module, configured to receive indication information sent by the acquisition card driver, wherein the indication information is generated by the acquisition card driver in response to an interception data configuration instruction;
[0166] a designated interception data determination module, configured to determine the data indicated by the instruction information as designated interception data; and / or
[0167] In one possible implementation, the device further includes:
[0168] The data combination rule receiving module is used to receive the data combination rule sent by the acquisition card driver, where the data combination rule is generated by the acquisition card driver in response to the configuration instruction.
[0169] The embodiment of the present application further provides an acquisition card, which is arranged at a preset terminal, and includes a second processor and a network port, and the acquisition card is connected to a preset acquisition device via the network port;
[0170] A network port, configured to receive network data packets and send the network data packets to the second processor;
[0171] a second processor configured to send data carried in the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes target data collected by the preset collection device;
[0172] If the network data packet is not designated interception data, the network data packet is sent to a standard network protocol stack of a preset terminal, so that the standard network protocol stack implements network communication based on the network data packet.
[0173] The present application also provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:
[0174] Receive network data packets;
[0175] If the network data packet is designated interception data, the data carried by the network data packet is sent to the first processor of the preset terminal, wherein the designated interception data includes the target data collected by the preset collection device;
[0176] If the network data packet is not designated interception data, the network data packet is sent to a standard network protocol stack of a preset terminal, so that the standard network protocol stack implements network communication based on the network data packet.
[0177] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0178] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0179] In another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned network protocol-based data acquisition methods are implemented.
[0180] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the network protocol-based data acquisition methods in the above embodiments.
[0181] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state drive (SSD).
[0182] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0183] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0184] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A data collection method based on network protocol, characterized in that: Applied to an acquisition card, the acquisition card is arranged in a preset terminal and connected to a preset acquisition device, the method comprises: Receive network data packets; If the network data packet is designated interception data, the data carried by the network data packet is sent to the first processor of the preset terminal, wherein the designated interception data includes the target data collected by the preset collection device; If the network data packet is not the designated interception data, the network data packet is sent to the standard network protocol stack of the preset terminal, so that the standard network protocol stack realizes network communication based on the network data packet.
2. The method according to claim 1, characterized in that: The step of sending the data carried by the network data packet to the first processor of the preset terminal includes: Parsing the network data packet to obtain parsed data; According to the data combination rule, the parsed data are combined to obtain combined data; The combined data is sent to the first processor of the preset terminal.
3. The method according to claim 2, characterized in that Combining the parsed data according to the data combination rule to obtain the combined data includes: Combining the parsed data according to the data frames to obtain combined data, wherein each combined data includes the parsed data of a preset number of data frames; or The parsed data are combined according to data volume to obtain combined data, wherein the data volume of each combined data is within a preset data volume range.
4. The method according to claim 1, characterized in that: The step of sending the data carried by the network data packet to the first processor of the preset terminal includes: Sending an address allocation request to the acquisition card driver in the preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card; In response to the first direct memory access address, the data carried by the network data packet is written to the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor.
5. The method according to claim 4, characterized in that After writing the data carried by the network data packet into the first direct memory access address, the method further includes: A data read request is sent to the acquisition card driver, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the read data carried by the network data packet into a preset memory in the preset terminal.
6. The method according to claim 1, characterized in that The method further comprises: Receiving a standard network data packet sent by an application running in the preset terminal through the standard network protocol stack; The standard network data packet is sent to a destination network device of the standard network data packet.
7. The method according to claim 6, characterized in that The receiving of a standard network data packet sent by the application running in the preset terminal through the standard network protocol stack includes: In response to a second direct memory access address sent by the acquisition card driver in the preset terminal, read the standard network data packet stored in the second direct memory access address, wherein the second direct memory access address is the standard network data packet sent by the acquisition card driver in response to the application running in the preset terminal, an address allocated to the acquisition card, and the standard network data packet stored in the second direct memory access address is the standard network data packet sent by the acquisition card driver in response to the application running in the preset terminal, and write the standard network data packet into the second direct memory access address.
8. The method according to claim 1, characterized in that The method further comprises: Receiving indication information sent by the acquisition card driver, wherein the indication information is generated by the acquisition card driver in response to the interception data configuration instruction; The data indicated by the indication information is determined as designated interception data.
9. The method according to claim 2, characterized in that: The method further comprises: A data combination rule is received from a capture card driver, where the data combination rule is generated by the capture card driver in response to a data combination rule configuration instruction.
10. A data acquisition device based on a network protocol, characterized in that: Applied to a collection card, the collection card is set in a preset terminal and connected to a preset collection device, the device includes: A receiving module, used for receiving network data packets; A data sending module, configured to send the data carried by the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes the target data collected by the preset collection device; The data packet sending module is used to send the network data packet to the standard network protocol stack of the preset terminal if the network data packet is not the designated interception data, so that the standard network protocol stack realizes network communication based on the network data packet.
11. The device according to claim 10, characterized in that The data sending module comprises: The parsing submodule is used to parse the network data packet to obtain various parsed data; A combining submodule, used for combining the parsed data according to the data combining rule to obtain combined data; a sending submodule, configured to send the combined data to a first processor of the preset terminal; and / or The combining submodule combines the parsed data according to the data combining rule to obtain combined data, including: Combining the parsed data according to the data frames to obtain combined data, wherein each combined data includes the parsed data of a preset number of data frames; or Combine the parsed data according to the data volume to obtain combined data, wherein each of the combined data The amount of data is within the preset data amount range; and / or The data sending module comprises: an address allocation request sending submodule, configured to send an address allocation request to the acquisition card driver in the preset terminal, so that the acquisition card driver configures a first direct memory access address for the acquisition card in response to the address allocation request, and sends the first direct memory access address to the acquisition card; a data writing submodule, configured to write the data carried by the network data packet into the first direct memory access address in response to the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and sends the data carried by the network data packet to the first processor; and / or The data writing submodule is further used to send a data reading request to the acquisition card and the acquisition card driver after writing the data carried by the network data packet into the first direct memory access address, so that the acquisition card driver accesses the first direct memory access address to read the data carried by the network data packet, and stores the data carried by the read network data packet into the preset memory in the preset terminal; and / or The device also includes: A standard network data packet receiving module, configured to receive a standard network data packet sent by an application running in the preset terminal through the standard network protocol stack; A standard network data packet sending module, used for sending the standard network data packet to a destination network device of the standard network data packet; and / or The standard network data packet receiving module is specifically used for: In response to a second direct memory access address sent by the capture card driver in the preset terminal, read the standard network data packet stored in the second direct memory access address, wherein the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, an address allocated to the capture card, and the standard network data packet stored in the second direct memory access address is the standard network data packet sent by the capture card driver in response to the application running in the preset terminal, and write the standard network data packet into the second direct memory access address; and / or The device also includes: An indication information receiving module, used to receive indication information sent by the acquisition card driver, wherein the indication information is generated by the acquisition card driver in response to the interception data configuration instruction; a designated interception data determination module, configured to determine the data indicated by the indication information as designated interception data; and / or The device also includes: The data combination rule receiving module is used to receive the data combination rule sent by the acquisition card driver, where the data combination rule is generated by the acquisition card driver in response to the configuration instruction.
12. A capture card, characterized in that: The acquisition card is arranged at a preset terminal, the acquisition card comprises a second processor and a network port, and the acquisition card is connected to a preset acquisition device via the network port; The network port is used to receive a network data packet and send the network data packet to the second processor; The second processor is configured to send the data carried by the network data packet to the first processor of the preset terminal if the network data packet is designated interception data, wherein the designated interception data includes the target data collected by the preset collection device; If the network data packet is not the designated interception data, the network data packet is sent to the standard network protocol stack of the preset terminal, so that the standard network protocol stack realizes network communication based on the network data packet.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Image acquisition card, image acquisition method and image acquisition system
CN114286035A
Data acquisition method and device based on network protocol and acquisition card
CN117118858A
High-speed 10-gigabit network image acquisition card
CN216313328U