CN115955569B - Monitoring video data transmission method for animal epidemic prevention quarantine center - Google Patents

Monitoring video data transmission method for animal epidemic prevention quarantine center Download PDF

Info

Publication number
CN115955569B
CN115955569B CN202310237684.6A CN202310237684A CN115955569B CN 115955569 B CN115955569 B CN 115955569B CN 202310237684 A CN202310237684 A CN 202310237684A CN 115955569 B CN115955569 B CN 115955569B
Authority
CN
China
Prior art keywords
sequence
pixel value
encoded
pixel
run length
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310237684.6A
Other languages
Chinese (zh)
Other versions
CN115955569A (en
Inventor
刘顺猛
师青柏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Helen Animal Epidemic Prevention And Quarantine Center
Original Assignee
Helen Animal Epidemic Prevention And Quarantine Center
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Helen Animal Epidemic Prevention And Quarantine Center filed Critical Helen Animal Epidemic Prevention And Quarantine Center
Priority to CN202310237684.6A priority Critical patent/CN115955569B/en
Publication of CN115955569A publication Critical patent/CN115955569A/en
Application granted granted Critical
Publication of CN115955569B publication Critical patent/CN115955569B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A40/00Adaptation technologies in agriculture, forestry, livestock or agroalimentary production
    • Y02A40/70Adaptation technologies in agriculture, forestry, livestock or agroalimentary production in livestock or poultry

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The invention relates to the technical field of video coding compression, in particular to a monitoring video data transmission method for an animal epidemic prevention quarantine center, which comprises the following steps: acquiring a first pixel value sequence and a second run length sequence according to a key frame in a monitoring video of an animal epidemic prevention quarantine center; updating the first pixel value sequence and the second run length sequence to further obtain a suffix code of the run length and a suffix code of the pixel value; and obtaining a sequence to be encoded, encoding one or more elements in the sequence to be encoded according to the suffix encoding of the run length and the suffix encoding of the pixel value, obtaining a code word of the element to be encoded or the pixel string to be encoded, obtaining a compressed frame according to the code word, and transmitting the compressed frame. The method has high compression efficiency, and ensures that the monitoring video data of the animal epidemic prevention quarantine center can be rapidly transmitted.

Description

Monitoring video data transmission method for animal epidemic prevention quarantine center
Technical Field
The invention relates to the technical field of video coding compression, in particular to a monitoring video data transmission method for an animal epidemic prevention quarantine center.
Background
The animal epidemic prevention and quarantine center bears related works such as national animal epidemic analysis and treatment, serious animal epidemic prevention and control, and livestock and poultry product scrambling safety detection, and in order to ensure the traceability of the work of the animal epidemic prevention and quarantine center, the monitoring video of each unit of the animal epidemic prevention and quarantine center needs to be transmitted to a special server for storage.
The existing video compression algorithm divides the video into key frames and predictive coding frames according to the inter-frame redundancy characteristics to realize the compression of the video. Since the key frame is a complete image, the key frame can be compressed alone to achieve further compression of the video. Local pixel points in the key frame have similarity, so the run of pixel values in the key frame is longer.
The existing compression method is that different suffix codes are allocated to different characters in data, and the existing segment numbers and the suffix codes of the characters in the coding dictionary are combined into a codeword of one character or a plurality of characters in the data by means of constructing the coding dictionary while encoding, so that the data is compressed. LZ coding is not suitable for coding strings with long runs, and codes strings with long runs into multiple codewords. Compression of key frames using LZ coding is therefore inefficient.
Disclosure of Invention
The invention provides a monitoring video data transmission method for an animal epidemic prevention quarantine center, which aims to solve the existing problems.
The invention discloses a monitoring video data transmission method for an animal epidemic prevention quarantine center, which adopts the following technical scheme:
the embodiment of the invention provides a monitoring video data transmission method for an animal epidemic prevention quarantine center, which comprises the following steps:
acquiring a first pixel value sequence and a second run length sequence according to a key frame in a monitoring video of an animal epidemic prevention quarantine center; updating the first pixel value sequence and the second run-length sequence according to the first pixel value sequence and the second run-length sequence; acquiring suffix codes of each run length and suffix codes of each pixel value according to the first pixel value sequence and the second run length sequence; acquiring a single pixel value and a pixel group in a first pixel value sequence according to a first run length sequence to form a sequence to be coded;
constructing an empty coding dictionary; taking a first element in a sequence to be encoded as an element to be encoded, and performing encoding operation according to the element to be encoded, wherein the method comprises the following steps:
s1: when the element to be encoded does not exist in the encoding dictionary, acquiring a codeword of the element to be encoded according to the pixel value and the suffix encoding of the run length; adding the element to be encoded and the code word of the element to be encoded into an encoding dictionary; taking the next element of the element to be coded in the sequence to be coded as a new element to be coded;
S2: when the element to be encoded exists in the encoding dictionary, taking the element to be encoded as a prefix; the judging operation of the next element of the prefix in the sequence to be coded comprises the following steps:
s201: when the next element of the prefix in the sequence to be coded is a pixel group, acquiring a codeword of the prefix; adding the prefix and the codeword of the prefix into a coding dictionary; the next element of the prefix in the sequence to be coded is used as a new element to be coded;
s202: when the next element of the prefix in the sequence to be encoded is a single pixel value, the next element of the prefix in the sequence to be encoded is used as a suffix, and a pixel string formed by splicing the prefix and the suffix is used as a pixel string to be encoded; judging the pixel string to be encoded to obtain a new element to be encoded;
s3: repeating the encoding operation according to the new elements to be encoded until all elements in the sequence to be encoded have traversed and iteration is stopped;
taking a sequence formed by binary strings corresponding to all codewords in the coding dictionary as a compressed frame; the compressed frame is transmitted.
Preferably, the step of obtaining the first pixel value sequence and the second run length sequence according to the key frame in the monitoring video of the animal epidemic prevention quarantine center includes the following specific steps:
Acquiring a key frame in a monitoring video of an animal epidemic prevention quarantine center, and forming a first pixel value sequence by pixel values corresponding to all pixel points on the key frame; starting from a first pixel value in a first pixel value sequence, performing run statistics on the pixel values in the first pixel value sequence to obtain a first run length sequence; deleting all 1 and all 2 in the first run length sequence to obtain a second run length sequence.
Preferably, the updating the first pixel value sequence and the second run length sequence according to the first pixel value sequence and the second run length sequence includes the following specific steps:
the number of kinds of run lengths in the second run length sequence is recorded as N, and the number of kinds of pixel values in the first pixel value sequence is recorded as M;
when M+N+1<256 and 0 is not in the first pixel value sequence, updating the first pixel value sequence and the second run length sequence is not needed; when M+N+1<256 and 0 is in the first pixel value sequence, the second run length sequence is not required to be updated, the pixel values of all the pixel points with the pixel values of 0 in the key frame are adjusted to be 1, and the first pixel value sequence is re-acquired;
when M+N+1 is more than or equal to 256, if 0 is in the first pixel value sequence, adjusting the pixel values of all the pixel points with the pixel values of 0 in the key frame to be 1; if 0 is not in the first pixel value sequence, the key frame is not adjusted at the moment; drawing a pixel value histogram according to the frequency of each pixel value in the key frame, when the frequency of one pixel value in the pixel value histogram is smaller than a preset threshold value and the pixel value with the frequency larger than the frequency of the pixel value exists in the range of 10 adjacent pixel values, acquiring the pixel value which is closest to the pixel value and has the frequency larger than the pixel value in the pixel value histogram as a merging pixel value corresponding to the pixel value, and modifying the pixel value of the pixel point corresponding to the pixel value in the key frame into the merging pixel value; re-acquiring a first pixel value sequence according to the modified key frame; when the pixel value variety number M of the updated first pixel value sequence meets the condition of M+N+1<256, the second run length sequence is not required to be updated; when the number M of pixel value types of the updated first pixel value sequence does not meet the condition of M+N+1<256, counting the frequency of each run length in the second run length sequence, obtaining (M+N-255) run lengths with the minimum frequency, taking the (M+N-255) run lengths as split run lengths, splitting each split run length into other run lengths in two second run length sequences, and updating the second run length sequences according to a splitting result.
Preferably, the obtaining the suffix code of each run length and the suffix code of each pixel value according to the first pixel value sequence and the second run length sequence includes the following specific steps:
the method comprises the steps of obtaining integers which are in the range of (0, 255) and do not belong to a first pixel value sequence to form a second pixel value sequence, selecting one pixel value for each run length in the second run length sequence, which is randomly replaced in the second pixel value sequence, converting the selected pixel value into an eight-bit binary number as a suffix code of the corresponding run length, and encoding the 8-bit binary number of each pixel value appearing in the first pixel value sequence as the suffix code of each pixel value.
Preferably, the step of obtaining the single pixel value and the pixel group in the first pixel value sequence according to the first run length sequence to form the sequence to be encoded includes the following specific steps:
and dividing a plurality of corresponding identical pixel values in the first pixel value sequence into a pixel group according to each run length in the second run length sequence, and forming a sequence to be encoded by all single pixel values which are not divided into the pixel groups and all the pixel groups.
Preferably, when the element to be encoded does not exist in the encoding dictionary, the codeword of the element to be encoded is obtained according to the pixel value and the suffix encoding of the run length, and the specific steps include:
When the element to be encoded does not exist in the encoding dictionary and the element to be encoded is a single pixel value, encoding 0 and the suffix of the element to be encoded to form a codeword of the element to be encoded; when the element to be encoded does not exist in the encoding dictionary and the element to be encoded is a pixel group, suffix encoding of pixel values in the pixel group and suffix encoding of a run length corresponding to the pixel group form a codeword of the element to be encoded.
Preferably, when the next element of the prefix in the sequence to be encoded is a pixel group, a codeword of the prefix is obtained, which includes the following specific steps:
and forming a code word of the prefix by the segment number of the prefix in the coding dictionary and 0, wherein the segment number is a line number of the prefix in the coding dictionary.
Preferably, the judging operation is performed on the pixel string to be encoded to obtain a new element to be encoded, including the following specific steps:
when the pixel string to be encoded does not exist in the encoding dictionary, the segment number of the prefix in the encoding dictionary and the suffix of the suffix are encoded to form a codeword of the pixel string to be encoded; adding the code word of the pixel string to be encoded into an encoding dictionary; the next element of the suffix in the sequence to be coded is used as a new element to be coded;
When the pixel string to be encoded exists in the encoding dictionary, the pixel string to be encoded is used as a new prefix, the judgment operation on the next element of the suffix in the sequence to be encoded is repeated until a new element to be encoded is obtained or the suffix is the last element in the sequence to be encoded, and iteration is stopped.
Preferably, the sequence formed by the binary strings corresponding to all the codewords in the coding dictionary is used as a compressed frame, and the specific steps are as follows:
binary numbers corresponding to the contents of two parts of each codeword in the coding dictionary are spliced into a binary string, and a sequence formed by the binary strings corresponding to all codewords is used as a compressed frame.
The technical scheme of the invention has the beneficial effects that: according to the conventional compression method, for example, LZ coding can code a character string with a long run into a plurality of code words, as the run of pixel values in a key frame is longer, the compression efficiency of compressing the key frame by using LZ coding is low, the LZ coding is improved by combining the run, and according to the type of the pixel values in the key frame, suffix coding is distributed to the run lengths in a second run length sequence, so that the suffix coding of each run length is consistent with the length of the suffix coding of the pixel values but different in content, the number of the code words obtained when compressing the key frame by combining the suffix coding of the run lengths is reduced, and the code word length is not increased, thereby improving the compression efficiency; and the number of code words obtained by coding is reduced, so that the number of lines in the coding dictionary is reduced, and the content of the first part in all code words is further reduced, so that the length of the first part in the code words after the content of the first part in the code words is converted into binary numbers is reduced, namely the length of binary strings corresponding to the finally obtained code words is reduced, the compression efficiency is further improved, and the rapid transmission of the monitoring video data of the animal epidemic prevention quarantine center is ensured.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of steps of a method for transmitting surveillance video data for an animal quarantine and quarantine center according to the present invention;
FIG. 2 is a schematic diagram of a run-length dictionary according to one embodiment of the present invention;
FIG. 3 is a schematic diagram of a first dictionary for encoding according to one embodiment of the present invention;
fig. 4 is a schematic diagram of a second coding dictionary provided by an embodiment of LZ coding.
Detailed Description
In order to further explain the technical means and effects adopted by the invention to achieve the preset aim, the following is a detailed description of specific implementation, structure, characteristics and effects of a monitoring video data transmission method for an animal epidemic prevention quarantine center according to the invention, which is provided by the invention, with reference to the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a specific scheme of a monitoring video data transmission method for an animal epidemic prevention quarantine center.
Referring to fig. 1, a flowchart of a method for transmitting surveillance video data for an animal epidemic prevention quarantine center according to an embodiment of the present invention is shown, where the method includes the following steps:
s001, acquiring a key frame in a monitoring video of an animal epidemic prevention quarantine center.
It should be noted that, the video is divided into a plurality of image groups, and each image group includes a key frame and a plurality of predictive coding frames. The prediction coding frame is the difference between the image of the current frame and the key frame or the front and back frames, and because of the spatial redundancy of the video, the difference between the adjacent frames in the video or the image frames in one image group is small, so that most positions in the prediction coding frame are 0, and the values of the rest positions are also small, and therefore the prediction coding frame has been compressed. While the key frame is a complete image, embodiments of the present invention compress the key frame. The key frame of the embodiment of the invention is a gray image, and if the key frame is a color image, the image of each channel of the key frame is respectively regarded as a gray image to be compressed.
In the embodiment of the invention, the monitoring video shot by the camera arranged in the animal epidemic prevention quarantine center is acquired, and the key frame of the monitoring video is acquired.
S002, acquiring a first run-length sequence of the key frame, and setting a run-length dictionary according to the first run-length sequence.
It should be noted that, LZ encoding assigns different suffix codes to different characters in data, and forms the existing segment number and suffix codes of the characters in the coding dictionary into a codeword of one or more characters in the data by means of constructing the coding dictionary while encoding, thereby realizing compression of the data. However, since the key frame is a complete image, local pixel points in the key frame have similarity, so that the run of pixel values in the key frame is longer. However, if the key frame is compressed by LZ encoding, a plurality of pixel values corresponding to a longer run are compressed into a plurality of parts, for example, the run length of 3,3,3,3,3,3,3,3,3,3 is 10, but if the key frame is compressed by LZ encoding, the key frame is respectively encoded into a codeword by {3}, {3,3}, and the compression efficiency is not high. In order to further improve the compression efficiency of the LZ coding, the embodiment of the present invention combines the run length to improve the LZ coding.
In the embodiment of the invention, a key frame is scanned by a first scanning mode, pixel values corresponding to pixel points at each scanning position are sequentially obtained, and all the obtained pixel values form a first pixel value sequence. The first scanning mode in the embodiment of the present invention includes, but is not limited to, hilbert scanning and raster scanning, and in other embodiments, an operator may set the first scanning mode as required.
Starting from the first pixel value in the first pixel value sequence, performing run statistics on the pixel values in the first pixel value sequence, and forming all the obtained run lengths into a first run length sequence, for example, the first pixel value sequence is {65,65,65,126,47,47,47,47,45,45,46,65,65,65,43}, and the first run length sequence is {3,1,4,2,1,3,1}.
It should be noted that, when the pixel value with the run length of 1 is compressed by LZ encoding, the pixel value is encoded into a codeword or is encoded into a codeword together with other pixel values, and the compression efficiency is maximized, so that the compression is not needed by using the run. The pixel value with the run length of 2 is encoded into two code words together with other pixel values when compressed by LZ encoding, and the compression efficiency is not greatly improved when the run is combined for compression.
In the embodiment of the present invention, all 1 and all 2 in the first run-length sequence are deleted as the second run-length sequence. For example, the first run-length sequence is {3,1,4,2,1,3,1}, and the second run-length sequence obtained by deleting all 1 and 2 is {3,4,3}. Taking all the same run lengths in the second run length sequence as one run length, and counting the number N of types of the run lengths in the second run length sequence. And taking all the same pixel values as one pixel value, and counting the type number M of the pixel values in the first pixel value sequence.
It should be noted that, to enhance the compression rate of LZ coding in combination with a run, a suffix code may be allocated to each run length, and in the compression process, a suffix code of a character and a suffix code of a run length are used to form a codeword of a plurality of characters of the run length, so that a plurality of characters corresponding to a longer run are compressed into a result, thereby enhancing the compression rate of LZ coding. In the conventional compression of an image using LZ coding, each pixel value in the image is regarded as a character to be compressed, and suffix codes allocated to each different character (i.e., each pixel value) are converted into a result of converting each pixel value into a binary number of a fixed length. Since the key frame is a complete image, the value range of the pixel value of each pixel point in the key frame is [0,255], the suffix code of each pixel value in the key frame is eight-bit binary number, and the suffix code of each pixel value is one of 00000000, 00000001, 00000010 and 11111111. In order to ensure that subsequent decompression can be successfully performed, the length of the suffix code allocated for each run length needs to be the same as the length of the suffix code of the pixel value, and the content of the suffix code allocated for each run length is different from the content of the suffix code of the pixel value. Since there are no 8-bit binary numbers other than 00000000, 00000001, 00000010, &.. it is therefore necessary to increase the length of the suffix encoding of each pixel value in the key frame, to ensure that the length of the suffix code of each run-length allocation is the same as the length of the suffix code of the pixel value and that the content of the suffix code of each run-length allocation is different from the content of the suffix code of the pixel value. But this method tends to increase the length of the resulting codeword, thereby making compression less efficient. Therefore, the embodiment of the invention distributes suffix codes with the length of 8 bits for each run length by combining pixel values which do not appear in the key frame or pixel values with very small occurrence frequency, so that the length of the finally obtained code word is not increased, thereby ensuring the compression efficiency.
In the embodiment of the present invention, the specific method for allocating suffix codes to each run length is as follows:
the number of classes of run lengths is N and the number of classes of pixel values is M.
When M+N+1<256, the number of kinds of pixel values which do not appear in the key frame is greater than or equal to the number of kinds of the run lengths, at this time, all kinds of run lengths in the range of (0, 255) and the corresponding suffix codes form a run length dictionary, a schematic diagram of the run length dictionary provided by the embodiment of the invention is shown in figure 2, the first pixel value sequence is {65,65,65,126,47,47,47,47,45,45,46,65,65,65,43} and the second run length sequence is {3,4,3} and one run length corresponding to the second run length sequence is selected randomly and not replaced in the second pixel value sequence, the selected pixel values are converted into eight binary numbers, and the eight binary numbers are used as the suffix codes of the corresponding run lengths; when 0 is not in the first sequence of pixel values, no adjustment is made to the key frame.
When m+n+1 is greater than or equal to 256, the number of types of pixel values which do not appear in the key frame is smaller than the number of types of run lengths, and at this time, suffix encoding with a length of 8 bits cannot be allocated to all types of run lengths, so that the pixel values in the key frame need to be adjusted, so that the number of types of pixel values which do not appear in the key frame is greater, and suffix encoding with a length of 8 bits is allocated to all types of run lengths. The specific steps for adjusting the pixel values in the key frame are as follows:
when 0 is in the first pixel value sequence, the pixel values of all the pixel points with the pixel values of 0 in the key frame are adjusted to be 1. When 0 is not in the first sequence of pixel values, then no adjustment is made to the key frame at this time. And drawing a pixel value histogram according to the frequency of each pixel value in the key frame, and when the frequency of one pixel value in the pixel value histogram is smaller than a preset threshold value and pixel values with frequencies larger than the frequency of the pixel value exist in the adjacent 10 pixel value ranges, acquiring the pixel value which is closest to the pixel value and has frequencies larger than the pixel value in the pixel value histogram as a combined pixel value corresponding to the pixel value, and modifying the pixel value of the pixel point corresponding to the pixel value in the key frame into the combined pixel value, wherein the adjacent 10 pixel value ranges refer to the pixel value at the left 5 pixel values and the right 5 pixel values in the pixel value histogram. Similarly, the pixel values satisfying the condition in the key frame are all modified to their corresponding merged pixel values. And re-acquiring the first sequence of pixel values according to the modified key frame. In the embodiment of the present invention, the preset threshold is 0.00005, and in other embodiments, the implementation personnel can set the preset threshold according to the needs.
It should be noted that, when the embodiment of the invention adjusts the key frame, the frequency of the pixel values and the distance between the pixel values are combined, so that the pixel values of only a small part of the pixel points in the key frame are adjusted, and the adjustment amplitude of the pixel values in the key frame is ensured to be very small, so that the difference between the key frame after adjustment and the key frame before adjustment is very small, and visual lossless can be ensured.
When the pixel value variety number M of the first pixel value sequence meets the condition that M+N+1 is less than 256, acquiring a run length dictionary; when the number M of pixel value types of the first pixel value sequence does not meet the condition that M+N+1<256, the second run length sequence is adjusted, the frequency of each run length in the second run length sequence is counted, the (M+N-255) run lengths with the minimum frequency are obtained and used as split run lengths, and when each split run length is split into other run lengths in the two second run length sequences, for example, the run length 10 is split into the run lengths 5 and 5. It should be noted that, when the split run length cannot be split into other run lengths in the two second run length sequences, the split run length is split into other run lengths in the two first run length sequences. And updating the second run length sequence according to the splitting result, and eliminating all 1 and all 2 in the second run length sequence. At this time, the number of types N of the run lengths in the second run length sequence and the number of types M of the pixel values in the first pixel value sequence finally obtained satisfy the condition m+n+1<256, and at this time, a run length dictionary is obtained.
Thus, a run-length dictionary is obtained.
It should be noted that, in the embodiment of the present invention, by combining the types of pixel values in the key frame, suffix codes are allocated to run lengths in the second run-length sequence, so as to construct a run-length dictionary, and it is ensured that the suffix code of each run length in the run-length dictionary is consistent with the length of the suffix code of the pixel value but different in content, so that when the key frame is compressed by combining the suffix codes of the run lengths subsequently, the number of obtained code words is reduced, and the code word length is not increased, thereby ensuring compression efficiency.
S003, compressing the key frames according to the run length dictionary to obtain compressed frames.
And compressing the key frame adjusted in the step S002. The specific method for compressing the key frames comprises the following steps:
each pixel value appearing in the first sequence of pixel values is first assigned a suffix encoding, and an 8-bit binary number of each pixel value appearing in the first sequence of pixel values is encoded as the suffix of that pixel value.
An empty coding dictionary is constructed, wherein the coding dictionary comprises three columns, namely a segment number, a pixel string and a code word, wherein the segment number is used for recording the line number of the coding dictionary, the pixel string is used for recording the content coded by the current line, and the code word is used for recording the result of the coding of the current line.
Each run length in the second run length sequence corresponds to a plurality of identical pixel values in the first pixel value sequence, and the plurality of identical pixel values corresponding to the first pixel value sequence are divided into a pixel group according to each run length in the second run length sequence. All pixel values which are not divided into pixel groups and all pixel groups are formed into a sequence to be encoded according to the sequence of the pixel values in the first pixel value sequence. For example, the second run-length sequence is {3,4,3}, the first pixel value sequence is {65,65,65,126,47,47,47,47,45,45,46,65,65,65,43}, 65,65,65 is divided into one pixel group, 47,47,47,47 is divided into one pixel group, 65,65,65 is divided into one pixel group, and the sequence to be encoded is { (65,65,65), 126, (47,47,47,47), 45,45,46, (65,65,65), 43}.
Taking the first element in the sequence to be encoded as an element to be encoded, and performing encoding operation according to the element to be encoded:
1. when the element to be encoded does not exist in the pixel string of the encoding dictionary, a row is inserted at the tail of the encoding dictionary, the element to be encoded is filled into the pixel string of the inserted row, the row number of the row is filled into the section number column, for example, the row number of the ith row is i, and the section number of the corresponding row is i. When the element to be encoded is a single pixel value, encoding 0 and the suffix of the element to be encoded to form a codeword of the element to be encoded, filling the codeword of the element to be encoded into a codeword column of a row where the element to be encoded is located in an encoding dictionary, for example, when the element to be encoded is 126, the suffix of the element to be encoded is encoded as 01111110, and the codeword is (0,01111110); when the element to be encoded is a pixel group, the suffix of the pixel value in the pixel group is encoded to form a codeword of the element to be encoded with the suffix of the run length corresponding to the pixel group, the codeword of the element to be encoded is filled into a codeword row of the line where the element to be encoded is located in the encoding dictionary, for example, when the element to be encoded is 65,65,65, the run length is 3, the suffix of the pixel value 65 is 01000001, and if the suffix of the run length 3 is 10000000, the codeword is (01000001,10000000). And taking the next element of the element to be encoded in the sequence to be encoded as a new element to be encoded.
2. When the element to be encoded exists in the pixel string of the encoding dictionary, the element to be encoded is used as a prefix P. The judging operation of the next element of the prefix P in the sequence to be coded comprises the following steps:
2.1, inserting a row at the end of the code word dictionary when the next element of the prefix P in the sequence to be coded is a pixel group, filling the prefix P into the pixel string of the inserted row, filling the row number of the row into the segment number column, forming a code word of the prefix P by the prefix P and 0 corresponding to the code word dictionary, and filling the code word into the code dictionary, for example, the prefix P is 65,65,65, and assuming 65,65,65 exists in the code dictionary and the segment number is 1, the code word is (1, 0). Taking the next element of the prefix P in the sequence to be encoded as a new element to be encoded;
2.2, when the next element of the prefix P in the sequence to be encoded is a single pixel value, taking the next element of the prefix P in the sequence to be encoded as a suffix C, taking a pixel string spliced by the prefix P and the suffix C as a pixel string to be encoded, and judging whether the pixel string to be encoded exists in the pixel string of the encoding dictionary or not:
when the pixel string to be encoded does not exist in the pixel string of the encoding dictionary, inserting a row at the end of the encoding dictionary, filling the pixel string to be encoded into the pixel string of the inserted row, filling the row number of the row into the section number column, encoding the prefix P in the section number corresponding to the encoding dictionary and the suffix of the suffix C to form a codeword of the pixel string to be encoded, and filling the codeword into the encoding dictionary, for example, the prefix P is 65,65,65, the suffix C is 43, the suffix of the suffix C is 00101011, and assuming 65,65,65 exists in the encoding dictionary and the section number is 1, the codeword is (1,00101011); taking the next element of the suffix C in the sequence to be encoded as a new element to be encoded;
When the pixel string to be encoded exists in the pixel string of the encoding dictionary, the pixel string to be encoded is used as a new prefix P, the judgment operation is repeatedly carried out on the next element of the suffix C in the sequence to be encoded until a new element to be encoded is obtained or the suffix is the last element in the sequence to be encoded, and iteration is stopped.
3. And repeating the encoding operation according to the new elements to be encoded until all elements in the sequence to be encoded have traversed and iteration is stopped.
Referring to fig. 3, fig. 3 is a diagram illustrating a first pixel value sequence {65,65,65,126,47,47,47,47,45,45,46,65,65,65,43}, a second run-length sequence {3,4,3}, and a corresponding code dictionary when the run-length dictionary is fig. 2.
If LZ coding is used for the first sequence of pixel values 65,65,65,126,47,47,47,47,45,45,46,65,65,65,43, the resulting coding dictionary is shown in fig. 4. As can be seen from fig. 3 and fig. 4, the number of lines of the coding dictionary finally obtained by the method in the embodiment of the present invention is small, the number of corresponding codewords is small, and the compression efficiency is higher than that of LZ coding.
In the coding dictionary finally obtained by the embodiment of the invention, each codeword is divided into two parts, wherein the first part is the suffix coding of 0 or segment number or pixel value, and the second part is the suffix coding of pixel value or the suffix coding of 0 or run. The content of the first part of all codewords is converted uniformly into fixed-length binary numbers, the length L of which depends on the maximum value B in the content of the first part of all codewords (the suffix encoding of the pixel values in the first part can be converted into decimal numbers for comparison with other values in the first part, thus screening the maximum value B, which is a decimal number),
Figure SMS_1
Wherein
Figure SMS_2
To take the value symbol upwards. The contents of the second part of all codewords are converted uniformly into 8-bit binary numbers. And splicing the fixed-length binary number of the first part of each codeword with the 8-bit binary number of the second part to obtain a binary string, and using the binary string as the coding result of the pixel string corresponding to the codeword. The coding results of all pixel strings in the coding dictionary are sequentially formed into a one-dimensional sequence, which is recorded as a compressed frame. The compressed frame is the result of compressing the key frame.
Thus, a compressed frame is acquired.
It should be noted that, in the embodiment of the present invention, a mode of combining run length and LZ coding is adopted to compress a key frame, and a suffix code with a certain length is allocated to the run length, so that the length of the second part of content of the obtained codeword is ensured to be consistent with the length of the second part of content of the codeword obtained only by LZ coding, and the number of finally obtained codewords is reduced by combining run length coding, thereby achieving the effect of increasing compression efficiency. And the number of the code words is reduced, so that the segment numbers in the coding dictionary are reduced, and the maximum value in the content of the first part in all the code words is further reduced, so that the length of the content of the first part in the code words converted into binary numbers is reduced, namely the length of the finally obtained coding result of the pixel string is reduced, and the compression efficiency is further improved.
S004, compressed data are obtained and transmitted, and decompression is carried out on the compressed data.
The compressed frames and the predictive coding frames in the monitoring video are transmitted to a storage server as compressed data for storage, and in order to ensure decompression, the run length dictionary is also required to be transmitted to the storage server for storage. When decompression is needed, the compressed frames in the compressed data are decompressed first. The specific decompression process is as follows:
the compressed frame is a result of compressing the key frame, the compressed frame is a one-dimensional sequence, each element in the compressed frame is a coding result, and each coding result corresponds to a pixel string. The length of each coding result is equal, and the length of the coding result is marked as C. Each encoding result is split into two parts of contents, wherein the first part is the result of converting the front (C-8) bit binary number in the encoding result into a decimal number, and the second part is the rear 8 bit binary number in the encoding result. The first part and the second part of each coding result are formed into a code word, and all code words are formed into a code word sequence.
The number T of codewords in the compressed frame is obtained. A coding dictionary is constructed, wherein the coding dictionary comprises three columns which are respectively a segment number, a pixel string and a code word, the coding dictionary comprises T rows, the segment number of each row is respectively a row number of the row, and the code word of each row is respectively each code word in a code word sequence.
Decoding each codeword in turn, the specific steps comprising:
when the second part of the code word is in the run-length dictionary, the second part of the code word is the suffix code of the run-length, the first part of the code word is the pixel value, the corresponding run-length S of the second part of the code word in the run-length dictionary is obtained, and a pixel string is obtained according to the pixel value and the run-length S. If the pixel value is 2 and the run length s=4, the pixel string is 2,2. The pixel string is the decoding result of the code word, and the pixel string is filled into the pixel string of the code word row in the coding dictionary.
When the second part of the code word is not in the run-length dictionary and is not 00000000, the second part of the code word is the suffix code of the pixel value, the suffix code is converted into decimal numbers to obtain the pixel value, and when the first part of the code word is not 0, the first part of the code word is a segment number, and the pixel string in a row corresponding to the segment number in the code dictionary is obtained. And splicing the obtained pixel values into the pixel string to obtain a new pixel string, wherein the new pixel string is the decoding result of the code word, and the new pixel string is filled into the pixel string of the row where the code word is located in the coding dictionary.
When the second part of the codeword is not in the run-length dictionary and is not 00000000, the second part of the codeword is a suffix encoding of the pixel value, and the suffix encoding is converted into a decimal number to obtain the pixel value, when the first part of the codeword is 0. And the pixel value corresponding to the second part of the code word is the decoding result of the code word, and the pixel value is filled into the pixel string of the code word line in the coding dictionary.
When the second part of the code word is 00000000, the first part of the code word is a segment number, and the pixel string in the row corresponding to the segment number in the coding dictionary is obtained, and then the pixel string is the decoding result of the code word. The pixel string is filled into the pixel string of the code dictionary where the code word is located.
And splicing the contents of a column of pixel strings in the finally obtained coding dictionary according to the sequence of the pixel strings in the coding dictionary to obtain a one-dimensional pixel value sequence. The one-dimensional sequence of pixel values is the pixel values in the key frame.
The size of the key frame is the same as that of the predictive coding frame, so that a two-dimensional matrix which is the same as that of the predictive coding frame and is empty is constructed, the two-dimensional matrix is scanned by utilizing a first scanning mode, each pixel value in the pixel value sequence is sequentially filled into each scanning position of the two-dimensional matrix, and the finally obtained filled two-dimensional matrix is the key frame.
And obtaining a monitoring video of the animal epidemic prevention quarantine center according to the key frame and the predictive coding frame.
Through the steps, the encoding compression and decompression of the monitoring video of the animal epidemic prevention quarantine center are completed.
The embodiment of the invention distributes the suffix codes for the run lengths in the second run length sequence by combining the types of the pixel values in the key frames, ensures that the suffix codes of each run length are consistent with the suffix codes of the pixel values in length but different in content, reduces the number of the obtained code words when the key frames are compressed by combining the suffix codes of the run lengths, and does not increase the code word length, thereby improving the compression efficiency; and the number of code words obtained by coding is reduced, so that the number of lines in the coding dictionary is reduced, and the content of the first part in all code words is further reduced, so that the length of the first part in the code words after the content of the first part in the code words is converted into binary numbers is reduced, namely the length of binary strings corresponding to the finally obtained code words is reduced, the compression efficiency is further improved, and the rapid transmission of the monitoring video data of the animal epidemic prevention quarantine center is ensured.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.

Claims (7)

1. A monitoring video data transmission method for an animal epidemic prevention quarantine center is characterized by comprising the following steps:
acquiring a first pixel value sequence and a second run length sequence according to a key frame in a monitoring video of an animal epidemic prevention quarantine center; updating the first pixel value sequence and the second run-length sequence according to the first pixel value sequence and the second run-length sequence; acquiring suffix codes of each run length and suffix codes of each pixel value according to the first pixel value sequence and the second run length sequence; acquiring a single pixel value and a pixel group in a first pixel value sequence according to a first run length sequence to form a sequence to be coded;
constructing an empty coding dictionary; taking a first element in a sequence to be encoded as an element to be encoded, and performing encoding operation according to the element to be encoded, wherein the method comprises the following steps:
s1: when the element to be encoded does not exist in the encoding dictionary, acquiring a codeword of the element to be encoded according to the pixel value and the suffix encoding of the run length; adding the element to be encoded and the code word of the element to be encoded into an encoding dictionary; taking the next element of the element to be coded in the sequence to be coded as a new element to be coded;
S2: when the element to be encoded exists in the encoding dictionary, taking the element to be encoded as a prefix; the judging operation of the next element of the prefix in the sequence to be coded comprises the following steps:
s201: when the next element of the prefix in the sequence to be coded is a pixel group, acquiring a codeword of the prefix; adding the prefix and the codeword of the prefix into a coding dictionary; the next element of the prefix in the sequence to be coded is used as a new element to be coded;
s202: when the next element of the prefix in the sequence to be encoded is a single pixel value, the next element of the prefix in the sequence to be encoded is used as a suffix, and a pixel string formed by splicing the prefix and the suffix is used as a pixel string to be encoded; judging the pixel string to be encoded to obtain a new element to be encoded;
s3: repeating the encoding operation according to the new elements to be encoded until all elements in the sequence to be encoded have traversed and iteration is stopped;
taking a sequence formed by binary strings corresponding to all codewords in the coding dictionary as a compressed frame; transmitting the compressed frame;
the method for acquiring the first pixel value sequence and the second run length sequence according to the key frame in the monitoring video of the animal epidemic prevention quarantine center comprises the following specific steps:
Acquiring a key frame in a monitoring video of an animal epidemic prevention quarantine center, and forming a first pixel value sequence by pixel values corresponding to all pixel points on the key frame; starting from a first pixel value in a first pixel value sequence, performing run statistics on the pixel values in the first pixel value sequence to obtain a first run length sequence; deleting all 1 and all 2 in the first run length sequence to obtain a second run length sequence;
the updating of the first pixel value sequence and the second run length sequence according to the first pixel value sequence and the second run length sequence comprises the following specific steps:
the number of kinds of run lengths in the second run length sequence is recorded as N, and the number of kinds of pixel values in the first pixel value sequence is recorded as M;
when M+N+1<256 and 0 is not in the first pixel value sequence, updating the first pixel value sequence and the second run length sequence is not needed; when M+N+1<256 and 0 is in the first pixel value sequence, the second run length sequence is not required to be updated, the pixel values of all the pixel points with the pixel values of 0 in the key frame are adjusted to be 1, and the first pixel value sequence is re-acquired;
when M+N+1 is more than or equal to 256, if 0 is in the first pixel value sequence, adjusting the pixel values of all the pixel points with the pixel values of 0 in the key frame to be 1; if 0 is not in the first pixel value sequence, the key frame is not adjusted at the moment; drawing a pixel value histogram according to the frequency of each pixel value in the key frame, when the frequency of one pixel value in the pixel value histogram is smaller than a preset threshold value and the pixel value with the frequency larger than the frequency of the pixel value exists in the range of 10 adjacent pixel values, acquiring the pixel value which is closest to the pixel value and has the frequency larger than the pixel value in the pixel value histogram as a merging pixel value corresponding to the pixel value, and modifying the pixel value of the pixel point corresponding to the pixel value in the key frame into the merging pixel value; re-acquiring a first pixel value sequence according to the modified key frame; when the pixel value variety number M of the updated first pixel value sequence meets the condition of M+N+1<256, the second run length sequence is not required to be updated; when the number M of pixel value types of the updated first pixel value sequence does not meet the condition of M+N+1<256, counting the frequency of each run length in the second run length sequence, obtaining (M+N-255) run lengths with the minimum frequency, taking the (M+N-255) run lengths as split run lengths, splitting each split run length into other run lengths in two second run length sequences, and updating the second run length sequences according to a splitting result.
2. The method for transmitting surveillance video data for an animal quarantine and quarantine center according to claim 1, wherein the acquiring the suffix code of each run length and the suffix code of each pixel value according to the first pixel value sequence and the second run length sequence comprises the following specific steps:
the method comprises the steps of obtaining integers which are in the range of (0, 255) and do not belong to a first pixel value sequence to form a second pixel value sequence, selecting one pixel value for each run length in the second run length sequence, which is randomly replaced in the second pixel value sequence, converting the selected pixel value into an eight-bit binary number as a suffix code of the corresponding run length, and encoding the 8-bit binary number of each pixel value appearing in the first pixel value sequence as the suffix code of each pixel value.
3. The method for transmitting surveillance video data for an animal epidemic prevention quarantine center according to claim 1, wherein the steps of obtaining a single pixel value and a pixel group in a first pixel value sequence according to a first run length sequence to form a sequence to be encoded include the following specific steps:
and dividing a plurality of corresponding identical pixel values in the first pixel value sequence into a pixel group according to each run length in the second run length sequence, and forming a sequence to be encoded by all single pixel values which are not divided into the pixel groups and all the pixel groups.
4. The method for transmitting surveillance video data for an animal epidemic prevention quarantine center according to claim 1, wherein when the element to be encoded does not exist in the encoding dictionary, the codeword of the element to be encoded is obtained according to the pixel value and the suffix encoding of the run length, comprising the specific steps of:
when the element to be encoded does not exist in the encoding dictionary and the element to be encoded is a single pixel value, encoding 0 and the suffix of the element to be encoded to form a codeword of the element to be encoded; when the element to be encoded does not exist in the encoding dictionary and the element to be encoded is a pixel group, suffix encoding of pixel values in the pixel group and suffix encoding of a run length corresponding to the pixel group form a codeword of the element to be encoded.
5. The method for transmitting surveillance video data for an animal epidemic prevention quarantine center according to claim 1, wherein when the next element in the sequence to be encoded is a pixel group, the method for acquiring the codeword of the prefix comprises the following specific steps:
and forming a code word of the prefix by the segment number of the prefix in the coding dictionary and 0, wherein the segment number is a line number of the prefix in the coding dictionary.
6. The method for transmitting monitoring video data for animal epidemic prevention quarantine center according to claim 1, wherein the judging operation is performed on the pixel string to be encoded to obtain new elements to be encoded, comprising the following specific steps:
When the pixel string to be encoded does not exist in the encoding dictionary, the segment number of the prefix in the encoding dictionary and the suffix of the suffix are encoded to form a codeword of the pixel string to be encoded; adding the code word of the pixel string to be encoded into an encoding dictionary; the next element of the suffix in the sequence to be coded is used as a new element to be coded;
when the pixel string to be encoded exists in the encoding dictionary, the pixel string to be encoded is used as a new prefix, the judgment operation on the next element of the suffix in the sequence to be encoded is repeated until a new element to be encoded is obtained or the suffix is the last element in the sequence to be encoded, and iteration is stopped.
7. The method for transmitting surveillance video data for an animal quarantine and quarantine center according to claim 1, wherein the sequence of binary strings corresponding to all codewords in the coding dictionary is used as a compressed frame, comprising the following specific steps:
binary numbers corresponding to the contents of two parts of each codeword in the coding dictionary are spliced into a binary string, and a sequence formed by the binary strings corresponding to all codewords is used as a compressed frame.
CN202310237684.6A 2023-03-14 2023-03-14 Monitoring video data transmission method for animal epidemic prevention quarantine center Active CN115955569B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310237684.6A CN115955569B (en) 2023-03-14 2023-03-14 Monitoring video data transmission method for animal epidemic prevention quarantine center

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310237684.6A CN115955569B (en) 2023-03-14 2023-03-14 Monitoring video data transmission method for animal epidemic prevention quarantine center

Publications (2)

Publication Number Publication Date
CN115955569A CN115955569A (en) 2023-04-11
CN115955569B true CN115955569B (en) 2023-05-23

Family

ID=85903325

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310237684.6A Active CN115955569B (en) 2023-03-14 2023-03-14 Monitoring video data transmission method for animal epidemic prevention quarantine center

Country Status (1)

Country Link
CN (1) CN115955569B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116320499B (en) * 2023-04-17 2024-01-09 深圳市嘉立方科技有限公司 Communication method and system
CN116388769B (en) * 2023-06-06 2023-12-29 莱芜职业技术学院 Computer storage optimization method for environment detection data
CN116506629B (en) * 2023-06-27 2023-08-25 上海伯镭智能科技有限公司 Road condition data compression method for mine unmanned mine car cooperative control
CN117119120B (en) * 2023-10-25 2023-12-22 上海伯镭智能科技有限公司 Cooperative control method based on multiple unmanned mine cars
CN118018032B (en) * 2024-04-09 2024-06-14 西安西驰信息技术有限公司 Remote control data transmission method of intelligent switch cabinet
CN118652963A (en) * 2024-08-21 2024-09-17 惠州海关综合技术中心(惠州国际旅行卫生保健中心、惠州海关口岸门诊部) Animal quarantine equipment based on fluorescent PCR technology and use method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103746706A (en) * 2014-01-01 2014-04-23 安庆师范学院 Testing data compressing and decompressing method on basis of double-run-length alternate coding
CN114614833A (en) * 2022-03-16 2022-06-10 程一飞 Test data compression and decompression method for self-adaptive run-length coding

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6597812B1 (en) * 1999-05-28 2003-07-22 Realtime Data, Llc System and method for lossless data compression and decompression
US8108361B2 (en) * 2008-07-31 2012-01-31 Microsoft Corporation Efficient column based data encoding for large-scale data storage
JP2010074444A (en) * 2008-09-17 2010-04-02 Ricoh Co Ltd Image compression apparatus and method, image decoding apparatus and method, and computer program
CN103997651A (en) * 2014-05-17 2014-08-20 北京中和卓远科技有限公司 Data compression method and device for composite images
CN112399181B (en) * 2019-08-19 2022-08-26 华为技术有限公司 Image coding and decoding method, device and storage medium
CN114092577A (en) * 2021-11-05 2022-02-25 杭州太美星程医药科技有限公司 Image data processing method, image data processing device, computer equipment and storage medium
CN114614832A (en) * 2022-03-16 2022-06-10 吴海峰 Test data compression and decompression method based on front and back run length coding

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103746706A (en) * 2014-01-01 2014-04-23 安庆师范学院 Testing data compressing and decompressing method on basis of double-run-length alternate coding
CN114614833A (en) * 2022-03-16 2022-06-10 程一飞 Test data compression and decompression method for self-adaptive run-length coding

Also Published As

Publication number Publication date
CN115955569A (en) 2023-04-11

Similar Documents

Publication Publication Date Title
CN115955569B (en) Monitoring video data transmission method for animal epidemic prevention quarantine center
US11044495B1 (en) Systems and methods for variable length codeword based data encoding and decoding using dynamic memory allocation
US4028731A (en) Apparatus for compression coding using cross-array correlation between two-dimensional matrices derived from two-valued digital images
CN1126268C (en) Method of and device for coding digital information signal
US5528628A (en) Apparatus for variable-length coding and variable-length-decoding using a plurality of Huffman coding tables
CN116723337B (en) HDMI high definition data optimized transmission method and system
JP4033836B2 (en) Compression of paletted color images using variable-length color codes
EP3108583B1 (en) Devices and methods of source-encoding and decoding of data
EP2317476B1 (en) Multimedia signature coding and decoding
US20070279261A1 (en) Method and apparatus for lossless run-length data encoding
CN101039374B (en) Image lossless compression method
US20010003544A1 (en) Image processing apparatus and method and storage medium
CN115242475A (en) Big data secure transmission method and system
JP2005516554A6 (en) Compression of paletted color images using variable-length color codes
US5594435A (en) Permutation-based data compression
CN115866287B (en) Efficient data transmission method for intelligent campus management platform
JPH07212242A (en) Variable-length decoder
CN1163686A (en) Method and system for encoding and decoding method and system
JP2831888B2 (en) HDTV decoder
US8933826B2 (en) Encoder apparatus, decoder apparatus and method
Langdon et al. A double-adaptive file compression algorithm
GB2060226A (en) Data compression-decompression
EP0349677B1 (en) Image coding system
CN110191341B (en) Depth data coding method and decoding method
KR100636370B1 (en) Apparatus and method for coding using bit-precision, and apparatus and method for decoding according to the same

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant