A method and device for securely encrypting real-time video data
By applying hybrid mapping encryption algorithm and hash encryption technology in video encryption, combining the characteristics of timestamps and blocked video data, the real-time video encryption problem in the existing technology is solved, and efficient, secure and real-time video data encryption is achieved.
Patent Information
- Application Number
- CN202411062266.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-08-05
AI Technical Summary
Existing video encryption methods are difficult to meet the needs of real-time video encryption, and ignore the spatiotemporal characteristics of video data, resulting in delays or distortions of encrypted video data.
The chaos mapping encryption algorithm is used to obtain the real-time video data and timestamp collected by the video acquisition device, generate the initial chaotic encryption key value, and generate the corresponding encryption key according to the data length of the chunked video data, and encrypt the chunked data packets in combination with hash encryption technology.
It realizes efficient, secure and real-time encryption of real-time video data, ensuring the integrity and confidentiality of video data, and avoiding the delay in video acquisition and transmission in the encryption process.
Smart Images

Figure CN118972654B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data security technology, and in particular to a method and device for secure encryption processing of real-time video data from a camera. Background Art
[0002] With the continuous development of science and technology, video acquisition equipment has been widely used in various fields, such as security monitoring, remote conferencing, media production, etc. However, the transmission and storage of video data often face security challenges, especially in today's complex and changeable network environment. How to ensure the integrity and confidentiality of video data has become an urgent problem to be solved.
[0003] Traditional video encryption methods mostly use symmetric or asymmetric encryption algorithms. Although they can protect the security of video data to a certain extent, they are often difficult to meet the needs of real-time video encryption due to the complexity and computational overhead of the algorithm itself. At the same time, traditional encryption methods often ignore the temporal and spatial characteristics of video data, which may cause problems such as delay or distortion when decrypting and playing the encrypted video data. Summary of the invention
[0004] The purpose of the present invention is to provide a method and device for securely encrypting real-time video data from a camera, aiming to solve technical problems existing in related scenarios.
[0005] In order to achieve the above-mentioned purpose, a first aspect of the embodiments of the present disclosure provides a method for securely encrypting real-time video data, comprising:
[0006] Acquire real-time video data captured by a video capture device and a timestamp of each frame of the real-time video data;
[0007] The first timestamp corresponding to the real-time video data is used as the initial state parameter of the chaotic mapping encryption algorithm, and an initial chaotic encryption key value is generated according to the preset control parameters;
[0008] The real-time video data is divided into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data;
[0009] Based on the initial chaotic encryption key value, taking the data length of each of the block video data as a control parameter, generating a chaotic encryption key value as an encryption key corresponding to the block video data;
[0010] Based on the chaotic mapping encryption algorithm, each of the block video data is preliminarily encrypted by the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data;
[0011] Hash encryption of the block data packets is performed according to the timestamp of the preset designated frame in each block video data and the corresponding block data packet to complete the secure encryption processing of the real-time camera video data.
[0012] In a possible implementation, the real-time video data is divided into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each of the block video data, including:
[0013] Traversing and determining the grayscale value of each pixel in each video frame of the real-time video data and the texture features in each video frame;
[0014] Determine a gray level co-occurrence matrix of the video frame according to the gray value of the pixel point in each video frame and the corresponding texture feature;
[0015] Calculating a specified statistic of the video frame according to the gray level co-occurrence matrix, and comparing the specified statistics of the gray level co-occurrence matrices corresponding to different video frames;
[0016] The video frames whose designated statistics meet preset conditions are divided into the same sub-bureau video data to obtain a plurality of sub-block video data, and the timestamp of the preset designated frame in each of the sub-block video data is obtained.
[0017] In a possible implementation, determining the gray level co-occurrence matrix of the video frame according to the gray value of the pixel point in each video frame and the corresponding texture feature includes:
[0018] Determining a direction parameter and a distance parameter of each video frame according to the texture feature of each video frame, wherein the direction parameter is used to represent a relative direction between pixel pairs in the video frame;
[0019] For each of the pixel points, query the corresponding target pixel point according to the direction parameter and the distance parameter corresponding to the corresponding video frame, and determine the grayscale value of the target pixel point;
[0020] The number of times the pixel points and the corresponding target pixel points appear in each of the video frames is counted, and the results are stored in a two-dimensional array to obtain a grayscale co-occurrence matrix of the video frame, wherein the rows and columns of the grayscale co-occurrence matrix correspond to the value ranges of the grayscale values of the pixel points and the grayscale values of the target pixel points, respectively.
[0021] In a possible implementation, for each pixel point, querying a corresponding target pixel point according to a direction parameter and a distance parameter corresponding to the corresponding video frame, and determining a grayscale value of the target pixel point includes:
[0022] For each pixel point (x, y), determine the components of the direction parameter in the x direction and the y direction according to the direction parameter corresponding to the corresponding video frame;
[0023] For each pixel point (x, y), query the corresponding target pixel point (x+a, y+b) according to the components of the corresponding direction parameters in the x direction and the y direction, where a and b are distance parameters respectively, and determine the grayscale value g2 of the target pixel point.
[0024] In a possible implementation, counting the number of occurrences of pixels and corresponding target pixels in each of the video frames, and storing the results in a two-dimensional array to obtain a gray-level co-occurrence matrix of the video frame includes:
[0025] Counting the number of times a pixel point and a corresponding target pixel point appear in each of the video frames, and using the grayscale value of the pixel point as a row coordinate and the grayscale value of the target pixel point as a column coordinate to query the position of the target element in the two-dimensional array;
[0026] In the two-dimensional array, the numerical value of the number of times is used as the filling value of the corresponding target element position to obtain the gray level co-occurrence matrix of the video frame.
[0027] In a possible implementation, the specified statistic includes at least one of energy and contrast of a gray level co-occurrence matrix.
[0028] In a possible implementation, based on the initial chaotic encryption key value, taking the data length of each of the block video data as a control parameter, generating a chaotic encryption key value as an encryption key corresponding to the block video data includes:
[0029] Based on the initial chaotic encryption key value, the data length of each of the block video data is input into the chaotic map as a control parameter, and the state of the chaotic map is iteratively updated;
[0030] Determine the number of iterations according to the multiple relationship between the data length and the preset standard data length, wherein if the data length is less than the preset standard data length, the minimum number of iterations is used as a default value, and if the data length exceeds a preset threshold, the maximum number of iterations is used as an upper limit;
[0031] In the case where the number of iterative updates meets the number of iterations, a key sequence of a preset length is extracted from the state of the chaotic map as a chaotic encryption key value corresponding to the block video data.
[0032] A second aspect of the embodiments of the present disclosure provides a device for securely encrypting real-time video data from a camera, comprising:
[0033] An acquisition module is configured to acquire real-time video data acquired by a video acquisition device and acquire a timestamp of each frame of the real-time video data;
[0034] The first generating module is configured to use the first timestamp corresponding to the real-time video data of the camera as the initial state parameter of the chaotic mapping encryption algorithm, and generate an initial chaotic encryption key value according to the preset control parameters;
[0035] A block division module is configured to divide the real-time video data into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data;
[0036] The second generating module is configured to generate a chaotic encryption key value as an encryption key corresponding to the block video data based on the initial chaotic encryption key value and taking the data length of each block video data as a control parameter;
[0037] A preliminary encryption module is configured to perform preliminary encryption processing on each of the block video data based on a chaotic mapping encryption algorithm by using the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data;
[0038] The hash encryption module is configured to perform hash encryption on the block data packets according to the timestamp of the preset designated frame in each block video data and the corresponding block data packets, so as to complete the security encryption processing of the real-time video data of the camera.
[0039] According to a third aspect of the present disclosure, an electronic device is provided, including:
[0040] Microcontroller;
[0041] a memory for storing instructions executable by the microcontroller;
[0042] The microcontroller is configured to execute executable instructions stored in the memory to perform the method described in any one of the first aspects.
[0043] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0044] The present invention provides a method and device for secure encryption processing of real-time video data from a camera. Compared with the prior art, the method utilizes the high randomness and unpredictability of chaotic mapping to generate an encryption key with complexity and security, so that the encrypted video data is difficult to be cracked. At the same time, by combining timestamp information, the complexity and security of encryption are further enhanced. While acquiring the real-time video data from the camera, encryption processing is performed synchronously to ensure the real-time nature of encryption. By optimizing the algorithm and reducing the computational overhead, the encryption process does not cause significant delays in the acquisition and transmission of the video. By processing the video data in blocks and generating corresponding encryption keys according to the data length of each block, refined encryption of the video data is achieved. This encryption method not only ensures the security of encryption, but also can perform differentiated encryption processing according to different data blocks, thereby improving the flexibility of encryption. By combining hash encryption technology, the block data packets are further encrypted to ensure the integrity of the video data. Any tampering or destruction of the data will result in a change in the hash value, which can be effectively detected. Therefore, by combining timestamp, chaotic map encryption algorithm and hash encryption technology, an efficient, secure and real-time video encryption processing method is realized, which provides strong security protection for the transmission and storage of video data.
[0045] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0047] Figure 1 It is a flow chart of a method for securely encrypting real-time video data according to an embodiment of the specification.
[0048] Figure 2 It is a block diagram of a camera real-time video data security encryption processing device according to an embodiment of the specification. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0051] In order to achieve the above-mentioned purpose, the present invention provides a method for securely encrypting real-time video data. Figure 1 This is a flow chart showing a method for securely encrypting real-time video data from a camera according to an embodiment. The system includes:
[0052] In step S11, real-time video data captured by a video capture device and a timestamp of each frame of the real-time video data are acquired;
[0053] The video acquisition device is a hardware device used to capture real-time video streams, such as cameras, camcorders, etc. The real-time video data is a data stream consisting of continuous video frames captured by the video acquisition device. The timestamp is a value used to mark the time when the data (here, the video frame) is generated or captured.
[0054] In the disclosed embodiments, a video acquisition device (such as a camera) captures the light signal of a scene through a sensor, converts it into an electrical signal, and then converts it into a digital signal through a digital signal processing technology (such as analog-to-digital conversion ADC). Real-time video data is presented in the form of continuous frames, and each frame has its own specific timestamp, indicating the time point when the frame was captured. The acquisition of the timestamp is usually achieved through the clock system of the video acquisition device or an external clock system synchronized therewith.
[0055] In step S12, the first timestamp corresponding to the real-time video data is used as the initial state parameter of the chaotic mapping encryption algorithm, and an initial chaotic encryption key value is generated according to the preset control parameters;
[0056] Among them, the chaotic mapping encryption algorithm is an encryption algorithm based on chaos theory, which uses the high sensitivity of chaotic systems to initial conditions to generate random and unpredictable key sequences. The initial state parameters are the starting conditions for the chaotic system to start iteration or calculation. The preset control parameters are parameters used in the chaotic system to affect the iteration process or output results, which are usually fixed or predefined.
[0057] In the disclosed embodiment, the timestamp of the first video frame is used as the initial state parameter of the chaotic map encryption algorithm. Then, the chaotic map encryption algorithm is run through preset control parameters (such as the number of iterations, specific parameters of the chaotic map, etc.) to generate an initial chaotic encryption key value. For example, using Logistic mapping as the chaotic map encryption algorithm, the first timestamp is converted into a value between 0 and 1 as the initial state, and a chaotic sequence is generated as the initial key value through the preset number of iterations and mapping parameters.
[0058] In the disclosed embodiment, the first timestamp is used as the initial state parameter of the chaotic map, which means that the state of the chaotic map begins to evolve from this timestamp. The preset control parameters may be some internal parameters of the chaotic map, such as the number of iterations, the step size, etc., which determine the evolution mode and speed of the chaotic map. Through the evolution of the chaotic map, a seemingly random initial chaotic encryption key value can be generated.
[0059] In step S13, the real-time video data is divided into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each of the block video data;
[0060] The block video data is a plurality of smaller video segments divided into original video data according to certain rules (such as size, time length, etc.). The preset designated frame is a specific frame selected in each block video data for subsequent data processing or encryption.
[0061] In the disclosed embodiment, the real-time video data can be divided into blocks according to a fixed size (such as every 1MB or every N seconds) or a fixed number of frames. At the same time, the timestamp of a preset specified frame (such as the first or last frame) in each block is recorded. For example, the video data is divided into a block every 5 seconds, and the timestamp of the first frame in each block is recorded.
[0062] In step S14, based on the initial chaotic encryption key value, a chaotic encryption key value as an encryption key corresponding to the block video data is generated with the data length of each block video data as a control parameter;
[0063] In the disclosed embodiment, the initial chaotic encryption key value is used as the starting point, and the data length of each block video data is used as a new control parameter to run the chaotic map encryption algorithm again. A unique chaotic encryption key value corresponding to the block video data is generated according to the data length. For example, for a block with a data length of 1MB, a unique chaotic key value is generated using a Logistic map and combined with the data length (converted to a value between 0 and 1).
[0064] In the disclosed embodiment, after obtaining the initial chaotic encryption key value, the chaotic mapping can be applied again to generate the corresponding chaotic encryption key value according to the data length of each block video data as a new control parameter. Since the data length of each block is different, the generated chaotic encryption key value will also be different, which increases the complexity and security of encryption.
[0065] In step S15, based on the chaotic mapping encryption algorithm, each of the block video data is preliminarily encrypted by the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data;
[0066] The chaotic encryption key value generated for each block of video data is used to perform preliminary encryption processing on the block video data through a chaotic mapping encryption algorithm. This usually involves applying a key value to each byte or bit of the video data for encryption operation. The encrypted data forms a block data packet. For example, each block of video data is encrypted using its corresponding chaotic key value to obtain an encrypted block data packet.
[0067] In the disclosed embodiment, each block of video data is encrypted using the previously generated chaotic encryption key value. The encryption process may involve bit manipulation, replacement, permutation and other operations on the video data, depending on the design of the chaotic map encryption algorithm. The encrypted data will be encapsulated into data packets, each data packet corresponding to a block of video data.
[0068] In step S16, hash encryption is performed on the block data packets according to the timestamp of the preset designated frame in each block video data and the corresponding block data packet to complete the security encryption processing of the real-time video data.
[0069] The timestamp of a preset specified frame is used as the input of the hash function to generate a unique hash value. This hash value is then used as part of the encrypted chunked data packet or is associated with the chunked data packet in some way to provide data integrity and authentication functions.
[0070] Specifically, assume that SHA-256 (a common hash function) is used as the hash encryption algorithm. For each block of video data, extract the timestamp of the preset specified frame (for example, the timestamp of the first frame of each block) and convert it into a string format (if necessary). Then, use this timestamp string as input to generate a 256-bit hash value through the SHA-256 hash function.
[0071] Next, this hash value can be incorporated into the chunked data packet in different ways. For example, the hash value can be appended to the header or trailer of the packet, or the hash value can be embedded in a specific location in the packet. This way, when the receiver receives the packet, they can recalculate the hash value (using the same timestamp and hash function) and compare it to the hash value stored in the packet. If the two hash values are the same, then the integrity of the packet is verified, indicating that the packet has not been tampered with during transmission.
[0072] For example: suppose there is a block video data, and the timestamp of the preset specified frame is "2023-09-17 10:30:15". Convert this timestamp into a string and generate a hash value through the SHA-256 hash function. The generated hash value will be a string consisting of 64 hexadecimal digits, such as "abcdef1234567890..." (only part of it is shown here for simplicity).
[0073] This hash value is then appended to the end of the chunked packet and the entire packet is sent to the receiver. When the receiver receives the packet, it extracts the timestamp and recalculates the hash value using the same SHA-256 hash function. If the recalculated hash value is the same as the hash value stored in the packet, then the receiver can confirm that the packet is intact and has not been tampered with. If the hash values are different, then the receiver knows that something went wrong with the packet during transmission and can take appropriate action (such as requesting that the packet be resent).
[0074] In the disclosed embodiment, a hash value is generated by using the timestamp of a preset designated frame in each block video data as one of the inputs of the hash function (other inputs such as a random salt value may also be required). Then, the hash value is used as an encryption key or verification information to encrypt or sign the corresponding block data packet again. In this way, even if the data packet is tampered with during transmission, it can be verified and detected by the hash value. Finally, the secure encryption processing of the real-time video data of the camera is completed.
[0075] The above technical solution utilizes the high randomness and unpredictability of chaotic mapping to generate an encryption key with complexity and security, making the encrypted video data difficult to crack. At the same time, by combining the timestamp information, the complexity and security of encryption are further enhanced. While acquiring the real-time video data of the camera, encryption processing is performed synchronously to ensure the real-time nature of encryption. By optimizing the algorithm and reducing the computational overhead, the encryption process does not cause significant delays to the acquisition and transmission of the video. By processing the video data in blocks and generating corresponding encryption keys according to the data length of each block, the refined encryption of the video data is achieved. This encryption method not only ensures the security of encryption, but also can perform differentiated encryption processing according to different data blocks, thereby improving the flexibility of encryption. By combining the hash encryption technology, the block data packets are further encrypted to ensure the integrity of the video data. Any tampering or destruction of the data will cause a change in the hash value, which can be effectively detected. Therefore, by combining the timestamp, the chaotic mapping encryption algorithm and the hash encryption technology, an efficient, secure and real-time video encryption processing method is realized, which provides a strong security guarantee for the transmission and storage of video data.
[0076] In a possible implementation, in step S13, the real-time video data is divided into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each of the block video data, including:
[0077] In step S131, the gray value of each pixel in each video frame of the real-time video data and the texture features in each video frame are determined by traversing;
[0078] In the disclosed embodiment, each frame of the real-time video data is traversed and the grayscale value of each pixel is analyzed. The grayscale value represents the brightness information of the image. At the same time, the texture features of each frame are analyzed. The texture features describe the pattern and regularity of the grayscale distribution of pixels in the local area of the image.
[0079] In step S132, a gray level co-occurrence matrix of the video frame is determined according to the gray value of the pixel point in each video frame and the corresponding texture feature;
[0080] Among them, the gray level co-occurrence matrix is a method based on the positional relationship between gray level pixels, which describes the spatial distribution relationship between pixels of different gray levels in the image. By calculating the gray level co-occurrence matrix, the texture features of the image can be further extracted. The gray level co-occurrence matrix of each frame is calculated based on the extracted pixel gray values and texture features. This matrix records the relative position and frequency between different gray level pixel pairs in the video frame, thereby reflecting the texture features of the video frame.
[0081] In step S133, a specified statistic of the video frame is calculated according to the gray level co-occurrence matrix, and the specified statistics of the gray level co-occurrence matrices corresponding to different video frames are compared;
[0082] After obtaining the gray-level co-occurrence matrix, the system calculates some statistics (such as contrast, correlation, energy, entropy, etc.) that can quantitatively describe the texture characteristics of the image. Then, the system compares the specified statistics of the gray-level co-occurrence matrices of different video frames to evaluate the similarities or differences between them.
[0083] In step S134, the video frames whose designated statistics satisfy preset conditions are divided into the same block video data to obtain a plurality of block video data, and the timestamp of the preset designated frame in each block video data is obtained.
[0084] After comparing the gray-level co-occurrence matrix statistics of different video frames, the system will classify the video frames that meet the conditions into the same block video data according to preset conditions (such as the threshold of the statistic, similarity, etc.). In this way, the system can combine video frames with similar texture features to form multiple block video data. At the same time, the system will also record the timestamp of the preset specified frame in each block video data.
[0085] The above technical solution can traverse each frame of the real-time video data of the camera, extract the gray value of each pixel, and analyze the texture features of each frame. This step provides basic data for the subsequent grayscale co-occurrence matrix calculation, ensuring the accuracy of the block operation. The grayscale co-occurrence matrix can reflect the spatial distribution relationship between pixels of different gray levels in the image, and then reflect the texture features of the video frame. According to the grayscale co-occurrence matrix, the specified statistics of each video frame are calculated, and these statistics can quantitatively describe the texture features of the video frame. Subsequently, the specified statistics of the grayscale co-occurrence matrices of different video frames are compared to evaluate the similarity or difference between them. The video frames whose specified statistics meet the preset conditions are divided into the same block video data. In this way, video frames with similar texture features and grayscale distribution are combined together to form a plurality of block video data. At the same time, the timestamp of the preset specified frame is obtained for each block video data, which is convenient for subsequent video processing and analysis.
[0086] Overall, the intelligent segmentation of real-time video data from the camera is realized, which improves the efficiency and accuracy of video processing. Through the segmentation method based on grayscale value and texture features, the technology can automatically identify and combine video frames with similar features, which facilitates subsequent video analysis, storage and transmission. At the same time, the technology also retains the timestamp information of each segmented video data, which helps to locate and analyze the video content in time.
[0087] In a possible implementation, in step S132, determining the gray level co-occurrence matrix of the video frame according to the gray value of the pixel point in each video frame and the corresponding texture feature includes:
[0088] In step S1321, according to the texture features of each video frame, a direction parameter and a distance parameter of each video frame are determined, wherein the direction parameter is used to represent the relative direction between pixel pairs in the video frame;
[0089] The direction parameter indicates the relative direction between pixel pairs, and is usually set to 0°, 45°, 90°, 135° (or other finer angle divisions), which is used to describe the directionality of grayscale value changes between pixels. Assume that four direction parameters (0°, 45°, 90°, 135°) and two distance parameters (d=1, d=2) are set. For each pixel in the video frame, other pixels that are 1 or 2 pixels away from it in these four directions will be considered as its target pixels.
[0090] In step S1322, for each pixel point, according to the direction parameter and distance parameter corresponding to the corresponding video frame, the corresponding target pixel point is queried, and the grayscale value of the target pixel point is determined;
[0091] Among them, traverse each pixel point in the video frame, and query the target pixel points of the pixel point in these directions and distances according to the previously determined direction parameters and distance parameters. Then, read the grayscale values of these target pixel points. For example: for a pixel point P in the video frame, according to the set direction parameters and distance parameters, find its target pixel point P1 that is 1 pixel away from it in the 0° direction, and read the grayscale value of P1. Then, find its target pixel point P2 that is 2 pixels away from it in the 45° direction, and read the grayscale value of P2. And so on, get the grayscale values of the target pixel points of the pixel point in all set directions and distances.
[0092] In step S1323, the number of times the pixel points and the corresponding target pixel points appear in each of the video frames is counted, and the results are stored in a two-dimensional array to obtain a grayscale co-occurrence matrix of the video frame, wherein the rows and columns of the grayscale co-occurrence matrix correspond to the value ranges of the grayscale values of the pixel points and the grayscale values of the target pixel points, respectively.
[0093] Among them, the number of occurrences of all pixel points in the video frame and their target pixel grayscale value pairs in various directions and distances is counted. These times are stored in a two-dimensional array to form a grayscale co-occurrence matrix. The rows and columns of the matrix correspond to the value ranges of the grayscale values of the pixel points and the grayscale values of the target pixel points, respectively. For example: Assume that the grayscale value range of the video frame is 0-255, and use a 256x256 two-dimensional array to represent the grayscale co-occurrence matrix. For each pixel point and its target pixel grayscale value pair (g1, g2), add 1 to the corresponding position (g1, g2) in the matrix. In this way, the final two-dimensional array is the grayscale co-occurrence matrix of the video frame, which reflects the spatial distribution relationship between pixel pairs with different grayscale values in the image.
[0094] The above technical solution can determine the direction parameter and distance parameter by considering the texture features of the video frame, which helps to more accurately capture the spatial distribution and grayscale change relationship between pixel pairs. According to the determined direction parameter and distance parameter, the corresponding target pixel point is queried for each pixel point, and the grayscale value of these target pixel points is determined. The grayscale co-occurrence matrix not only reflects the spatial distribution relationship between pixel pairs with different grayscale values in the video frame, but also reflects the grayscale change characteristics between pixel pairs.
[0095] In a possible implementation, in step S1322, for each pixel point, according to the direction parameter and the distance parameter corresponding to the corresponding video frame, querying the corresponding target pixel point, and determining the grayscale value of the target pixel point includes:
[0096] In step S13221, for each pixel point (x, y), components of the direction parameter in the x direction and the y direction are determined according to the direction parameter corresponding to the corresponding video frame;
[0097] In the disclosed embodiment, the direction parameter is converted from polar coordinates (angle) to Cartesian coordinates (components in the x and y directions). The direction parameter is usually an angle value (such as 0°, 45°, 90°, 135°, etc.), and trigonometric functions (such as sine and cosine) can be used to calculate the components of this angle in the x and y directions.
[0098] In step S13222, for each pixel point (x, y), the corresponding target pixel point (x+a, y+b) is queried according to the components of the corresponding direction parameters in the x direction and the y direction, where a and b are distance parameters respectively, and the grayscale value g2 of the target pixel point is determined.
[0099] In the disclosed embodiment, the coordinates of the target pixel are determined using the calculated components of the x and y directions and the set distance parameters a and b. Specifically, the coordinates (x, y) of the current pixel are added to the components of the direction parameters in the x and y directions (multiplied by the distance parameters) to obtain the coordinates (x+a, y+b) of the target pixel. Then, the pixel corresponding to this coordinate is queried and its grayscale value g2 is obtained.
[0100] For example: Assume that the coordinates of the current pixel are (10,10), the direction parameter is 45°, and the distance parameters a and b are both 1 (for simplicity, a and b are assumed to be equal, but they can be different values). The x-direction component and the y-direction component are both square root of 2 (can be integer or rounded to the nearest pixel). Therefore, the coordinates of the target pixel are (10+1,10+1), that is, (11,11). Then, query the pixel with coordinates (11,11) in the video frame and obtain its grayscale value g2.
[0101] In a possible implementation, in step S1323, counting the number of occurrences of the pixel points and the corresponding target pixel points in each of the video frames, and storing the results in a two-dimensional array, to obtain the gray level co-occurrence matrix of the video frame includes:
[0102] In step S13231, the number of times the pixel points and the corresponding target pixel points appear in each of the video frames is counted, and the grayscale value of the pixel points is used as the row coordinate, and the grayscale value of the target pixel points is used as the column coordinate to query the target element position in the two-dimensional array;
[0103] Among them, according to the range of grayscale values, a two-dimensional array (usually called grayscale co-occurrence matrix) is initialized. The number of rows and columns of the array are equal to the maximum value of the grayscale value plus one (for example, if the grayscale value range is 0-255, the array size is 256x256). For each pixel in the video frame and its corresponding target pixel, their grayscale values are extracted. The grayscale value of the pixel is used as the row coordinate and the grayscale value of the target pixel is used as the column coordinate to query the corresponding position in the two-dimensional array. If the position has not been visited (that is, the value is 0 or a certain initial value), start counting the number of times this pair of pixels appears.
[0104] For example: suppose there is a pixel P with a grayscale value of 100, and the corresponding target pixel T has a grayscale value of 150. A 256x256 two-dimensional array (grayscale co-occurrence matrix) is initialized. Then, with 100 as the row coordinate and 150 as the column coordinate, query the position (100,150) in the array. If the value of this position is 0 (indicating that there is no record of this pair of pixels appearing), start counting the number of times this pair of pixels appears, and set the value of this position to 1.
[0105] In step S13232, the numerical value of the number of times is used as the filling value of the corresponding target element position in the two-dimensional array to obtain the gray-level co-occurrence matrix of the video frame.
[0106] If the position of the queried target element already has a value (that is, the number of times this pair of pixels has appeared has been counted before), the new count needs to be added to that position. After traversing all the pixels in the video frame and their corresponding target pixels, each position in the two-dimensional array will store a value, indicating the number of times the grayscale value pair of the pixel corresponding to that position appears in the video frame. This two-dimensional array is the grayscale co-occurrence matrix of the video frame.
[0107] For example: Continuing with the above example, suppose that another pair of pixels is found in the subsequent traversal, and their grayscale value pair is also (100, 150). When the position (100, 150) in the array is queried again, it is found that the value of this position is already 1 (indicating that this pair of pixels has been counted once before). Therefore, the number of times counted this time is accumulated to this position, and the value is updated to 2. After traversing the entire video frame, the two-dimensional array obtained is the grayscale co-occurrence matrix of the video frame, where the value of the position (100, 150) is 2, indicating that the pixel with a grayscale value of 100 and the pixel with a grayscale value of 150 appear twice in the video frame.
[0108] In a possible implementation, the specified statistic includes at least one of energy and contrast of a gray level co-occurrence matrix.
[0109] Among them, energy is the sum of the squares of the element values in the gray-level co-occurrence matrix, which reflects the uniformity of the gray-level distribution and the coarseness of the texture of the image. When the values in the gray-level co-occurrence matrix are distributed more evenly, the energy value is small; when some values in the matrix are large (that is, some gray-level pairs appear frequently), the energy value is large. Therefore, the energy value can be used to measure the complexity and uniformity of the image texture.
[0110] Among them, contrast reflects the clarity of the image and the depth of the texture grooves. The greater the contrast, the clearer the visual effect of the image; conversely, the smaller the contrast, the more blurred the visual effect. Contrast is calculated based on the grayscale difference between pixel pairs in the grayscale co-occurrence matrix.
[0111] In a possible implementation, in step S14, based on the initial chaotic encryption key value, taking the data length of each of the block video data as a control parameter, generating a chaotic encryption key value as an encryption key corresponding to the block video data, including:
[0112] In step S141, based on the initial chaotic encryption key value, the data length of each of the block video data is input into the chaotic mapping as a control parameter, and the state of the chaotic mapping is iteratively updated;
[0113] It can be explained that chaotic mapping is a nonlinear dynamic system that is sensitive to initial values and parameters. In chaotic encryption, the iterative state of chaotic mapping is usually used to generate a key sequence. Here, the data length of the block video data is input into the chaotic mapping as a control parameter to control the iterative process of the chaotic mapping. The change of data length will lead to different updates of the chaotic mapping state, thereby generating different key sequences.
[0114] For example: Assume that the chaotic map used is the Logistic map, and its iteration formula is: (x_{n+1}=r\cdot x_n\cdot(1-x_n)), where (r) is the control parameter (usually 3.9999 to ensure chaotic behavior), and (x_n) is the current state. For each block of video data, its data length (for example, in bytes) is used as the fine-tuning value of (r), that is, (r'=r+\text{data length adjustment factor}\cdot\text{data length}). Then, use (r') to iterate the Logistic map and update the state of the chaotic map.
[0115] In step S142, the number of iterations is determined according to the multiple relationship between the data length and the preset standard data length, wherein if the data length is less than the preset standard data length, the minimum number of iterations is used as a default value, and if the data length exceeds a preset threshold, the maximum number of iterations is used as an upper limit;
[0116] In the disclosed embodiment, for each increase in a certain data length (such as 1KB, 1MB, etc.), a certain number of iterations (such as 100 times, 1000 times, etc.) is increased. For example, 100 iterations can be added with each 1KB data length as the preset standard data length. If the data length is less than 1KB, the minimum number of iterations (such as 50 times) is used as the default value. If the data length exceeds a certain threshold (such as 10MB), the maximum number of iterations (such as 10,000 times) is used as the upper limit to avoid excessive computational overhead.
[0117] For example, if the data length of a block of video data is 3.5 KB, the number of iterations is calculated as: (3.5imes 100=350) times.
[0118] In step S143, when the number of iterative updates meets the number of iterations, a key sequence of a preset length is extracted from the state of the chaotic map as a chaotic encryption key value corresponding to the block video data.
[0119] When the number of iterations of the chaotic map meets the number of iterations determined in step S142, a key sequence of a preset length is extracted from the current state of the chaotic map as the chaotic encryption key value corresponding to the block video data. This key sequence will be used to encrypt the block video data.
[0120] For example: Assume that the preset key sequence length is 256 bits (i.e. 32 bytes). After the chaotic map iteration reaches a certain number of times, a 256-bit key sequence is extracted from the current state of the chaotic map (usually a floating point number) by some method (such as binary representation, hash function, etc.). This key sequence is the chaotic encryption key value corresponding to the block video data.
[0121] The present disclosure also provides a device for securely encrypting real-time video data. Figure 2 As shown, including:
[0122] The acquisition module 210 is configured to acquire the real-time video data acquired by the video acquisition device and the timestamp of each frame of the real-time video data;
[0123] The first generating module 220 is configured to use the first timestamp corresponding to the real-time video data of the camera as the initial state parameter of the chaotic mapping encryption algorithm, and generate an initial chaotic encryption key value according to the preset control parameters;
[0124] The block module 230 is configured to block the real-time video data to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data;
[0125] The second generating module 240 is configured to generate a chaotic encryption key value as an encryption key corresponding to the block video data based on the initial chaotic encryption key value and taking the data length of each block video data as a control parameter;
[0126] The preliminary encryption module 250 is configured to perform preliminary encryption processing on each of the block video data based on the chaotic mapping encryption algorithm through the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data;
[0127] The hash encryption module 260 is configured to perform hash encryption on the block data packets according to the timestamp of the preset designated frame in each block video data and the corresponding block data packet, so as to complete the security encryption processing of the real-time video data of the camera.
[0128] In a possible implementation, the block segmentation module 230 is configured as follows:
[0129] Traversing and determining the grayscale value of each pixel in each video frame of the real-time video data and the texture features in each video frame;
[0130] Determine a gray level co-occurrence matrix of the video frame according to the gray value of the pixel point in each video frame and the corresponding texture feature;
[0131] Calculating a specified statistic of the video frame according to the gray level co-occurrence matrix, and comparing the specified statistics of the gray level co-occurrence matrices corresponding to different video frames;
[0132] The video frames whose designated statistics meet preset conditions are divided into the same sub-bureau video data to obtain a plurality of sub-block video data, and the timestamp of the preset designated frame in each of the sub-block video data is obtained.
[0133] In a possible implementation, the block segmentation module 230 is configured as follows:
[0134] Determining a direction parameter and a distance parameter of each video frame according to the texture feature of each video frame, wherein the direction parameter is used to represent a relative direction between pixel pairs in the video frame;
[0135] For each of the pixel points, query the corresponding target pixel point according to the direction parameter and the distance parameter corresponding to the corresponding video frame, and determine the grayscale value of the target pixel point;
[0136] The number of times the pixel points and the corresponding target pixel points appear in each of the video frames is counted, and the results are stored in a two-dimensional array to obtain a grayscale co-occurrence matrix of the video frame, wherein the rows and columns of the grayscale co-occurrence matrix correspond to the value ranges of the grayscale values of the pixel points and the grayscale values of the target pixel points, respectively.
[0137] In a possible implementation, the block segmentation module 230 is configured as follows:
[0138] For each pixel point (x, y), determine the components of the direction parameter in the x direction and the y direction according to the direction parameter corresponding to the corresponding video frame;
[0139] For each pixel point (x, y), query the corresponding target pixel point (x+a, y+b) according to the components of the corresponding direction parameters in the x direction and the y direction, where a and b are distance parameters respectively, and determine the grayscale value g2 of the target pixel point.
[0140] In a possible implementation, the block segmentation module 230 is configured as follows:
[0141] Counting the number of times a pixel point and a corresponding target pixel point appear in each of the video frames, and using the grayscale value of the pixel point as a row coordinate and the grayscale value of the target pixel point as a column coordinate to query the position of the target element in the two-dimensional array;
[0142] In the two-dimensional array, the numerical value of the number of times is used as the filling value of the corresponding target element position to obtain the gray level co-occurrence matrix of the video frame.
[0143] In a possible implementation, the specified statistic includes at least one of energy and contrast of a gray level co-occurrence matrix.
[0144] In a possible implementation, the second generating module 240 is configured to:
[0145] Based on the initial chaotic encryption key value, the data length of each of the block video data is input into the chaotic map as a control parameter, and the state of the chaotic map is iteratively updated;
[0146] Determine the number of iterations according to the multiple relationship between the data length and the preset standard data length, wherein if the data length is less than the preset standard data length, the minimum number of iterations is used as a default value, and if the data length exceeds a preset threshold, the maximum number of iterations is used as an upper limit;
[0147] In the case where the number of iterative updates meets the number of iterations, a key sequence of a preset length is extracted from the state of the chaotic map as a chaotic encryption key value corresponding to the block video data.
[0148] The present disclosure also provides an electronic device, including:
[0149] Microcontroller;
[0150] a memory for storing instructions executable by the microcontroller;
[0151] The microcontroller is configured to execute executable instructions stored in the memory to perform the method described in any one of the aforementioned embodiments.
[0152] The embodiments of the present disclosure further provide a computer-readable storage medium having computer program instructions stored thereon, which implement the steps of the method described in any one of the aforementioned embodiments when the program instructions are executed by a processor.
[0153] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments; within the technical concept of the present disclosure, various changes, modifications, substitutions and variations may be made to these embodiments, and these changes, modifications, substitutions and variations all fall within the protection scope of the present disclosure.
[0154] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any appropriate manner without contradiction, and they should also be regarded as the contents disclosed in this disclosure. In order to avoid unnecessary repetition, this disclosure will not further describe various possible combinations. The technical scope of this application is not limited to the contents in the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A method for securely encrypting real-time video data, characterized in that: The method comprises: Acquire real-time video data captured by a video capture device and a timestamp of each frame of the real-time video data; The timestamp of the first video frame corresponding to the real-time video data of the camera is used as the initial state parameter of the chaotic mapping encryption algorithm, and an initial chaotic encryption key value is generated according to the preset control parameters; The real-time video data is divided into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data; Based on the initial chaotic encryption key value, taking the data length of each of the block video data as a control parameter, generating a chaotic encryption key value as an encryption key corresponding to the block video data; Based on the chaotic mapping encryption algorithm, each of the block video data is preliminarily encrypted by the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data; Hash encryption of the block data packets is performed according to the timestamp of the preset designated frame in each block video data and the corresponding block data packet to complete the secure encryption processing of the real-time camera video data.
2. The method for securely encrypting real-time video data according to claim 1, characterized in that: The step of dividing the real-time video data into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data includes: Traversing and determining the grayscale value of each pixel in each video frame of the real-time video data and the texture features in each video frame; Determine a gray level co-occurrence matrix of the video frame according to the gray value of the pixel point in each video frame and the corresponding texture feature; Calculating a specified statistic of the video frame according to the gray level co-occurrence matrix, and comparing the specified statistics of the gray level co-occurrence matrices corresponding to different video frames; The video frames whose designated statistics meet preset conditions are divided into the same sub-bureau video data to obtain a plurality of sub-block video data, and the timestamp of the preset designated frame in each of the sub-block video data is obtained.
3. The method for securely encrypting real-time video data according to claim 2, characterized in that: Determining the grayscale co-occurrence matrix of the video frame according to the grayscale value of the pixel point in each video frame and the corresponding texture feature includes: Determining a direction parameter and a distance parameter of each video frame according to the texture feature of each video frame, wherein the direction parameter is used to represent a relative direction between pixel pairs in the video frame; For each of the pixel points, query the corresponding target pixel point according to the direction parameter and the distance parameter corresponding to the corresponding video frame, and determine the grayscale value of the target pixel point; The number of times the pixel points and the corresponding target pixel points appear in each of the video frames is counted, and the results are stored in a two-dimensional array to obtain a grayscale co-occurrence matrix of the video frame, wherein the rows and columns of the grayscale co-occurrence matrix correspond to the value ranges of the grayscale values of the pixel points and the grayscale values of the target pixel points, respectively.
4. The method for securely encrypting real-time video data according to claim 3, characterized in that: For each pixel point, querying the corresponding target pixel point according to the direction parameter and the distance parameter corresponding to the corresponding video frame, and determining the grayscale value of the target pixel point includes: For each pixel point (x, y), determine the components of the direction parameter in the x direction and the y direction according to the direction parameter corresponding to the corresponding video frame; For each pixel point (x, y), query the corresponding target pixel point (x+a, y+b) according to the components of the corresponding direction parameters in the x direction and the y direction, where a and b are distance parameters respectively, and determine the grayscale value g2 of the target pixel point.
5. The method for securely encrypting real-time video data according to claim 3, characterized in that: The counting of the number of occurrences of the pixel points and the corresponding target pixel points in each of the video frames, and storing the results in a two-dimensional array to obtain the gray level co-occurrence matrix of the video frame includes: Counting the number of times a pixel point and a corresponding target pixel point appear in each of the video frames, and using the grayscale value of the pixel point as a row coordinate and the grayscale value of the target pixel point as a column coordinate to query the position of the target element in the two-dimensional array; In the two-dimensional array, the numerical value of the number of times is used as the filling value of the corresponding target element position to obtain the gray level co-occurrence matrix of the video frame.
6. The method for securely encrypting real-time video data according to claim 2, characterized in that: The specified statistic includes at least one of energy and contrast of a gray level co-occurrence matrix.
7. The method for securely encrypting real-time video data according to any one of claims 1 to 6, characterized in that: The method of generating a chaotic encryption key value as an encryption key corresponding to the block video data based on the initial chaotic encryption key value and taking the data length of each block video data as a control parameter comprises: Based on the initial chaotic encryption key value, the data length of each of the block video data is input into the chaotic map as a control parameter, and the state of the chaotic map is iteratively updated; Determine the number of iterations according to the multiple relationship between the data length and the preset standard data length, wherein if the data length is less than the preset standard data length, the minimum number of iterations is used as a default value, and if the data length exceeds a preset threshold, the maximum number of iterations is used as an upper limit; In the case where the number of iterative updates meets the number of iterations, a key sequence of a preset length is extracted from the state of the chaotic map as a chaotic encryption key value corresponding to the block video data.
8. A camera real-time video data security encryption processing device, characterized in that: include: An acquisition module is configured to acquire real-time video data acquired by a video acquisition device and acquire a timestamp of each frame of the real-time video data; The first generating module is configured to use the timestamp of the first video frame corresponding to the real-time video data of the camera as the initial state parameter of the chaotic mapping encryption algorithm, and generate an initial chaotic encryption key value according to the preset control parameters; A block division module is configured to divide the real-time video data into blocks to obtain a plurality of block video data and a timestamp of a preset designated frame in each block video data; The second generating module is configured to generate a chaotic encryption key value as an encryption key corresponding to the block video data based on the initial chaotic encryption key value and taking the data length of each block video data as a control parameter; A preliminary encryption module is configured to perform preliminary encryption processing on each of the block video data based on a chaotic mapping encryption algorithm by using the chaotic encryption key value to obtain a block data packet corresponding to each of the block video data; The hash encryption module is configured to perform hash encryption on the block data packets according to the timestamp of the preset designated frame in each block video data and the corresponding block data packets, so as to complete the security encryption processing of the real-time video data of the camera.
9. An electronic device, characterized in that: include: Microcontroller; a memory for storing instructions executable by the microcontroller; The microcontroller is configured to execute executable instructions stored in the memory to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
A multi-level encryption scheme for H.265 / HEVC based on syntax elements scrambling
AU2020100421A4
Method and system for chaotic encryption of video
CN105430432A