Image data transmission method, system and device and storage medium
Through the customization mechanism, the reliability problem of UDP protocols in the transmission of 10D image data is solved, reducing development costs and complexity, improving transmission efficiency and reliability, and suitable for high -speed transmission scenarios.
Patent Information
- Application Number
- CN202411610049.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-01-24
AI Technical Summary
The existing 10G image data transmission solutions have shortcomings in terms of cost, development ease and reliability, especially the GigE IP core is expensive, and the GigE Vision protocol has high CPU load, high interrupt rate, multiple cache copy and packet loss etc.
Through customized mechanisms, the reliability problem of the UDP protocol has been solved, and the development cost and complexity of the 10 Magazine cameras is reduced. Specific methods include the upper machine to send a picture command to the camera, receive image data and detect packet loss. If there is a packet loss, send a re -transmitting request to make up the image data.
It improves the efficiency and reliability of image data transmission, reduces development costs and complexity, and is suitable for scenarios requiring high-speed transmission while ensuring the integrity of image data.
Smart Images

Figure CN119363300A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, system, device and storage medium for image data transmission. Background Art
[0002] With the development of science and technology, especially in the fields of industrial automation, medical imaging, scientific research, etc., the requirements for the clarity and transmission speed of image data are getting higher and higher. 10G image data transmission technology has come into being. The development of 10G image data transmission technology meets the growing demand for high-speed and high-resolution image transmission, and at the same time uses standardized network technology to reduce costs and improve transmission efficiency and stability.
[0003] In the existing technology, 10G image data transmission solutions usually rely on FPGA and GigE IP core to achieve data analysis, reliable transmission and improved transmission speed. The GigE Vision protocol is based on standard Ethernet physical links and runs on the UDP protocol layer. It includes two parts: the control protocol GVCP and the data stream protocol GVSP. The advantage of this solution is that it can use standard network infrastructure to achieve high-speed data transmission.
[0004] However, the existing GigE IP cores on the market are expensive, which significantly increases the R&D cost. For users who do not want to purchase IP cores, there is currently no standardized process or method to ensure reliable image data transmission between PCs and downstream cameras, and the application layer of the GigE Vision protocol has some defects, such as high CPU load, high interrupt rate, multiple cache copies, packet loss, etc., which may lead to low data reception efficiency. In general, the existing 10G image data transmission solutions are insufficient in terms of cost, development convenience and reliability. Summary of the invention
[0005] The present application provides a method, system, device and storage medium for transmitting image data, which are used to solve the reliability problem of UDP protocol through a customized retransmission mechanism and reduce the development cost and complexity of 10G camera.
[0006] In a first aspect, the present application provides a method for transmitting image data, comprising:
[0007] The host computer sends a picture acquisition command to the camera;
[0008] When the host computer receives the response command from the camera, it enters a waiting state that lasts for a preset time;
[0009] The host computer receives the image data uploaded by the camera packet by packet within the preset time;
[0010] When the host computer receives a frame confirmation command sent by the camera, it determines whether there is packet loss data in the image data, and the frame confirmation command is used to indicate that the data sending process of the camera has ended;
[0011] If so, the host computer sends a retransmission request to the camera, wherein the retransmission request is used to cause the camera to retransmit the image data corresponding to the lost packet data to the host computer;
[0012] If not, the host computer generates an image object by packaging the image data.
[0013] Optionally, the image data carries package information, the package information includes a package sequence number and a row sequence number, and after the host computer receives the image data uploaded by the camera within the preset time, the method further includes:
[0014] The host computer stores the received image data into an image queue according to the packet information, and at the same time verifies the image data and records packet loss information, wherein the packet loss information includes a lost target packet sequence number and a target row sequence number;
[0015] The host computer sends a retransmission command to the camera, including:
[0016] The host computer sends a retransmission command to the camera according to the target row sequence number and the target packet sequence number.
[0017] Optionally, the host computer generates an image object by packaging the image data, including:
[0018] The host computer reads the data packets of the image data from the image queue, and arranges and combines the data packets into an image array according to the packet information;
[0019] The host computer splices the image array to obtain a complete image object.
[0020] Optionally, the method further includes:
[0021] When the host computer still has not received the image data uploaded by the camera after the preset time has elapsed, the host computer initializes the state of the camera and re-sends the image acquisition command to the camera.
[0022] Optionally, after the host computer generates an image object by assembling the image data, the method further includes:
[0023] The host computer enables or disables the ISP algorithm through SDK operation.
[0024] Optionally, the ISP algorithm includes image cropping, image dark level processing, flat field correction and 3A algorithm.
[0025] Optionally, before the host computer sends a picture acquisition command to the camera, the method further includes:
[0026] The camera is powered on and performs initialization operations and image configuration operations. The initialization operations include initializing the lens aperture and initializing the focus value. The image configuration operations include configuring the image bit number, exposure value, gain, and Binning mode.
[0027] The second aspect of the present application provides a system for image data transmission, the system is implemented based on the UPD protocol, the system includes: a host computer and a camera; the host computer includes:
[0028] A sending unit, used for sending a picture acquisition command to the camera;
[0029] A waiting unit, configured to enter a waiting state lasting a preset time when receiving a response command from the camera;
[0030] A receiving unit, configured to receive the image data uploaded by the camera packet by packet within the preset time;
[0031] a judgment unit, configured to judge whether there is packet loss data in the image data when receiving a frame confirmation command sent by the camera, wherein the frame confirmation command is used to indicate that a data transmission process of the camera has ended;
[0032] a retransmission unit, configured to send a retransmission request to the camera when the judgment result of the judgment unit is yes, wherein the retransmission request is used to enable the camera to retransmit the image data corresponding to the lost packet data to the host computer;
[0033] The packaging unit is used to package the image data to generate an image object when the judgment result of the judgment unit is no.
[0034] Optionally, the image data carries package information, the package information includes a package sequence number and a row sequence number, and the host computer further includes:
[0035] A storage unit, used for storing the received image data into an image queue according to the packet information, and at the same time verifying the image data and recording packet loss information, wherein the packet loss information includes a lost target packet sequence number and a target row sequence number;
[0036] The retransmission unit is specifically used for:
[0037] A retransmission command is sent to the camera according to the target row sequence number and the target packet sequence number.
[0038] Optionally, the packaging unit is specifically used for:
[0039] Reading data packets of the image data from the image queue, and arranging and combining the data packets into an image array according to the packet information;
[0040] The image arrays are spliced to obtain a complete image object.
[0041] Optionally, the host computer further includes:
[0042] The timeout unit is used to initialize the state of the camera and re-send the image acquisition command to the camera when the image data uploaded by the camera is still not received after the preset time.
[0043] Optionally, the ISP algorithm includes image cropping, image dark level processing, flat field correction and 3A algorithm.
[0044] Optionally, the camera includes:
[0045] The initialization unit is used to power on and perform initialization operations and image configuration operations, wherein the initialization operations include initializing the lens aperture and initializing the focus value, and the image configuration operations include configuring the image bit number, exposure value, gain, and Binning mode.
[0046] A third aspect of the present application provides a device for transmitting image data, the device comprising:
[0047] Processor, memory, input-output unit, and bus;
[0048] The processor is connected to the memory, the input and output unit, and the bus;
[0049] The memory stores a program, and the processor calls the program to execute the first aspect and any optional image data transmission method in the first aspect.
[0050] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the method for transmitting image data in the first aspect and any optional method in the first aspect is executed.
[0051] It can be seen from the above technical solutions that this application has the following advantages:
[0052] The image data transmission method provided by the present application is implemented based on the UDP protocol, and solves the reliability problem of the UDP protocol through a custom retransmission mechanism. In addition, during the entire image data transmission process, handshake confirmation is no longer performed, but overall packet loss detection and retransmission are performed after the host computer receives the frame confirmation command sent by the camera, reducing unnecessary handshake steps between the camera and the host computer, significantly improving transmission efficiency, and is particularly suitable for scenes requiring high-speed transmission. When the host computer receives the frame confirmation command sent by the camera, the host computer actively detects packet loss, and sends a retransmission request to the camera to complete the image data when packet loss is detected, effectively making up for the lack of reliability of the UDP protocol, while improving transmission efficiency. Ensure the integrity of the image data. Compared with traditional commercial protocols (such as Giga IP), this application avoids authorization restrictions by using custom protocols, and developers can flexibly customize functions, thereby reducing the development cost and complexity of 10,000-gigabyte cameras. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0054] Figure 1 A flowchart of an embodiment of the method for image data transmission provided by the present application;
[0055] Figure 2 A diagram of the data packet definition between the host computer and the camera in the method for image data transmission provided by this application;
[0056] Figure 3 A flowchart of another embodiment of the method for image data transmission provided by the present application;
[0057] Figure 4 A schematic diagram of the handshake process definition between the host computer and the camera in the method for image data transmission provided by this application;
[0058] Figure 5 A schematic diagram of the structure of an embodiment of the system for image data transmission provided by the present application;
[0059] Figure 6 A schematic diagram of the structure of an embodiment of the device for transmitting image data provided in this application. DETAILED DESCRIPTION
[0060] The present application provides a method, system, device and storage medium for transmitting image data, which are used to solve the reliability problem of UDP protocol through a customized retransmission mechanism and reduce the development cost and complexity of 10G camera.
[0061] It should be noted that the method provided in this application is applied to a host computer, which refers to a computer or device that controls the entire image acquisition and processing process. For example, the host computer can be a smart phone or computer, tablet computer, smart TV, smart watch, portable computer terminal, or a fixed terminal such as a desktop computer. For the convenience of explanation, this application is described with the host computer as the execution subject.
[0062] See also Figure 1 , Figure 1 An embodiment of the method for transmitting image data provided by the present application includes:
[0063] 101. The host computer sends a picture acquisition command to the camera;
[0064] In this embodiment, the host computer sends a capture command to the camera through a custom transmission protocol based on UDP. The UDP protocol (User Datagram Protocol) is a connectionless transport layer protocol. The sender and the receiver do not need to establish a connection before transmitting data, nor do they maintain the connection status during the transmission process. This enables the UDP protocol to quickly transmit data.
[0065] 102. When the host computer receives the response command from the camera, it enters a waiting state for a preset time;
[0066] After the host computer sends a capture command to the camera, the camera will send back a response command through the UDP protocol. The purpose of this response command is to confirm that the camera has successfully received the capture command and is ready for image acquisition. When the host computer receives the response command returned by the camera, it will enter a waiting state that lasts for a preset time. During this waiting state, the host computer will continue to monitor whether there is image data transmitted from the camera to ensure that the received data packet is processed as soon as possible. The host computer entering the waiting state can not only ensure that the camera has enough time to process and send image data, but also avoid the host computer from constantly requesting or excessive polling, thereby improving response efficiency.
[0067] The preset time can be set according to the estimated time of image acquisition, processing, and transmission, and can be dynamically adjusted according to the actual usage scenario to adapt to different camera parameters and network environments, which are not specifically limited here. If the preset time is set too short, the host computer may not receive all the data; if it is set too long, it will cause unnecessary waiting time. In some specific embodiments, the host computer can dynamically adjust the preset time according to the response command of the camera, that is, the host computer automatically calculates the preset time according to the information reflected in the response command (such as image size, network bandwidth, frame rate, etc.).
[0068] 103. The host computer receives the image data uploaded by the camera packet by packet within a preset time;
[0069] Within the preset time, the camera will upload the collected image data to the host computer through the UDP protocol. The host computer will continue to monitor and receive the image data packets uploaded by the camera through the network interface during the preset time. Specifically, in order to ensure the reliability and integrity of data transmission, it is necessary to define the data packets transmitted between the host computer and the camera. Please refer to Figure 2 , Figure 2 The data packets between the host computer and the camera are defined as follows:
[0070] 1. Data transmission frame
[0071] Header: occupies 10 bytes, marks the beginning of the data packet, and ensures that the host computer can recognize that this is a valid data packet;
[0072] Confirmation code (Ack): occupies 4 bytes and is used to confirm whether the previous data packet has been successfully received;
[0073] Sequence code (Seq): occupies 4 bytes and identifies the order of data packets. Since UDP does not guarantee the order of packets, the sequence code can help the host computer assemble image data in the correct order to avoid disorder problems;
[0074] Function code (Func): occupies 2 bytes and identifies the function of the current data packet (such as sending image data or control information);
[0075] Data length (Len): occupies 4 bytes and indicates the length of the data carried in the current data packet (in bytes);
[0076] Checksum (CRC): occupies 4 bytes and provides integrity check for data packets to ensure that no errors occur during data transmission;
[0077] Data: occupies N bytes, specific image data fragment;
[0078] Frame tail (End): occupies 4 bytes and marks the end of the data packet.
[0079] 2. Data reply frame
[0080] The frame header (Header), confirmation code (Ack), sequence code (Seq), function code (Func), data length (Len), and checksum (CRC) are the same as those of the data transmission frame.
[0081] Return value (Ret): used to return the status of the data packet transmitted from the camera to the host computer, indicating the success or failure of the transmission.
[0082] 3. Confirmation frame
[0083] The structure of the confirmation frame is similar to that of the data transmission frame, but the data field may be empty or small, and it is only used to confirm the reception status of a data packet.
[0084] 104. When the host computer receives the frame confirmation command sent by the camera, it determines whether there is packet loss data in the image data. The frame confirmation command is used to indicate that the data sending process of the camera has ended;
[0085] After the camera completes the transmission of a frame of image data, it will send a frame confirmation command to the host computer. This command is a special signal used to notify the host computer that all data packets of the current frame have been sent. After receiving the frame confirmation command, the host computer actively enters the packet loss detection phase to determine whether there is packet loss data in the image data.
[0086] During the data transmission process, the camera will continue to send data packets to the host computer, and only the host computer will ensure the correctness of the data, without the need for handshakes and confirmations between each data packet. After sending the data, the camera will not immediately monitor whether there is packet loss and resend it, but will rely on the feedback from the host computer in the subsequent process to decide whether the data needs to be resent. Compared with the traditional handshake mechanism, there is no need for a large amount of two-way interaction between the host computer and the camera. Instead, the host computer side analyzes and confirms the changes in the frame sequence code to quickly determine packet loss, reducing the additional communication burden. It is particularly suitable for scenarios that require high-speed transmission and achieves a higher overall transmission speed.
[0087] If the host computer finds that there is packet loss data in the received image data, step 105 is executed to make the camera retransmit the image data corresponding to the packet loss data. If no packet loss data is found, step 106 is executed to package the image data.
[0088] 105. The host computer sends a retransmission request to the camera, where the retransmission request is used to enable the camera to retransmit the image data corresponding to the lost packet data to the host computer;
[0089] When the host computer determines that there is packet loss, it will generate a corresponding retransmission request. The host computer sends the retransmission request to the camera to ensure that the lost data packet can be retransmitted. After receiving the retransmission request, the camera will resend the image data packet corresponding to the lost data according to the retransmission request to ensure that the host computer can correctly receive the missing data.
[0090] Through this retransmission mechanism, the host computer can ensure that even if packet loss occurs, it can eventually receive complete image data. The design and implementation of retransmission requests is an important part of the entire image data transmission process. It improves the reliability of data transmission without requiring a large amount of interaction and effectively solves the reliability problem of the UDP protocol when data packets are lost.
[0091] 106. The host computer generates an image object by packaging the image data.
[0092] After receiving all data packets (including normal received and retransmitted data packets) and confirming that there is no packet loss, the host computer enters the packet assembly process to assemble all image data into a complete image object for use by the program.
[0093] In this embodiment, the image data transmission method is implemented based on the UDP protocol, and the reliability problem of the UDP protocol is solved by a custom retransmission mechanism. In addition, during the entire image data transmission process, handshake confirmation is no longer performed, but overall packet loss detection and retransmission are performed after the host computer receives the frame confirmation command sent by the camera, which reduces unnecessary handshake steps between the camera and the host computer, significantly improves transmission efficiency, and is particularly suitable for scenes requiring high-speed transmission. After the host computer receives the frame confirmation command sent by the camera, the host computer actively detects packet loss, and sends a retransmission request to the camera to complete the image data when packet loss is detected, which effectively makes up for the lack of reliability of the UDP protocol, and ensures the integrity of the image data while improving transmission efficiency. Compared with traditional commercial protocols (such as Giga IP), this embodiment avoids authorization restrictions by using custom protocols, and developers can flexibly customize functions, thereby reducing the development cost and complexity of 10,000 Gigabit cameras.
[0094] The following is a detailed description of the image data transmission method provided by this application. Figure 3 , Figure 3 Another embodiment of the method for transmitting image data provided by the present application includes:
[0095] 301. The camera is powered on and performs initialization and image configuration operations;
[0096] Before image acquisition, it is necessary to control the camera to power on and perform initialization and image configuration operations. First, start the camera power supply to initialize the aperture size and focus position of the lens. In addition, if the camera is equipped with a filter, the filter needs to be initialized. After that, it is also necessary to configure the image parameters, including: setting the image bit number: selecting the image bit width (such as 8bit, 10bit, 12bit or 16bit); setting the exposure value: adjusting the exposure time according to the shooting environment; setting the gain: adjusting the gain to increase the intensity of the image signal; configuring the Binning mode: selecting whether to enable the Binning mode to improve the image quality in low-light environments. Furthermore, the enabling status of the image signal processing function can be configured according to needs, that is, setting whether the ISP function is enabled. After completing all parameter settings, download the configuration parameters to the camera and you can enter the image acquisition mode.
[0097] 302. The host computer sends a picture acquisition command to the camera;
[0098] 303. When the host computer receives the response command from the camera, it enters a waiting state for a preset time;
[0099] In this embodiment, steps 302 to 303 are similar to steps 101 to 102 in the aforementioned embodiment, and are not described again here.
[0100] It should be noted that, in step 303, if the host computer does not receive a response command from the camera for a long time, it will resend an image acquisition command to the camera to restart the image data acquisition process.
[0101] 304. When the host computer still does not receive the image data uploaded by the camera after the preset time, the host computer initializes the state of the camera and re-sends a picture acquisition command to the camera.
[0102] In this embodiment, the host computer enters a waiting state after sending the image acquisition command, and the preset time is used to monitor whether the image data of the camera is received within a reasonable time. If the preset time expires but no data is received, the host computer triggers a timeout process. During the timeout process, the host computer resets the state of the camera, including clearing the cache, resetting the connection, or reconfiguring the camera parameters to ensure that the camera can return to a normal communication state. After completing the state initialization, the host computer sends the image acquisition command to the camera again to restart the image data acquisition process.
[0103] 305. The host computer receives the image data uploaded by the camera packet by packet within a preset time;
[0104] In this embodiment, step 305 is similar to step 103 in the aforementioned embodiment and will not be described again here.
[0105] 306. The host computer stores the received image data into the image queue according to the packet information, and at the same time verifies the image data and records the packet loss information, where the packet loss information includes the lost target packet sequence number and target row sequence number;
[0106] The image data carries packet information, which specifically includes a packet sequence number and a row sequence number. The packet sequence number is used to identify the order of the data packet in the entire transmission stream, and the row sequence number is used to identify the row position of the data packet in the image frame. After receiving the image data uploaded by the camera, the host computer will insert each received data packet into the correct position of the image queue according to the packet information carried in the image data, in preparation for subsequent packet assembly. The image queue is a cache structure used to store received image data packets in sequence.
[0107] During the receiving process, the host computer will check each received data packet to verify the integrity and correctness of the data. If the host computer finds that the data packet is erroneous or lost during the receiving process, the host computer will record the relevant packet loss information, which specifically includes the target packet number and target row number of the lost data, for subsequent retransmission requests.
[0108] 307. When the host computer receives the frame confirmation command sent by the camera, it determines whether there is packet loss data in the image data. The frame confirmation command is used to indicate that the data sending process of the camera has ended;
[0109] When the camera completes the entire image data transmission process, it will send a frame confirmation command to the host computer, which indicates that the transmission of all data packets has ended. The frame confirmation command is a sign actively sent by the camera, indicating that the image data transmission task on the camera side has been completed. The frame confirmation command avoids the host computer from passively waiting or blindly waiting for data, and helps the host computer correctly enter the next judgment or retransmission stage.
[0110] During the entire data transmission process, the host computer will record the packet loss in real time through the packet sequence number and row sequence number information. After receiving the frame confirmation command, the host computer can determine whether there is packet loss data in the image data based on the previously recorded packet loss information, and then decide whether further data retransmission is required. If all packet information matches and there is no packet loss information, step 309 is executed. If there is recorded packet loss information, it can be determined that there is packet loss data in the image data uploaded by the camera, and step 308 is executed to request retransmission of the lost data packet.
[0111] 308. The host computer sends a retransmission command to the camera according to the target row number and the target packet number;
[0112] According to the recorded packet loss information, the host computer generates a retransmission command, which is used to notify the camera to retransmit the lost image data packets. The retransmission command carries detailed information about the packet loss, including the location of the lost data packet (i.e., the target row number and the target packet number), ensuring that only part of the lost data packet is retransmitted, reducing unnecessary repeated transmissions, thereby improving the overall transmission efficiency. When multiple data packets are lost, the retransmission command may carry information about multiple target packets and row numbers, requiring the camera to retransmit in batches.
[0113] When the camera receives the retransmission command sent by the host computer, it will locate the location of the lost data in the cache according to the target row number and target packet number in the retransmission command, and repackage the located lost data and send it. When the camera completes the retransmission of the lost packet data, it will send a frame confirmation command to the host computer again to notify the host computer that the data transmission has ended. The host computer will then determine whether there is any lost packet data again. If the host computer finds new lost packets again, the process will repeat: the host computer initiates a new retransmission request to the camera, and the camera retransmits the lost packet data and sends a frame confirmation command. This process will be repeated until the host computer confirms that all data packets have been received correctly.
[0114] It should be noted that during the retransmission process, the host computer still needs to perform timeout judgment and resend the retransmission command to the camera when necessary. In this process, the retransmitted data packets do not require an additional handshake confirmation mechanism, but are directly sent according to the UDP protocol, which can improve the speed and transmission efficiency of data retransmission.
[0115] 309. The host computer reads data packets of image data from the image queue, and arranges and combines the data packets into an image array according to the packet information;
[0116] When the host computer confirms that all data packets of the image data have been received correctly, it enters the packet assembly process. The host computer will read the data packets of the image data from the image queue in sequence, and arrange and combine the data packets in the correct order according to the packet information carried in each data packet. The host computer fills the data into the memory one by one according to the content of the arranged and combined data packets to form a complete image array.
[0117] 310. The host computer splices the image array to obtain a complete image object;
[0118] The host computer stitches the image array. When all the data are stitched together, a complete image object will be generated for further processing and display.
[0119] 311. The host computer enables or disables the ISP algorithm through SDK operation.
[0120] Finally, the host computer can enable or disable the functions of certain ISP algorithms through SDK operations according to specific application requirements, and can adjust the parameters of the ISP algorithm to obtain the best image effect. The ISP algorithm includes image cropping, dark level processing, flat field correction and 3A algorithm. The purpose of image cropping is to cut off the unnecessary parts of the image and retain only the area of interest, which can reduce the amount of calculation for subsequent processing and improve processing efficiency. Dark level processing is to correct the noise signal captured by the image sensor when there is no light input to improve the clarity of the image. Flat field correction is used to eliminate non-uniformity between the lens and the sensor, such as optical distortion or uneven brightness, to ensure that the brightness and color of the image are consistent across the entire image plane. The 3A algorithm (i.e., automatic exposure, automatic white balance, and automatic focus) can be implemented respectively: according to the lighting conditions of the scene, automatically adjust the shutter speed and aperture size to achieve appropriate exposure; according to the lighting conditions, automatically adjust the color of the image to make the object look real under different light; according to the distance of the object in the scene, automatically adjust the focal length to ensure a clear image. Through these steps, a high-quality, noise-free, uniform color and exposure image object is finally generated.
[0121] During the transmission process, no additional complex image processing can reduce the camera processing burden, increase transmission speed, and reduce latency. After the image transmission is completed, the host computer controls the ISP function through the SDK to enable, allowing developers to flexibly process images according to different scenarios to ensure the final quality of the image.
[0122] In this embodiment, the camera is ensured to be in the best state before collecting images through power-on initialization and detailed image configuration operations. During the image data transmission process, the host computer will perform timeout detection and resend the image acquisition command or retransmission command when necessary, thereby reducing system stagnation caused by delays or failures, and quickly identifying and solving transmission problems. When receiving image data, the host computer will store the data in the image queue according to the packet information, perform verification, and record the packet loss information. After receiving the frame confirmation command sent by the camera, the host computer determines whether there is packet loss data. If there is packet loss data, it sends a retransmission command to the camera according to the recorded packet loss information, so as to effectively make up for the lack of reliability of the UDP protocol, and ensure the integrity of the image data while improving the transmission efficiency. And after the data transmission is completed, the host computer can flexibly control whether the ISP algorithm is enabled or not through the SDK, adjust the image processing parameters according to different application scenarios, and allow developers to optimize the image quality according to needs, so that the final generated image has higher clarity and uniformity.
[0123] See also Figure 4 , Figure 4The handshake process is defined as follows: The sender is the host computer and the receiver is the camera. The handshake process is based on the UDP protocol and is confirmed step by step through the seq and ack flags. Each complete command sequence code seq increases by 1, and the camera will send a frame confirmation command to inform that the data transmission is complete. The specific process is as follows:
[0124] The host computer sends a picture acquisition command (seq=0, ack=1): The host computer first sends a picture acquisition command to the camera, with the sequence number seq=0, and waits for the camera's response command ack=1.
[0125] The host computer receives the camera response command: After receiving the image acquisition command, the camera replies with the response command ack=1 to notify the host computer that it is ready to transmit image data.
[0126] Image data packet transmission: After receiving the confirmation from the camera, the host computer enters the waiting state and receives the image data packet by packet. No handshake is required in this process. Each time the camera sends a data packet, seq increases by 1.
[0127] The camera sends a frame confirmation command (seq=N, ack=1): When the image data transmission is completed, the camera will send a frame confirmation command to inform the host computer that the transmission of this image data has been completed (sequence number seq=N, corresponding to the number of data packets).
[0128] The host computer performs packet loss detection: After receiving the frame confirmation command, the host computer determines whether there is packet loss during the data transmission process. If there is no packet loss, the image data is assembled to generate a complete image object; otherwise, the exception handling process is entered.
[0129] Send a retransmission request (seq=N+1, ack=1): After the frame confirmation command, the host computer detects that the image data packet is lost, and the host computer sends a retransmission request to the camera, requiring the camera to retransmit the lost data packet.
[0130] The camera retransmits lost packet data (seq=N+2, ack=1): The camera will retransmit the lost image data packets upon request until the host computer confirms that all lost data packets have been received.
[0131] Complete retransmission and assemble packets to generate image objects: After all lost packets are retransmitted, the host computer assembles the image data to generate a complete image object.
[0132] The following is a detailed description of the image data transmission system provided by this application. Figure 5 , Figure 5 Another embodiment of the system for image data transmission provided by the present application is implemented based on the UPD protocol. The system includes: a host computer 51 and a camera 52; the host computer 51 includes:
[0133] The sending unit 511 is used to send a picture acquisition command to the camera;
[0134] A waiting unit 512, configured to enter a waiting state for a preset time when receiving a response command from the camera;
[0135] The receiving unit 513 is used to receive the image data uploaded by the camera packet by packet within a preset time;
[0136] A determination unit 514, configured to determine whether there is packet loss data in the image data when receiving a frame confirmation command sent by the camera, wherein the frame confirmation command is used to indicate that the data transmission process of the camera has ended;
[0137] A retransmission unit 515, configured to send a retransmission request to the camera when the judgment result of the judgment unit 514 is yes, the retransmission request being used to enable the camera to retransmit the image data corresponding to the packet loss data to the upper computer;
[0138] The packaging unit 516 is used to package the image data to generate an image object when the judgment result of the judgment unit is no.
[0139] Optionally, the image data carries package information, which includes a package number and a row number. The host computer also includes:
[0140] The storage unit 517 is used to store the received image data into the image queue according to the packet information, and at the same time verify the image data and record the packet loss information, the packet loss information includes the lost target packet sequence number and target row sequence number;
[0141] The retransmission unit 515 is specifically used for:
[0142] Send a retransmission command to the camera according to the target row number and target packet number.
[0143] Optionally, the packaging unit 516 is specifically used for:
[0144] Read the data packets of the image data from the image queue, and arrange and combine the data packets into an image array according to the packet information;
[0145] Concatenate the image arrays to get a complete image object.
[0146] Optionally, the host computer also includes:
[0147] The timeout unit 518 is used to initialize the state of the camera and re-send the image acquisition command to the camera when the image data uploaded by the camera is not received after the preset time.
[0148] Optionally, the ISP algorithm includes image cropping, image dark level processing, flat field correction and 3A algorithm.
[0149] Optional cameras include:
[0150] The initialization unit 521 is used to power on and perform initialization operations and image configuration operations. The initialization operations include initializing the lens aperture and initializing the focus value. The image configuration operations include configuring the image bit number, exposure value, gain, and Binning mode.
[0151] In this embodiment, the functions of each unit are the same as those described above. Figure 1 or Figure 2 The steps in the method embodiment shown correspond to each other and will not be repeated here.
[0152] This application also provides a device for transmitting image data. Figure 6 , Figure 6 An embodiment of the device for transmitting image data provided by the present application includes:
[0153] Processor 601, memory 602, input and output unit 603, bus 604;
[0154] The processor 601 is connected to the memory 602, the input and output unit 603 and the bus 604;
[0155] The memory 602 stores a program, and the processor 601 calls the program to execute any of the above image data transmission methods.
[0156] The present application also relates to a computer-readable storage medium, on which a program is stored. When the program is run on a computer, the computer executes any of the above methods for transmitting image data.
[0157] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0158] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, etc. Various media that can store program codes.
Claims
1. A method for transmitting image data, characterized in that: The method is implemented based on the UPD protocol, and the method includes: The host computer sends a picture acquisition command to the camera; When the host computer receives the response command from the camera, it enters a waiting state that lasts for a preset time; The host computer receives the image data uploaded by the camera packet by packet within the preset time; When the host computer receives a frame confirmation command sent by the camera, it determines whether there is packet loss data in the image data, and the frame confirmation command is used to indicate that the data sending process of the camera has ended; If so, the host computer sends a retransmission request to the camera, wherein the retransmission request is used to cause the camera to retransmit the image data corresponding to the lost packet data to the host computer; If not, the host computer generates an image object by packaging the image data.
2. The method according to claim 1, characterized in that The image data carries package information, and the package information includes a package sequence number and a row sequence number. After the host computer receives the image data uploaded by the camera within the preset time, the method further includes: The host computer stores the received image data into an image queue according to the packet information, and at the same time verifies the image data and records packet loss information, wherein the packet loss information includes a lost target packet sequence number and a target row sequence number; The host computer sends a retransmission command to the camera, including: The host computer sends a retransmission command to the camera according to the target row sequence number and the target packet sequence number.
3. The method according to claim 2, characterized in that The host computer generates an image object by packaging the image data, including: The host computer reads the data packets of the image data from the image queue, and arranges and combines the data packets into an image array according to the packet information; The host computer splices the image array to obtain a complete image object.
4. The method according to claim 1, characterized in that: The method further comprises: When the host computer still has not received the image data uploaded by the camera after the preset time has elapsed, the host computer initializes the state of the camera and re-sends the image acquisition command to the camera.
5. The method according to claim 1, characterized in that After the host computer generates an image object by packaging the image data, the method further includes: The host computer enables or disables the ISP algorithm through SDK operation.
6. The method according to claim 5, characterized in that The ISP algorithm includes image cropping, image dark level processing, flat field correction and 3A algorithm.
7. The method according to any one of claims 1 to 6, characterized in that Before the host computer sends a picture acquisition command to the camera, the method further includes: The camera is powered on and performs initialization operations and image configuration operations. The initialization operations include initializing the lens aperture and initializing the focus value. The image configuration operations include configuring the image bit number, exposure value, gain, and Binning mode.
8. A system for transmitting image data, characterized in that: The system is implemented based on the UPD protocol, and the system includes: a host computer and a camera; the host computer includes: A sending unit, used for sending a picture acquisition command to the camera; A waiting unit, configured to enter a waiting state lasting a preset time when receiving a response command from the camera; A receiving unit, configured to receive the image data uploaded by the camera packet by packet within the preset time; a judgment unit, configured to judge whether there is packet loss data in the image data when receiving a frame confirmation command sent by the camera, wherein the frame confirmation command is used to indicate that a data transmission process of the camera has ended; a retransmission unit, configured to send a retransmission request to the camera when the judgment result of the judgment unit is yes, wherein the retransmission request is used to enable the camera to retransmit the image data corresponding to the lost packet data to the host computer; The packaging unit is used to package the image data to generate an image object when the judgment result of the judgment unit is no.
9. A device for transmitting image data, characterized in that: The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed on a computer, the method according to any one of claims 1 to 7 is performed.