An adaptive acquisition and storage method for high-speed video data
By calculating the acquisition frame rate and storage speed through data fitting, adaptive acquisition and storage are realized, which solves the problem of incomplete data or dropped frames in high-speed video measurement systems, improves acquisition and storage efficiency, and ensures real-time lossless storage of data.
Patent Information
- Application Number
- CN202210215620.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-07
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-03-07
AI Technical Summary
During the data collection and storage process of high-speed video measurement systems, the mismatch between the collection frame rate and the storage speed results in incomplete data or frame loss. Existing solutions such as NAND FLASH storage media and kernel optimization solutions are difficult to achieve real-time lossless storage.
Obtain the relationship between the acquisition frame rate of the acquisition device and the storage speed of the storage device through data fitting, calculate the window size and storage speed, realize adaptive acquisition and storage, and design appropriate acquisition buffer size and cyclic reading and writing methods. , ensuring data integrity and storage efficiency.
It improves the collection and storage efficiency of high-speed video data, avoids data frame loss, improves the utilization of the hard disk cache area, and ensures real-time lossless storage of massive data.
Smart Images

Figure CN114845075B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video storage, and in particular to an adaptive acquisition and storage method for high-speed video data. Background Art
[0002] High-speed video measurement systems can obtain hundreds or thousands of frames of high-resolution images in a second, and are widely used in the field of industrial measurement. When using high-resolution, high-frame-rate high-speed cameras for experiments, massive amounts of data will inevitably be generated. The mismatch between the data acquisition and storage efficiency and the high-resolution, high-frame-rate data transmission and storage speed will affect the efficiency of high-speed acquisition and storage, resulting in incomplete or lost frames of collected data. Although a large-capacity cache can allow more data to be stored in the cache when the hard disk is reading and writing to increase the access speed of the hard disk, it does not mean that the larger the cache, the better. There is an algorithm problem in the application of cache. Even if the cache capacity is large, without an efficient algorithm, it will lead to a low hit rate of cached data in the application, and the advantages of a large-capacity cache cannot be effectively utilized.
[0003] Improving the efficiency of real-time acquisition and storage of massive data in the field of high-speed video measurement is an urgent problem to be solved in the industry. In terms of improving the efficiency of high-speed video acquisition and storage, many scholars have proposed many solutions to this problem. These solutions can be summarized as follows: (1) Based on FPAGA, NAND FLASH is used as the storage medium; (2) Based on the computer kernel, acquisition storage queue optimization and data parallel transmission are realized; (3) Increasing the acquisition buffer pool space to increase the acquisition rate; (4) Combining PowerPC and FPGA with SATA-based solid-state hard drives to improve storage efficiency, etc.
[0004] However, the storage solution based on NAND FLASH storage media is complex and difficult to implement, and is difficult to apply in actual engineering experiments. The kernel-based acquisition storage queue optimization can indeed improve the acquisition and storage rates, but the mismatch between the two will affect the efficiency of high-speed acquisition and storage, resulting in incomplete or lost frames in the collected data, making it difficult to achieve real-time lossless storage of massive data. Summary of the invention
[0005] The present invention provides an adaptive acquisition and storage method for high-speed video data. The functional relationship between the acquisition frame rate of an acquisition device and the window size of an acquired image, the storage speed of a storage device and the window size of an acquired image is obtained by a data fitting method. When the acquisition time and data volume are constant, the window size is calculated according to the acquisition frame rate to achieve adaptive acquisition. The storage speed is then calculated according to the window size to avoid incomplete or frame loss of the acquired data due to the mismatch between the acquisition frame rate and the storage speed. At the same time, according to the storage speed, it is determined whether it needs to be temporarily stored in a cache area of a storage device first, the cache area utilization rate of the storage device is provided, and adaptive storage is achieved. In addition, the relationship between the processor memory and the acquisition cache area is used to design an acquisition cache area size that is more beneficial to the acquisition efficiency, thereby increasing the acquisition efficiency.
[0006] The present invention can be achieved through the following technical solutions:
[0007] A method for adaptively collecting and storing high-speed video data, comprising the following steps:
[0008] Step 1: High-speed video data acquisition
[0009] In view of the actual application requirements of high-speed video data acquisition, when the acquisition time and acquisition data flow are certain, the acquisition operation is performed by calculating the window size of the acquisition image according to the acquisition frame rate of the acquisition device;
[0010] Step 2: High-speed video data transmission
[0011] Under the premise that the total buffer area is less than 50% of the processor memory capacity, the window size of the acquired image is used as the capacity of a single memory buffer, the number of memory buffers is calculated, and then the high-speed video data is read and written to each memory buffer one by one in a circular reading and writing manner;
[0012] Step 3: Storage of high-speed video data
[0013] According to the window size, the storage speed of the storage device is calculated, and then it is determined whether the storage speed is greater than the storage speed corresponding to the cache area of the storage device. If so, the high-speed video data is first stored in the hard disk cache area and then stored in the hard disk medium; otherwise, the high-speed video data is directly stored in the hard disk medium.
[0014] Furthermore, when the acquisition time and the acquisition data stream are constant, the functional relationship between the acquisition frame rate of the acquisition device and the window size of the acquired image is obtained by using a data fitting method. The functional relationship is set to
[0015] p=τ+σcos(αx)+ρsin(αx)
[0016] Among them, p represents the window size of the acquired image, the unit is bite, x represents the acquisition frame rate, the unit is fps / s, τ, σ, ρ, α represent constants;
[0017] The functional relationship between the storage speed of the storage device and the window size of the acquired image is obtained by using a data fitting method. The functional relationship is set to
[0018] p=ae (bs)
[0019] Where s represents the transmission speed of the storage device, p represents the window size of the acquired image, and a and b represent constants.
[0020] Further, when the acquisition time is set to 60s-100s and the amount of data acquired is set to 5G-8G, the constants in the functional relationship between the acquisition frame rate of the acquisition device and the window size of the acquired image are set to
[0021] τ=1.38×10 7 ,σ=-1.065×10 7 ,ρ=-8.374×10 6 , α=0.005126;
[0022] The constants in the functional relationship between the storage speed of the storage device and the window size of the acquired image are set to a=3463000 and b=-0.002282.
[0023] Furthermore, multiple memory buffers are numbered 0, 1, 2...N in sequence, and the cyclic read-write mode is set to write high-speed video data into memory buffers No. 0, 1, 2...N, 0, 1... in sequence, and then read out from memory buffers No. 0, 1, 2...N, 0, 1... in sequence.
[0024] Furthermore, the acquisition device is set to a CMOS high-speed camera, the storage device is set to a high-speed solid-state hard disk of the M.2 type NVMe protocol, and multiple optical fiber media cables are used to connect the interface of the high-speed camera to the CameraLink high-speed acquisition card, and then the CameraLink high-speed acquisition card is connected to the storage device through two multiple optical fiber media cables. The data transmission interface uses the CameraLink interface.
[0025] The CMOS high-speed camera is controlled by the CameraLink high-speed acquisition card for video acquisition, and then the video is transmitted and stored in a high-speed solid-state hard drive via an optical fiber cable.
[0026] The beneficial technical effects of the present invention are:
[0027] The present invention is in the field of high-speed video acquisition and storage, and aims to improve the acquisition and storage efficiency of high-speed video, establish an acquisition adaptive model, and design multiple memory buffers of the same size as the acquired image to increase the acquisition efficiency. An adaptive model of image window size and hard disk transmission speed is established to improve the utilization efficiency of the hard disk cache area.
[0028] (1) By utilizing the relationship between the computer's processor memory and the acquisition buffer, a collection buffer size that is more beneficial to acquisition efficiency is designed to increase acquisition efficiency.
[0029] (2) An adaptive model between the window size and the acquisition frame rate of the acquired image is established, so that the most suitable acquisition frame rate or window size can be selected when acquiring images, thereby improving the efficiency of high-speed video acquisition.
[0030] (3) An adaptive model is established regarding the window size of the stored image and the storage speed of the hard disk. This model can determine whether the image is stored in the hard disk cache area, i.e., whether there is a cache area, has buffer, or no buffer, according to the storage speed of the hard disk, thereby improving the utilization efficiency of the hard disk cache area. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic diagram of the overall process of the present invention;
[0032] Figure 2 A schematic diagram of a cyclic reading process of multiple buffers in a processor memory of the present invention;
[0033] Figure 3 This is a schematic diagram of the acquisition and storage adaptive algorithm of the present invention. DETAILED DESCRIPTION
[0034] The specific implementation of the present invention is described in detail below with reference to the accompanying drawings and preferred embodiments.
[0035] like Figure 1 and 3 As shown, the present invention provides an adaptive acquisition and storage method for high-speed video data, comprising the following steps:
[0036] Step 1: High-speed video data acquisition
[0037] In view of the actual application requirements of high-speed video data acquisition, when the acquisition time and acquisition data flow are certain, the window size of the acquisition image is calculated according to the acquisition frame rate of the acquisition device, and the acquisition operation is performed.
[0038] According to the acquisition transmission storage data stream, the stored data is:
[0039] s=t×f×p
[0040] Among them, t is the acquisition time, f is the acquisition frame rate, and p is the window size of the acquired image, which is the length and width of the image m×n.
[0041] According to the above formula, the acquisition efficiency is related to the acquisition frame rate, acquisition time and the size of the acquired image. When the acquisition time is fixed, the acquisition frame rate and the acquisition window size are the main parameters affecting the acquisition data stream. While ensuring that the data stream remains unchanged, changing the independent variable acquisition frame rate and appropriately changing the dependent variable acquisition window size can ensure that the data stream remains unchanged.
[0042] The following table shows the window size range corresponding to different acquisition frame rates when the acquisition time is fixed at 60s and the data stream is fixed at 5G.
[0043]
[0044]
[0045] The data fitting method is used to establish the functional relationship between the acquisition frame rate and the window size. After experimental testing, the functional relationship obtained by the Newton method and the general global optimization fitting method can optimize the mean square error, root mean square error and determination coefficient of the fitting result. Therefore, the fitting result is selected as the final functional relationship model, as shown below
[0046] P=τ+σ×cos(x×a)+ρ×sin(x×a)
[0047] Where p represents the window size of the acquired image, the unit is bite, x represents the acquisition frame rate, the unit is fps / s, τ, σ, ρ, α represent constants, τ = 1.38 × 10 7 ,σ=-1.065×10 7 ,ρ=-8.374×10 6 , α=0.005126.
[0048]
[0049] In order to verify the adaptability of the above functional relationship model, we set different collection times and corresponding different collection data streams to observe the changes of constants in the functional relationship model.
[0050]
[0051] The Newton method and the general global optimization method are used to fit the curves of different collection times and collection data volumes to calculate the correlation. It can be seen that several curves are highly correlated, which verifies the correctness of the function model.
[0052]
[0053] Use the new acquisition frame rate interval test and the window size, use the same method to fit the curve, and test the curve correlation with the initial function, and calculate the Fleche distance between the two curves. The Fleche distance is a description of the similarity of the path space, which can be used to compare the correlation between the two curves.
[0054] Judging from the above table, under the conditions of different acquisition time t and no data collection, the change of parameters is in line with the range of correlation variation of data fitting.
[0055] Step 2: High-speed video data transmission
[0056] On the premise that the total buffer area is less than 50% of the processor memory capacity, the window size of the acquired image is used as the capacity of a single memory buffer, the number of memory buffers is calculated, and then a circular read and write method is used to read and write high-speed video data to each memory buffer one by one.
[0057] In the process of high-speed video measurement and acquisition, an efficient buffer is required for data buffering. Disk cache, also known as disk cache, actually saves the downloaded data in the memory space allocated by the system for the software (this memory space is called the "buffer pool"). When the data saved in the memory pool reaches a certain level, the data is saved to the hard disk. This can reduce actual disk operations and effectively protect the disk from damage caused by repeated read and write operations.
[0058] If the buffer pool is designed to be too small, the data from the high-speed camera exposure and high-speed data transmission to the acquisition card will be lost before it is stored. If the buffer pool is designed to be too large, too many computer resources will be occupied. Other programs on the same computer also require computer memory space to run, which may cause the system to crash and common computer response delays.
[0059] The present invention designed an experiment to test the maximum amount of space that can be used as a buffer pool space during high-speed video acquisition in a computer environment with a 44GB memory card. In the first experiment, 4000 memory buffers were applied. In the fifth experiment, 5500 buffers were applied, and the system was stuck. Therefore, the number of buffers was adjusted to between 5800-5850, and the range was gradually narrowed to determine how many buffers could be applied. The limit of memory application was reached in the 15th experiment. After calculation, it can be known that the buffer pool capacity is greater than 22GB at this time, where the size of each buffer is 4000KB, which is more than half of the memory capacity. The experimental results are shown in the following table:
[0060]
[0061] Therefore, set the buffer pool size to no more than 50% of the computer's processor memory.
[0062] Capture equipment such as high-speed cameras expose data at high speed and transmit the data to the capture card through high-speed transmission media and interfaces. After receiving the data, the capture card sends the data to the memory buffer pool. However, the data transmission speed is too high and the buffer pool will be filled. After it is filled, the data generated by the high-speed camera will not be stored in the memory buffer pool, but will be discarded by the capture card. This will cause frame loss, which has very serious consequences. Since the buffer pool includes multiple buffers, the present invention proposes that a cyclic read-write method can be used to store the collected data. At the same time, each buffer can be written repeatedly, which minimizes the problem of frame loss. The number of buffers can be calculated using the following equation:
[0063] c=δ×β
[0064] Among them, c is the memory space occupied by the buffer pool in the computer, δ is the number of buffers, and β is the size of the buffer, that is, the window size of the image.
[0065] Note that multiple memory buffers are numbered 0, 1, 2...N in sequence. The cyclic read-write mode is set to write high-speed video data into memory buffers No. 0, No. 1, No. 2... No. N, No. 0, No. 1... in sequence, and then read out from memory buffers No. 0, No. 1, No. 2... No. N, No. 0, No. 1... in sequence, as follows:
[0066] The buffer pool is a space applied in the memory to store the data generated by the high-speed camera exposure. The data reaches the acquisition card through the high-speed data transmission interface, and the acquisition card transmits it to the corresponding buffer. Figure 2 As shown in the figure, there are 4 buffers, each with its own corresponding buffer number. The buffer number is designed to be able to write and read a specific buffer. At this time, memory buffers 0-2 have all been written with data. If there is new data transmission to be written, it will be written to memory buffer 3. After all buffers are occupied, if there is new data transmission to be written, it will continue to be written from buffer 0, and so on. This is the design of the cyclic read and write method.
[0067] After the data is written into the buffer pool in a loop, it will be read and written via asynchronous I / O. Asynchronous I / O can store the data in the buffer in different threads to ensure storage efficiency. When the asynchronous thread ends, the stored frame number will be checked to ensure that no frames are lost during the buffer storage process.
[0068] Step 3: Storage of high-speed video data
[0069] According to the window size, the storage speed of the storage device is calculated, and then it is determined whether the storage speed is greater than the storage speed corresponding to the cache area of the storage device. If so, the high-speed video data is first stored in the hard disk cache area and then stored in the hard disk medium; otherwise, the high-speed video data is directly stored in the hard disk medium.
[0070] Although a large-capacity cache can store more data in the cache to improve the access speed of the hard disk when the hard disk is reading and writing, it does not mean that the larger the cache, the better. There is an algorithm problem in the application of cache. Even if the cache capacity is large, without an efficient algorithm, it will lead to a low hit rate of cached data in the application and cannot effectively play the advantages of a large-capacity cache. The algorithm and cache capacity complement each other. A large-capacity cache requires a more efficient algorithm, otherwise the performance will be greatly reduced. Therefore, adaptive judgment of whether there is a hard disk cache area based on the image size and the hard disk write speed is one aspect of improving storage efficiency.
[0071] First, the storage speed of the hard disk is tested to obtain the parameters of the hard disk's write speed.
[0072]
[0073] Secondly, through a large number of experimental tests, a large amount of data on the window size of the acquired image at different storage speeds is obtained, as shown in the following table.
[0074]
[0075] The Newton method and the general global optimization method are used to fit the data of the hard disk write speed and the window size, and the optimal functional relationship model is obtained, as shown in the following formula.
[0076] p=ae (bs)
[0077] Where s represents the transmission speed of the storage device, p represents the window size of the acquired image, and a and b represent constants: a = 3463000, b = -0.002282.
[0078] By calculating the correlation of different fitting curves, it can be seen that the root mean square error and determination coefficient of the function model obtained by the Newton method and the general global optimization method are optimal. The correlation of several fitting curves is shown in the following table.
[0079]
[0080] Then, using the functional relationship, the storage speed of the storage device is calculated according to the window size of the acquired image, and then it is determined whether the storage speed is greater than the storage speed corresponding to the cache area of the storage device. If so, the high-speed video data is first stored in the hard disk cache area and then stored in the hard disk medium; otherwise, the high-speed video data is directly stored in the hard disk medium, and the storage method with the highest storage efficiency is selected to reduce image loss and realize adaptive storage.
[0081] Based on the above acquisition and storage method, a hardware system as shown in the figure can be built. The hardware system consists of the following modules: (1) High-speed image acquisition module. A cameralink high-speed camera can be used as the image acquisition module with a resolution of 2048*2020, an acquisition frame rate of 1-500fps, and an image bit depth of 8 bits.
[0082] (2) High-speed transmission hardware module, which can use two high-speed data transmission lines such as optical fiber medium cables. The data transmission interface is cameralink, and the total transmission speed is 2.5GB / s. The high-speed data transmission line connects the high-speed camera and the high-speed image acquisition card such as CameraLink high-speed acquisition card. The high-speed image acquisition card is mounted on the PCIe3.0*4 interface of the Dell graphics workstation. The CMOS high-speed camera can be controlled through the CameraLink high-speed acquisition card to perform video acquisition.
[0083] (3) High-speed storage hardware module. The M.2 NVMe protocol high-speed solid-state drive Samsung 970 Pro 512GB is used as the storage medium. The solid-state drive is mounted on the M.2 interface of the Dell graphics workstation. The CameraLink high-speed capture card is then connected to the storage device through multiple optical fiber cables. The video can then be transmitted and stored in the high-speed solid-state drive through the optical fiber cables.
[0084] Although specific embodiments of the present invention are described above, those skilled in the art should understand that these are merely examples and that various changes or modifications may be made to these embodiments without departing from the principles and essence of the present invention. Therefore, the scope of protection of the present invention is limited by the appended claims.
Claims
1. A method for adaptively collecting and storing high-speed video data, characterized in that The following steps are involved: Step 1: High-speed video data acquisition In view of the actual application requirements of high-speed video data acquisition, when the acquisition time and acquisition data flow are certain, the acquisition operation is performed by calculating the window size of the acquisition image according to the acquisition frame rate of the acquisition device; Step 2: High-speed video data transmission Under the premise that the total buffer area is less than 50% of the processor memory capacity, the window size of the acquired image is used as the capacity of a single memory buffer, the number of memory buffers is calculated, and then the high-speed video data is read and written to each memory buffer one by one in a circular reading and writing manner; Step 3: Storage of high-speed video data According to the window size, the storage speed of the storage device is calculated, and then it is determined whether the storage speed is greater than the storage speed corresponding to the cache area of the storage device. If so, the high-speed video data is first stored in the hard disk cache area and then stored in the hard disk medium; Otherwise, the high-speed video data is directly stored in the hard disk medium; When the acquisition time and the acquisition data stream are constant, the functional relationship between the acquisition frame rate of the acquisition device and the window size of the acquired image is obtained by using the data fitting method. The functional relationship is set to p=τ+σcos(αx)+ρsin(αx) Among them, p represents the window size of the acquired image, the unit is bite, x represents the acquisition frame rate, the unit is fps / s, τ, σ, ρ, α represent constants; The functional relationship between the storage speed of the storage device and the window size of the acquired image is obtained by using a data fitting method. The functional relationship is set to p=ae (bs) Where s represents the transmission speed of the storage device, p represents the window size of the acquired image, and a and b represent constants.
2. The method for adaptively collecting and storing high-speed video data according to claim 1, characterized in that: When the acquisition time is set to 60s-100s and the amount of data acquired is set to 5G-8G, the constants in the functional relationship between the acquisition frame rate of the acquisition device and the window size of the acquired image are set to τ=1.38×10 7 ,σ=-1.065×10 7 ,ρ=-8.374×10 6 ,α=0.005126; The constants in the functional relationship between the storage speed of the storage device and the window size of the acquired image are set to a=3463000 and b=-0.002282.
3. The method for adaptively collecting and storing high-speed video data according to claim 1, characterized in that: Multiple memory buffers are numbered 0, 1, 2...N in sequence, and the cyclic read-write mode is set to write high-speed video data into memory buffers No. 0, 1, 2...N, 0, 1... in sequence, and then read out from memory buffers No. 0, 1, 2...N, 0, 1... in sequence.
4. The method for adaptively collecting and storing high-speed video data according to claim 1, characterized in that: The acquisition device is set as a CMOS high-speed camera, and the storage device is set as a high-speed solid-state hard disk of the M.2 type NVMe protocol. A plurality of optical fiber media cables are used to connect the interface of the high-speed camera with the CameraLink high-speed acquisition card, and then the CameraLink high-speed acquisition card is connected to the storage device through two or more optical fiber media cables. The data transmission interface uses the CameraLink interface. The CMOS high-speed camera is controlled by the CameraLink high-speed acquisition card for video acquisition, and then the video is transmitted and stored in a high-speed solid-state hard drive via an optical fiber cable.
Citation Information
Cited By
Outdoor supervision-oriented multimode behavior perception and time domain attenuation intelligent detection device
CN122205037A
