A security monitoring video compression transmission method and system

Through the combination technology of two-dimensional symbiosis matrix and Shannon-Vano encoding, the problem of low entropy coding compression efficiency is solved, and more efficient security monitoring video compression transmission is achieved, ensuring the real-time security monitoring.

CN119031137BActive Publication Date: 2025-01-14ANYU HEZHONG TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411510763.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-01-14
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

The existing entropy encoding has limited compression efficiency for security monitoring videos, and cannot break through the frequency limit of the encoded object, resulting in low transmission efficiency of security monitoring videos.

Method used

A two-dimensional symbiosis matrix is ​​used to reflect the occurrence pattern of grayscale values ​​in the sequence to be compressed, and a codeword is assigned to each grayscale value by using Shannon-Vanno encoding. The order of grayscale values ​​is adjusted to shorten the codeword length by constructing the target sequence. , improve compression efficiency.

Benefits of technology

It improves the compression efficiency of security surveillance video, ensures the real-time nature of security surveillance, and is higher than the compression efficiency of entropy encoding, improving transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119031137B_ABST
    Figure CN119031137B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image communication technology, and in particular to a security monitoring video compression transmission method and system. The method comprises: expanding the image frames in the security monitoring video into a sequence to be compressed, constructing a two-dimensional co-occurrence matrix according to the sequence to be compressed, assigning a codeword to each grayscale value, for the K-th grayscale value in the sequence to be compressed, obtaining the grayscale value corresponding to the column where all elements with values ​​of 1 in the corresponding row of the two-dimensional co-occurrence matrix of the K-1-th grayscale value are located, as the distinguishing grayscale value of the K-th grayscale value, using the shortest substring in the codeword of the K-th grayscale value that can distinguish the K-th grayscale value from all distinguishing grayscale values ​​as the encoding result of the K-th grayscale value, and forming the encoding results of all grayscale values ​​in the sequence to be compressed into compressed data for transmission. The present invention has high compression efficiency for image frames, improves the transmission efficiency of security monitoring videos, and ensures the real-time performance of security monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image communication technology, and in particular to a security monitoring video compression transmission method and system. Background Art

[0002] Security surveillance cameras can capture surveillance videos of the surveillance area in real time and transmit the captured surveillance videos to the monitoring platform for security monitoring. Since the real-time surveillance videos contain a large number of image frames, in order to ensure the real-time nature of security monitoring, the image frames of the security surveillance videos need to be compressed and transmitted.

[0003] The patent document with announcement number CN115190311B discloses a security monitoring video compression and storage method, including: obtaining the serial number of each background template image according to the degree of difference between historical security monitoring background images; obtaining each feature point on each background template image according to the pixel value of each pixel point on each background template image; obtaining the background template image corresponding to each security monitoring image to be compressed according to the pixel value of each feature point and the pixel value of the pixel point corresponding to each feature point on each security monitoring image to be compressed; obtaining the target security monitoring image and the security monitoring background image to be compressed according to the binary image of each security monitoring image to be compressed, and storing the serial number of the background template image corresponding to the security monitoring background image to be compressed; compressing and storing each target area of ​​each target security monitoring image according to the pixel value of each pixel point in each target connected domain of each target security monitoring image.

[0004] The above patent documents use Huffman coding to compress and store target areas of target security monitoring images. Huffman coding is entropy coding, and the compression efficiency of entropy coding cannot break through the frequency limit of the coding object. The minimum average coding length is equal to the entropy value of the coding object. The compression efficiency of using entropy coding to compress security monitoring videos is limited. Summary of the invention

[0005] In order to solve the problem that the compression efficiency of entropy coding cannot break through the frequency limitation of the coding object and the compression efficiency of compressing security monitoring video using entropy coding is limited, the present invention provides a security monitoring video compression transmission method and system.

[0006] In a first aspect, the present invention provides a security monitoring video compression transmission method, which adopts the following technical solution:

[0007] A security monitoring video compression transmission method comprises the following steps:

[0008] Expand the image frames in the security monitoring video into a sequence to be compressed; construct a two-dimensional co-occurrence matrix according to the sequence to be compressed, wherein the elements in the two-dimensional co-occurrence matrix are 0 or 1, which is used to indicate whether the grayscale combination consisting of the grayscale value corresponding to the row where the element is located and the grayscale value corresponding to the column where the element is located appears in the sequence to be compressed; assign a codeword to each grayscale value; compress each grayscale value in the sequence to be compressed in turn, including: for the first grayscale value in the sequence to be compressed, Gray value, when When The code word corresponding to the gray value is taken as the The encoding result of the gray value; when When The grayscale values ​​of the columns where all the elements with a value of 1 in the corresponding rows of the two-dimensional co-occurrence matrix are located are respectively used as A gray value difference gray value; starting from the highest bit, compare the The gray value and all the code words that distinguish the gray values ​​are The codeword corresponding to the gray value can distinguish The shortest substring of the gray value and all the different gray values ​​is taken as the The encoding results of all gray values ​​in the sequence to be compressed constitute compressed data for transmission.

[0009] The effect is that the present invention reflects the occurrence law of gray values ​​in the sequence to be compressed through a two-dimensional co-occurrence matrix, and uses the shortest codeword that can distinguish these gray values ​​to encode the gray values ​​that may appear at the same time, thereby shortening the encoding length of each gray value in the sequence to be compressed, and improving the compression efficiency of the image frame in the security monitoring video, so that the compression efficiency is not limited by the frequency of each gray value in the image frame, and the compression efficiency is better than that of entropy coding, thereby improving the transmission efficiency of the security monitoring video and ensuring the real-time nature of security monitoring.

[0010] Preferably, the step of expanding the image frames in the security monitoring video into a sequence to be compressed includes: expanding the grayscale values ​​of all pixels in the image frame into a one-dimensional sequence according to a set scanning order as the sequence to be compressed.

[0011] Preferably, the step of constructing a two-dimensional co-occurrence matrix according to the sequence to be compressed includes: the size of the two-dimensional co-occurrence matrix is , the two-dimensional co-occurrence matrix Line When the element of the column is 1, it means Gray value With Gray value Grayscale combination has appeared in the sequence to be compressed; the two-dimensional co-occurrence matrix Line When the element of the column is 0, it means Gray value With Gray value Grayscale combination has not appeared in the sequence to be compressed, where , , Indicates the number of grayscale values ​​that appear in the sequence to be compressed.

[0012] The effect is that the present invention reflects the regularity of occurrence of gray values ​​in the sequence to be compressed by constructing a two-dimensional co-occurrence matrix, and the compression effect of subsequently compressing the sequence to be compressed according to the regularity of occurrence of gray values ​​is better.

[0013] Preferably, the step of assigning a codeword to each grayscale value comprises: for each grayscale value, converting the grayscale value into a codeword having a length of The binary number is used as the codeword of the gray value, where Indicates the number of types of gray values ​​that appear in the sequence to be compressed, Indicates the round-up symbol.

[0014] Preferably, the assigning of codewords to each grayscale value comprises: counting the frequency of each grayscale value in the sequence to be compressed, and assigning codewords to each grayscale value using Shannon-Fanno coding according to the frequency of each grayscale value.

[0015] The effect is that the present invention uses Shannon-Fanno coding to assign code words to each gray value, so that the code word length of each gray value is different, which has better compression efficiency compared with fixed-length coding.

[0016] Preferably, the use of Shannon-Fanno coding to assign codewords to each grayscale value includes: arranging the grayscale values ​​in order of frequency from large to small, and assigning codewords to each grayscale value using Shannon-Fanno coding according to the frequency of each grayscale value in the order of the arranged grayscale values.

[0017] Preferably, the method of using Shannon-Fanno coding to assign codewords to each grayscale value includes: S1: constructing an empty target sequence; S2: adding the grayscale value with the largest frequency to the target sequence; S3: taking the grayscale values ​​corresponding to the columns where all elements with values ​​of 1 in each row of the two-dimensional co-occurrence matrix are located as parallel grayscale values; S4: recording the number of grayscale values ​​already in the target sequence as According to the parallel gray values, each gray value among all gray values ​​not added to the target sequence is determined as the first The grayscale value with the largest preference is added to the end of the target sequence; S5: repeat S4 until all grayscale values ​​have been added to the target sequence and then stop the iteration; S6: according to the order of grayscale values ​​in the target sequence and the frequency of each grayscale value in the sequence to be compressed, use Shannon-Fanno coding to assign a codeword to each grayscale value.

[0018] The effect is that the two-dimensional co-occurrence matrix reflects the occurrence law of gray values ​​in the sequence to be compressed. The present invention determines the order of adding gray values ​​into the target sequence according to the occurrence law of gray values ​​in the sequence to be compressed, and uses Shannon-Fanno coding to allocate code words to each gray value according to the order of gray values ​​in the target sequence, thereby shortening the length of the shortest code word that can distinguish parallel gray values, thereby improving compression efficiency.

[0019] Preferably, the preference satisfies the expression: ;in, Indicates the gray value of all gray values ​​not added to the target sequence The gray value is taken as the The preference of the gray value added to the target sequence; Indicates The gray value added to the target sequence, Indicates the gray value of all gray values ​​not added to the target sequence Gray value; Indicates the sequence number of the gray value added to the target sequence in the target sequence; Indicates the number of gray values ​​that have been added to the target sequence; Represents the gray value Gray value Function, when the gray value Gray value When is a parallel gray value, , when the gray value Gray value When it is not a parallel gray value, .

[0020] The effect is that the present invention determines the order of adding grayscale values ​​to the target sequence by judging whether the grayscale values ​​added to the target sequence and the grayscale values ​​to be added to the target sequence are parallel grayscale values, so that the parallel grayscale values ​​are as far as possible in the target sequence. After the Shannon-Fanno coding is used to assign codewords to each grayscale value according to the order of the grayscale values ​​in the target sequence, the shorter the common length between the codewords of the parallel grayscale values, the shorter the shortest codeword that can distinguish the parallel grayscale values. The shortest codeword is used for encoding, which further shortens the encoding length of each grayscale value in the sequence to be compressed and improves the compression efficiency.

[0021] Preferably, forming compressed data from the encoding results of all grayscale values ​​in the sequence to be compressed includes: splicing the encoding results of all grayscale values ​​in the sequence to be compressed together in order to obtain compressed data of the sequence to be compressed.

[0022] In a second aspect, the present invention provides a security monitoring video compression transmission system, which adopts the following technical solution:

[0023] A security monitoring video compression transmission system comprises: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned security monitoring video compression transmission method is implemented.

[0024] By adopting the above technical solution, the above-mentioned security monitoring video compression and transmission method is generated into a computer program and stored in a memory so as to be loaded and executed by a processor, thereby making a terminal device based on the memory and the processor for easy use.

[0025] The present invention has the following technical effects: the present invention uses the shortest codeword that can distinguish grayscale values ​​that may appear simultaneously for encoding, shortens the encoding length of the grayscale value, makes the compression efficiency of the image frame not limited by the frequency of the grayscale value, has higher compression efficiency than entropy coding, improves the transmission efficiency of security monitoring video, and ensures the real-time nature of security monitoring. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts.

[0027] Figure 1 It is a flow chart of a security monitoring video compression transmission method according to an embodiment of the present invention;

[0028] Figure 2 It is a schematic diagram of the two-dimensional co-occurrence matrix;

[0029] Figure 3 is the code word corresponding to each gray value in the first embodiment of the present invention;

[0030] Figure 4 is a schematic diagram of assigning code words to each gray value in the second embodiment of the present invention;

[0031] Figure 5 is the code word corresponding to each gray value in the second embodiment of the present invention;

[0032] Figure 6 is a schematic diagram of assigning code words to each gray value in Embodiment 3 of the present invention;

[0033] Figure 7 It is the code word corresponding to each gray value in the third embodiment of the present invention. DETAILED DESCRIPTION

[0034] 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 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0035] It should be understood that when the terms "first", "second", etc. are used in the claims, descriptions, and drawings of the present invention, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the description and claims of the present invention indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections.

[0036] The embodiment of the present invention discloses a security monitoring video compression transmission method, referring to Figure 1 , including steps S001 to S005:

[0037] S001: Expand image frames in the security monitoring video into a sequence to be compressed.

[0038] It should be noted that a video is composed of image groups, each of which contains a key frame (Intra-coded Frame, I frame) and multiple predicted frames (Predicted Frame, P frame). An I frame is a complete image frame, and a P frame stores the change in the image compared with the previous frame, which is a compressed image frame. In the present invention, I frames and P frames are collectively referred to as image frames, and the same method is used to compress I frames and P frames.

[0039] For the image frame to be transmitted in the security monitoring video, the grayscale values ​​of all pixels in the image frame are expanded into a one-dimensional sequence as the sequence to be compressed. It should be noted that in this embodiment, the order of Zigzag scanning is adopted to expand the grayscale values ​​of all pixels in the image frame into a one-dimensional sequence. In other embodiments, the implementer can choose the order of expanding the grayscale values ​​of all pixels in the image frame into a one-dimensional sequence according to the actual implementation situation, such as S-type scanning, Hilbert scanning, etc.

[0040] At this point, the sequence to be compressed is obtained.

[0041] S002: Construct a two-dimensional co-occurrence matrix according to the sequence to be compressed.

[0042] Specifically, obtain the number of types of gray values ​​that appear in the sequence to be compressed . Count whether the grayscale combination composed of any two grayscale values ​​appears in the sequence to be compressed, and construct The value of the element in the two-dimensional co-occurrence matrix is ​​0 or 1, which is used to indicate whether the corresponding grayscale combination appears in the sequence to be compressed. For example, the two-dimensional co-occurrence matrix Line When the element of the column is 1, it means Gray value With Gray value Grayscale combination has appeared in the sequence to be compressed; the two-dimensional co-occurrence matrix Line When the element of the column is 0, it means Gray value With Gray value Grayscale combination has not appeared in the sequence to be compressed, where , .

[0043] For example, when the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the corresponding two-dimensional co-occurrence matrix can be found in Figure 2 .

[0044] So far, the two-dimensional co-occurrence matrix of the sequence to be compressed is obtained. The two-dimensional co-occurrence matrix can reflect the occurrence regularity of gray values ​​in the sequence to be compressed.

[0045] S003: Assign a codeword to each gray value.

[0046] Embodiment 1: For each gray value, the gray value is converted into a length of The binary number is used as the codeword of the gray value, where Indicates the number of types of gray values ​​that appear in the sequence to be compressed, For example, when the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the codeword corresponding to the gray value is Figure 3 .

[0047] It should be noted that Shannon-Fano coding is a technology that constructs prefix codes based on a set of source symbol sets and the frequencies of their occurrence. Shannon-Fano coding sorts the source symbols from the highest frequency to the lowest frequency, and divides the arranged source symbols into two large groups, so that the sum of the probabilities of the two groups is almost the same, and each is assigned a binary code symbol "0" and "1". By continuously differentiating each group until only one source symbol is left in each group, the binary code symbols of all groups to which the source symbol belongs are concatenated to obtain the codeword of the source symbol. Shannon-Fano coding can realize variable-length coding of source symbols through the above method, and has better compression efficiency than fixed-length coding. Therefore, in the second embodiment of the present invention, Shannon-Fano coding is used to assign codewords to each grayscale value.

[0048] Embodiment 2: Count the frequency of each grayscale value in the sequence to be compressed, arrange the grayscale values ​​in descending order of frequency, and assign a codeword to each grayscale value according to the frequency of each grayscale value using Shannon-Fanno coding in the order of the arranged grayscale values. For example, when the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the schematic diagram of assigning a codeword to each grayscale value is shown in Figure 4 , the codeword corresponding to each gray value can be found in Figure 5 .

[0049] It should be noted that in the traditional Shannon-Fano coding, when assigning code words to each gray value, each gray value is arranged in order of frequency from large to small. In the final result, the length of the common code words of the adjacent gray values ​​in the sorting is longer. The purpose of the present invention is to encode the gray values ​​that may appear at the same time using the shortest code words that can distinguish these gray values, so as to improve the compression efficiency. If the length of the common code words of these gray values ​​is longer, the length of the shortest code words that can distinguish these gray values ​​is longer, and the compression effect is worse at this time. Therefore, in the third embodiment of the present invention, when assigning code words to each gray value, the order of gray value arrangement is adjusted according to the two-dimensional co-occurrence matrix, so that the common code words of different gray values ​​appearing after the same gray value are as short as possible, so that the gray values ​​can be distinguished using the shortest possible code words to improve the compression efficiency.

[0050] In the third embodiment, the method for assigning code words to each gray value is as follows:

[0051] 1. Construct an empty target sequence.

[0052] 2. Count the frequency of each grayscale value in the sequence to be compressed, and add the grayscale value with the largest frequency to the target sequence.

[0053] 3. For each row in the two-dimensional co-occurrence matrix, if the number of elements with a value of 1 in the row is not less than 2, obtain the grayscale values ​​corresponding to the columns where all elements with a value of 1 in the row are located, and use these grayscale values ​​as parallel grayscale values. For example, Figure 2 In the two-dimensional co-occurrence matrix shown, the elements in the 1st, 2nd, 4th, and 9th columns in the 3rd row are 1, so the grayscale values ​​1, 2, 4, and 9 corresponding to the 1st, 2nd, 4th, and 9th columns are parallel grayscale values ​​in pairs.

[0054] 4. Record the number of grayscale values ​​in the target sequence as According to the parallel gray values ​​of each gray value in the target sequence, each gray value of all gray values ​​not added to the target sequence is obtained as the first The preference of the gray value added to the target sequence:

[0055] ;

[0056] in, Indicates the gray value of all gray values ​​not added to the target sequence The gray value is taken as the The preference of the gray value added to the target sequence; Indicates The gray value added to the target sequence, Indicates the gray value of all gray values ​​not added to the target sequence Gray value; Indicates the sequence number of the gray value added to the target sequence in the target sequence; Indicates the number of gray values ​​that have been added to the target sequence; Represents the gray value Gray value Function, when the gray value Gray value When is a parallel gray value, , when the gray value Gray value When it is not a parallel gray value, .

[0057] It should be noted that the first OK( ), all grayscale values ​​corresponding to the column where the element with value 1 is located are usually in the first The grayscale value corresponding to the row appears after that, for example, If the elements in the 1st, 2nd, 4th, and 9th columns of the row are 1, then After the grayscale value corresponding to the row appears in the sequence to be compressed, the next grayscale value that appears may be the grayscale value corresponding to the first column of the two-dimensional co-occurrence matrix, or it may be the grayscale value corresponding to the second, fourth, and ninth columns of the two-dimensional co-occurrence matrix. The grayscale values ​​corresponding to the first, second, fourth, and ninth columns of the two-dimensional co-occurrence matrix are parallel grayscale values. In order to distinguish parallel grayscale values, it is necessary to use the shortest codeword that can distinguish parallel grayscale values ​​for encoding. In Shannon-Fano coding, if the distance between two grayscale values ​​is closer after sorting, the length of the common codeword between the two grayscale values ​​is longer; if the distance between the two grayscale values ​​is farther after sorting, the length of the common codeword between the two grayscale values ​​is shorter. Therefore, this embodiment obtains each grayscale value among all grayscale values ​​that have not been added to the target sequence as the first grayscale value by judging whether the grayscale value that has been added to the target sequence and the grayscale value to be added to the target sequence are parallel grayscale values. The priority of the grayscale values ​​to be added to the target sequence is determined, thereby determining the order of adding the grayscale values ​​to be added to the target sequence, so that the parallel grayscale values ​​are as far apart as possible in the target sequence. After assigning a codeword to each grayscale value through Shannon-Fanno coding, the length of the common codeword between the parallel grayscale values ​​is as short as possible. In the subsequent encoding, the parallel grayscale values ​​can be distinguished by the shortest possible codeword, thereby improving the compression efficiency.

[0058] The grayscale value with the highest preference among all grayscale values ​​not added to the target sequence is taken as the first selected grayscale value. When there is only one first selected grayscale value, the first selected grayscale value is added to the end of the target sequence. When there are multiple first selected grayscale values, the first selected grayscale value with the largest frequency is taken as the second selected grayscale value. When there is only one second selected grayscale value, the second selected grayscale value is added to the end of the target sequence. When there are multiple second selected grayscale values, the second selected grayscale value with the smallest grayscale value is added to the end of the target sequence.

[0059] 5. Repeat step 4 until all grayscale values ​​have been added to the target sequence and stop the iteration.

[0060] For example, the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, and the two-dimensional co-occurrence matrix is Figure 2 As shown, the frequencies of gray values ​​1, 2, 3, 4, 5, 6, 7, 8, and 9 are , , , , , , , , , where grayscale value 4 is the grayscale value with the highest frequency, then grayscale value 4 is added to the target sequence, and the target sequence is {4}. The element in the third row, first column, and fourth column of the two-dimensional co-occurrence matrix is ​​1, so grayscale value 1 and grayscale value 4 are parallel grayscale values, and the preference of grayscale value 1 as the second grayscale value added to the target sequence is: , the elements in the 3rd row, 2nd column, and 4th column of the two-dimensional co-occurrence matrix are 1, so the gray value 2 and the gray value 4 are parallel gray values, and the preference of gray value 2 as the second gray value added to the target sequence is: Similarly, the grayscale values ​​3, 5, 6, 7, 8, and 9 are preferred as the second grayscale values ​​added to the target sequence: 0, 1, 1, 1, 0, 0, respectively. Among them, the grayscale values ​​5, 6, and 7 are preferred as the second grayscale values ​​added to the target sequence and are equal to each other. Then, the grayscale value 7 with the largest frequency is added to the end of the target sequence, and the target sequence is updated to {4, 7}; the grayscale value 1 is preferred as the third grayscale value added to the target sequence: Similarly, the grayscale values ​​2, 3, 5, 6, 8, and 9 are preferred as the third grayscale value added to the target sequence: , , 1, 1, 0, 0, among which the grayscale values ​​5 and 6 are the third grayscale values ​​added to the target sequence with the largest preference and are equal to each other, and the frequencies of the grayscale values ​​5 and 6 are also equal, then the smallest grayscale value 5 is added to the end of the target sequence, and the target sequence is updated to {4, 7, 5}; and so on, the final target sequence is {4, 7, 5, 6, 3, 1, 8, 2, 9}.

[0061] 6. According to the order of gray values ​​in the target sequence, use Shannon-Fanno coding to assign code words to each gray value according to the frequency of each gray value in the sequence to be compressed. For a schematic diagram of assigning code words to each gray value according to the target sequence {4,7,5,6,3,1,8,2,9}, see Figure 6 , the codeword corresponding to each gray value can be found in Figure 7 .

[0062] In other embodiments, implementers may also use other encoding methods to assign code words to each grayscale value, such as Huffman encoding.

[0063] At this point, the codeword allocation of grayscale values ​​is achieved.

[0064] S004: compress the sequence to be compressed according to the two-dimensional co-occurrence matrix and the codeword corresponding to each gray value to obtain compressed data.

[0065] Compress each grayscale value in the compression sequence in turn:

[0066] For the first Gray value, when When The code word corresponding to the gray value is taken as the The encoding result of gray value;

[0067] when When The grayscale values ​​of the corresponding rows of the two-dimensional co-occurrence matrix and the grayscale values ​​of the columns where the elements with a value of 1 are located are respectively used as For any distinguishing gray value, the code word of the distinguishing gray value is the same as the first The gray value codewords are compared from the highest bit, and the consecutive identical bits in the two codewords are taken as the The common codeword of the gray value and the distinguishing gray value, for example, the first two bits of codeword 10110 and codeword 1001 are consecutively the same, then the common codeword is 10, and the length of the common codeword is 2. For example, the highest bit of codeword 10110 and codeword 001 are different, then these two codewords have no consecutive identical bits, then the common codeword is empty, and the length of the common codeword is 0. The length of the longest common codeword among the common codewords of the gray value and all the different gray values ​​is recorded as , then The gray value codeword bits and the first bits are different, then The gray value codeword bits can distinguish gray value and all the difference gray values, so the The gray value codeword bits as the first The encoding result of the gray value.

[0068] The encoding results of all grayscale values ​​in the sequence to be compressed are concatenated together in order to obtain the compressed data of the sequence to be compressed.

[0069] For example, when the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the two-dimensional co-occurrence matrix is Figure 2 , the code words for each gray value refer to Figure 3When the method of the present invention is used to compress the sequence to be compressed, the process is as follows: for the first gray value 4 in the sequence to be compressed, the code word 0100 corresponding to 4 is used as the encoding result of 4; for the second gray value 4 in the sequence to be compressed, the gray values ​​corresponding to the column where the element with the value 1 in the corresponding row (i.e., the 4th row) of the previous gray value 4 is located are 3 and 4, then the gray value 3 is the difference gray value of the second gray value 4, the code word of 3 is 0011, the code word of 4 is 0100, and the common code word length of the two is 1, then the first gray value in the code word of 4 is 0011. The bit position 01 is used as the encoding result of the second grayscale value 4; similarly, the encoding results corresponding to the third and fourth grayscale values ​​4 and 3 in the sequence to be compressed are 01 and 00 respectively; for the fifth grayscale value 4 in the sequence to be compressed, the grayscale values ​​corresponding to the column where the element with the value of 1 in the corresponding row (i.e. the third row) of the two-dimensional co-occurrence matrix of the previous grayscale value 3 is located are 1, 2, 4, and 9, then the grayscale values ​​1, 2, and 9 are the different grayscale values ​​of the fifth grayscale value 4, and the codewords of 1, 2, 4, and 9 are 0001, 0010, 0100, and 1001 respectively, the common codeword length between 1 and 4 is 1, the common codeword length between 2 and 4 is 1, and the common codeword length between 9 and 4 is 0, then the first grayscale value in the codeword of 4 is replaced by 0 The bit position 01 is used as the encoding result of the fifth gray value 4; and so on, the compressed data finally obtained is 010001010001001100011001000000100100000001110000, and the length of the compressed data is 48. Figure 3 The codeword of each gray value in is used to encode the sequence to be compressed, and the result is 010001000100001101000011100110001001100101110100001100100100010000110001010101111000100110000110, and the length is 96. It can be seen that the method in the present invention has a high compression efficiency.

[0070] When the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the two-dimensional co-occurrence matrix can be found in Figure 2 , the code words for each gray value refer to Figure 5When the method of the present invention is used to compress the sequence to be compressed, the process is as follows: for the first gray value 4 in the sequence to be compressed, the code word 00 corresponding to 4 is used as the encoding result of 4; for the second gray value 4 in the sequence to be compressed, the gray values ​​corresponding to the column where the element with the value 1 in the corresponding row (i.e., the 4th row) of the previous gray value 4 is located are 3 and 4, then the gray value 3 is the difference gray value of the second gray value 4, the code word of 3 is 01, the code word of 4 is 00, and the common code word length of the two is 1, then the previous gray value 4 in the code word is 01. The bit position 00 is used as the encoding result of the second grayscale value 4; similarly, the encoding results corresponding to the third and fourth grayscale values ​​4 and 3 in the sequence to be compressed are 00 and 01 respectively; for the fifth grayscale value 4 in the sequence to be compressed, the grayscale values ​​corresponding to the column where the element with the value of 1 in the corresponding row (i.e. the third row) of the two-dimensional co-occurrence matrix of the previous grayscale value 3 is located are 1, 2, 4, and 9, then the grayscale values ​​1, 2, and 9 are the distinguishing grayscale values ​​of the fifth grayscale value 4, and the codewords of 1, 2, 4, and 9 are 1101, 1110, 00, and 100 respectively, the common codeword length between 1 and 4 is 0, the common codeword length between 2 and 4 is 0, and the common codeword length between 9 and 4 is 0, then the first grayscale value in the codeword of 4 is replaced by 0. The bit position 0 is used as the encoding result of the fifth gray value 4; and so on, the final compressed data is 00000001001101011010011001111000011101111010111, and the length of the compressed data is 47. If the method in the present invention is not used, directly according to Figure 5 The codeword of each gray value in is used to encode the sequence to be compressed, and the result is 000000010001100101100100110000011110000001110111110110010110010111111, and the length is 69. It can be seen that the method in the present invention has higher compression efficiency than the existing Shannon-Fanno coding.

[0071] Similarly, when the sequence to be compressed is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}, the two-dimensional co-occurrence matrix is Figure 2 , the code words for each gray value refer to Figure 7 When the method of the present invention is used, the compressed data finally obtained is 00001011111011100111000110001110, and the length of the compressed data is 33. If the method of the present invention is not used, directly according to Figure 7The codeword of each gray value in is used to encode the sequence to be compressed, and the result is 00000010000100111101111111101000100110000010010100110010101111110110111, and the length is 71. It can be seen that the method of the present invention has higher compression efficiency than the existing Shannon-Fanno coding, and the codeword of each gray value obtained in Example 3 of the present invention is used to encode the sequence to be compressed, and the compression efficiency is higher than that of the codeword of each gray value obtained in Example 1 and Example 2 of the present invention.

[0072] At this point, the compression of the sequence to be compressed is achieved.

[0073] S005: Send the compressed data to the monitoring platform so that the monitoring platform can decompress the compressed data and restore the image frame.

[0074] The compressed data is transmitted to the monitoring platform. To ensure decodability, the two-dimensional co-occurrence matrix and the codewords of each gray value are transmitted to the monitoring platform as supplementary data. It should be noted that the implementer can further compress the two-dimensional co-occurrence matrix using run-length coding before transmission, which can further improve the transmission efficiency.

[0075] The monitoring platform decodes the compressed data. Specifically:

[0076] Starting from the first bit in the compressed data, read the bits in the compressed data in order from left to right. When there is a codeword with a gray value that is the same as the read content, stop reading and use the gray value as the first decoding result. Get the gray value corresponding to the column where the element with a value of 1 in the corresponding row of the two-dimensional co-occurrence matrix of the first decoding result is located as the first candidate gray value. Re-read the bits in the compressed data starting from the first unread bit in the compressed data in order from left to right. When the read content is only the same as the first one of all the first candidate gray values, bits are the same, the first candidate grayscale value is used as the second decoding result, where Indicates the number of bits currently read. Get the gray value corresponding to the column where the element with a value of 1 in the corresponding row of the two-dimensional co-occurrence matrix of the second decoding result is located as the second candidate gray value. Reread the bits in the compressed data from the first unread bit in the compressed data from left to right. When the read content only matches the first bit of one of all the second candidate gray values, bits are the same, the second candidate grayscale value is used as the third decoding result, where Indicates the number of bits currently read. And so on, the iteration stops when all bits in the compressed data have been read, and all decoding results constitute the decompression sequence of the compressed data. Fill each element in the decompression sequence into an empty matrix of the same size as each frame of the video in the order of Zigzag scanning to obtain the currently transmitted image frame.

[0077] For example, when the compressed data is 000010111110111001110001100011100, the two-dimensional co-occurrence matrix is ​​as follows Figure 2 As shown, the codewords for each character are as follows Figure 7 As shown, the process of decoding the compressed data is as follows: starting from the first bit in the compressed data, read the bits in the compressed data from left to right. When 00 is read, the code word of the gray value 4 is the same as 00, so the first decoding result is 4; obtain the gray values ​​3 and 4 corresponding to the column where the element with a value of 1 in the corresponding row of the two-dimensional co-occurrence matrix of the first decoding result 4 is located as the first candidate gray value. The code words of 3 and 4 are 100 and 00 respectively. Reread from the third bit of the compressed data. When 0 is read, the first bit of the first candidate gray value 4 is 0, and the first bit of the first candidate gray value 3 is not 0, so the second decoding result is is 4; get the second decoding result 4, and the grayscale values ​​corresponding to the column where the element with value 1 in the corresponding row of the two-dimensional co-occurrence matrix are 3 and 4. As the second candidate grayscale values, the codewords of 3 and 4 are 100 and 00 respectively. Reread from the 4th bit of the compressed data. When 0 is read, the first bit of the second candidate grayscale value 4 is 0, and the first bit of the second candidate grayscale value 3 is not 0, then the third decoding result is 4; and so on, all the decoding results can be obtained, and the final decompression sequence is {4,4,4,3,4,3,9,8,9,9,7,4,3,2,4,4,3,1,5,7,8,9,8,6}.

[0078] The embodiment of the present invention further discloses a security monitoring video compression transmission system, including a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a security monitoring video compression transmission method according to the present invention is implemented.

[0079] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their configuration and functions are known in the art, so they will not be described in detail here.

[0080] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.

[0081] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A security monitoring video compression transmission method, characterized in that: include: Expand the image frames in the security monitoring video into a sequence to be compressed; Construct a two-dimensional co-occurrence matrix according to the sequence to be compressed, wherein the elements in the two-dimensional co-occurrence matrix are 0 or 1, which is used to indicate whether the grayscale combination formed by the grayscale value corresponding to the row where the element is located and the grayscale value corresponding to the column where the element is located appears in the sequence to be compressed; assign a codeword to each grayscale value; Compress each grayscale value in the sequence to be compressed in turn, including: Gray value, when When The code word corresponding to the gray value is taken as the The encoding result of the gray value; when When The grayscale values ​​of the columns where all the elements with a value of 1 in the corresponding rows of the two-dimensional co-occurrence matrix are located are respectively used as A difference gray value of gray values; starting from the highest bit, compare the The gray value and all the code words that distinguish the gray values ​​are The codeword corresponding to the gray value can distinguish The shortest substring of the gray value and all the different gray values ​​is taken as the The encoding result of gray value; The encoding results of all grayscale values ​​in the sequence to be compressed constitute compressed data for transmission.

2. A security monitoring video compression transmission method according to claim 1, characterized in that: The step of expanding the image frames in the security monitoring video into a sequence to be compressed includes: The grayscale values ​​of all pixels in the image frame are expanded into a one-dimensional sequence according to the set scanning order as the sequence to be compressed.

3. A security monitoring video compression transmission method according to claim 1, characterized in that: The step of constructing a two-dimensional co-occurrence matrix according to the sequence to be compressed includes: The size of the two-dimensional co-occurrence matrix is , the two-dimensional co-occurrence matrix Line When the element of the column is 1, it means Gray value With Gray value Grayscale combination has appeared in the sequence to be compressed; the two-dimensional co-occurrence matrix Line When the element of the column is 0, it means Gray value With Gray value Grayscale combination has not appeared in the sequence to be compressed, where , , Indicates the number of grayscale values ​​that appear in the sequence to be compressed.

4. The security monitoring video compression transmission method according to claim 1, characterized in that: The allocating a codeword for each grayscale value comprises: For each grayscale value, convert the grayscale value to a length of The binary number is used as the codeword of the gray value, where Indicates the number of types of gray values ​​that appear in the sequence to be compressed, Indicates the round-up symbol.

5. The security monitoring video compression transmission method according to claim 1, characterized in that: The allocating a codeword for each grayscale value comprises: The frequency of each grayscale value in the sequence to be compressed is counted, and a codeword is assigned to each grayscale value according to the frequency of each grayscale value using Shannon-Fanno coding.

6. A security monitoring video compression transmission method according to claim 5, characterized in that: The method of using Shannon-Fanno coding to assign a codeword to each grayscale value includes: The grayscale values ​​are arranged in order from large to small in frequency, and a code word is assigned to each grayscale value according to the frequency of each grayscale value by using Shannon-Fanno coding in the order of the arranged grayscale values.

7. A security monitoring video compression transmission method according to claim 5, characterized in that: The method of using Shannon-Fanno coding to assign a codeword to each grayscale value includes: S1: Construct an empty target sequence; S2: Add the gray value with the highest frequency to the target sequence; S3: Take the gray values ​​corresponding to the columns of all elements with a value of 1 in each row of the two-dimensional co-occurrence matrix as parallel gray values; S4: Record the number of gray values ​​in the target sequence as According to the parallel gray values, each gray value among all gray values ​​not added to the target sequence is determined as the first The grayscale value with the largest preference is added to the end of the target sequence; S5: repeat S4 until all grayscale values ​​have been added to the target sequence and then stop the iteration; S6: according to the order of grayscale values ​​in the target sequence and the frequency of each grayscale value in the sequence to be compressed, use Shannon-Fanno coding to assign a codeword to each grayscale value.

8. A security monitoring video compression transmission method according to claim 7, characterized in that: The preference satisfies the expression: ; in, Indicates the gray value of all gray values ​​not added to the target sequence The gray value is taken as the The preference of the gray value added to the target sequence; Indicates The gray value added to the target sequence, Indicates the gray value of all gray values ​​not added to the target sequence Gray value; Indicates the sequence number of the gray value added to the target sequence in the target sequence; Indicates the number of gray values ​​that have been added to the target sequence; Represents the gray value Gray value Function, when the gray value Gray value When is a parallel gray value, , when the gray value Gray value When it is not a parallel gray value, .

9. The security monitoring video compression transmission method according to claim 1, characterized in that: The encoding results of all gray values ​​in the sequence to be compressed form compressed data, including: The encoding results of all grayscale values ​​in the sequence to be compressed are concatenated together in order to obtain the compressed data of the sequence to be compressed.

10. A security monitoring video compression transmission system, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a security monitoring video compression and transmission method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • A method for compressing and storing security surveillance videos

    CN115190311B

  • Concrete product quality detection method based on intelligent monitoring platform

    CN115082443A

  • Organ-like culture image compression method

    CN117437310A