Video compression method and device, nonvolatile storage medium and electronic equipment
By identifying key areas in video frames and using differentiated compression algorithms, the problems of key information loss and storage resource waste caused by video compression in the prior art are solved, and efficient and clear video storage is achieved.
Patent Information
- Application Number
- CN202510520622.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-12
AI Technical Summary
Existing video compression methods perform indiscriminate compression of videos, resulting in the loss of key information, and non-critical information occupies too much storage resources, making it difficult to achieve efficient compression while ensuring the quality of video.
The deep learning model YOLO is used to identify the key areas (ROIs) in the video frame, and a high-fidelity compression algorithm is adopted for key areas, and a high-compression ratio algorithm is used for non-critical areas to achieve differentiated compression among regions.
It ensures the integrity and clarity of key information, while significantly reducing storage space requirements and improving the storage efficiency of video data.
Smart Images

Figure CN120475166A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video surveillance technology, and in particular to a video compression method, device, non-volatile storage medium, and electronic device. Background Art
[0002] With the widespread adoption of video surveillance systems, the amount of video data has increased dramatically, posing significant challenges to storage and management. Existing video compression methods rely on indiscriminate compression, which, while reducing storage space, can lead to the loss of critical information due to overcompression, while non-critical information consumes excessive storage resources.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present application provide a video compression method, device, non-volatile storage medium and electronic device to at least solve the technical problems of loss of key video information and excessive storage resources occupied by non-key information due to indiscriminate video compression in the prior art.
[0005] According to one aspect of an embodiment of the present application, a video compression method is provided, including: determining a first area and a second area in each frame video image of a target video, wherein the first area is an area containing a detection target; determining feature information of the first area and position information of the first area in the video image; applying a first compression algorithm to the first area to obtain a first compressed code stream, and applying a second compression algorithm to the second area to obtain a second compressed code stream, wherein a compression ratio of the second compressed code stream is higher than a compression ratio of the first compressed code stream; integrating the first compressed code stream and the second compressed code stream into a frame code stream, and storing the frame code stream, feature information and position information in a storage space.
[0006] Optionally, applying a first compression algorithm to the first region to obtain a first compressed code stream includes: performing wavelet transform processing on the first region to obtain a first component and a second component of the first region, wherein the frequency of the first component is higher than the frequency of the second component, and the first component is used to reflect the detail feature information of the first region; performing quantization compression processing on the second component to obtain a quantization compression result; and determining the first compressed code stream based on the first component and the quantization compression result.
[0007] Optionally, determining the first compressed code stream based on the first component and the quantization compression result includes: combining the first component and the quantization compression result to obtain the first compressed code stream; or, compressing the first component using lossless coding compression to obtain a lossless compression result; and combining the lossless compression result and the quantization compression result to obtain the first compressed code stream.
[0008] Optionally, determining the first area and the second area in each frame of the target video includes: determining a target bounding box in the video image, wherein the target bounding box is a bounding box containing the detected target; determining the first area in the video image based on the target bounding box; and determining an area in the video image other than the first area as the second area.
[0009] Optionally, determining a target bounding box in a video image includes: dividing the video image into multiple grids; for each grid in the multiple grids, determining a predicted bounding box corresponding to each grid, as well as a confidence and a predicted value of the predicted bounding box, wherein the confidence is used to reflect the probability that the predicted bounding box contains the detected target, and the predicted value includes a category probability prediction value, and the category probability prediction value is used to reflect the probability that the predicted bounding box is a preset bounding box category, and different preset bounding box categories correspond to different detection target categories; the predicted bounding box is screened according to the confidence and the prediction value to obtain the target bounding box.
[0010] Optionally, filtering the predicted bounding boxes based on the confidence and the predicted value to obtain the target bounding box includes: filtering the predicted bounding boxes based on the confidence and the predicted value to obtain a set of candidate bounding boxes; determining the degree of overlap between each bounding box in the set of candidate bounding boxes and a reference bounding box, wherein the reference bounding box is the predicted bounding box with the highest confidence; and removing bounding boxes in the set of candidate bounding boxes other than the reference bounding box whose degree of overlap is greater than a preset threshold to obtain the target bounding box.
[0011] Optionally, the feature information includes at least one of the following: detection target type, texture feature, color feature, motion feature.
[0012] According to another aspect of an embodiment of the present application, a video compression device is also provided, including: a first processing module, used to determine a first area and a second area in each frame video image of a target video, wherein the first area is an area containing a detection target; a second processing module, used to determine feature information of the first area and position information of the first area in the video image; a third processing module, used to apply a first compression algorithm to the first area to obtain a first compressed code stream, and apply a second compression algorithm to the second area to obtain a second compressed code stream, wherein the compression ratio of the second compressed code stream is higher than the compression ratio of the first compressed code stream; a fourth processing module, used to integrate the first compressed code stream and the second compressed code stream into a frame code stream, and store the frame code stream, feature information and position information in a storage space.
[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, in which a program is stored. When the program is running, a device where the non-volatile storage medium is located is controlled to execute a video compression method.
[0014] According to another aspect of an embodiment of the present application, an electronic device is provided, including: a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the video compression method is executed when the program is run.
[0015] According to another aspect of an embodiment of the present application, a computer program product is further provided, including a computer program, which implements a video compression method when executed by a processor.
[0016] In an embodiment of the present application, a first region and a second region are determined in each frame of a target video, wherein the first region is a region containing a detection target; feature information of the first region and position information of the first region in the video image are determined; a first compression algorithm is applied to the first region to obtain a first compressed code stream, and a second compression algorithm is applied to the second region to obtain a second compressed code stream, wherein the compression ratio of the second compressed code stream is higher than the compression ratio of the first compressed code stream; the first compressed code stream and the second compressed code stream are integrated into a frame code stream, and the frame code stream, feature information and position information are stored in a storage space. By using the deep learning model YOLO for intelligent analysis of video content and key area identification, high-fidelity compression is applied to key areas and high compression ratio compression is applied to non-key areas, thereby achieving the purpose of differentiated compression and storage of video data by region, thereby achieving the technical effect of significantly reducing the overall storage space requirement while ensuring high clarity and integrity of key information, thereby solving the technical problem of loss of key video information and excessive storage resource occupation by non-key information due to indiscriminate compression of videos in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a structural diagram of a computer terminal provided according to an embodiment of the present application;
[0019] Figure 2 1 is a flow chart of a video compression method provided according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a video compression method provided according to an embodiment of the present application;
[0021] Figure 4 This is a schematic diagram of a process for identifying and marking key information according to an embodiment of the present application;
[0022] Figure 5 This is a schematic diagram of regional compression provided according to an embodiment of the present application;
[0023] Figure 6 It is a structural diagram of a video compression device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0027] Video compression: Specific compression techniques are used to remove redundant information from videos, thereby reducing the amount of storage required to represent the original video. The main purpose is to reduce storage space and transmission bandwidth requirements, improve transmission efficiency, and save costs.
[0028] In the field of video surveillance and image processing, ROI (Region of Interest) refers to specific areas within an image or video frame that contain important or sensitive information. These areas may contain data that is critical to monitoring targets, event analysis, or security assessments. For example:
[0029] 1. Face regions: In surveillance videos of public places, face regions are identified as ROIs because they contain key information about individual identities and are extremely important for crowd behavior analysis, facial recognition, and security monitoring.
[0030] 2. License Plate Region: In traffic monitoring, license plate regions are marked as ROIs because they contain vehicle identity information and are critical for traffic law enforcement, traffic accident investigation, and vehicle tracking.
[0031] 3. Abnormal behavior areas: In video surveillance, abnormal behavior areas (such as sudden running, falling, etc.) that can be identified through behavioral analysis technology are crucial as ROIs for immediate security response and incident recovery.
[0032] 4. Specific object or sign area: In some scenarios, specific objects (such as dangerous goods and sensitive signs) will be identified and marked as ROI to ensure monitoring and recording of these objects.
[0033] YOLO (You Only Look Once) model: An object detection model. Unlike traditional two-stage detection (such as the R-CNN series), YOLO does not generate a large number of candidate regions before performing object detection. Instead, it divides the input image into multiple fixed-size grids, each of which is responsible for predicting the bounding box and class probability of the object it contains. This grid-based detection approach enables YOLO to handle objects of varying scales and positions without relying on complex region proposal mechanisms. The predicted bounding box information for each grid includes the coordinates of the center point, the width and height of the bounding box, and whether the bounding box contains the object and the probability of belonging to the specified class. By simultaneously optimizing these outputs during training, YOLO can achieve the dual tasks of object localization and classification with a single network architecture, greatly simplifying the detection process and improving computational efficiency. The YOLO model is particularly widely used in video surveillance and intelligent security. It can quickly and accurately identify and locate key objects in videos, such as pedestrians, vehicles, abnormal behavior, or specific objects, supporting functions such as video analysis, behavior recognition, and security warnings. YOLO's real-time detection capabilities and high accuracy make it ideal for processing large amounts of video data, especially in latency-sensitive scenarios requiring instantaneous response, such as intelligent transportation systems, crowd monitoring, and security monitoring in automated production environments. By combining the intelligent analysis capabilities of deep learning, YOLO provides an efficient and accurate object detection solution for video surveillance systems, significantly improving the efficiency and value of video data analysis.
[0034] With the widespread adoption of video surveillance systems, the amount of video data has increased dramatically, posing significant challenges to storage and management. Traditional video compression and storage methods rely on indiscriminate compression. While this reduces storage space, it fails to distinguish between critical and non-critical information within the video. Consequently, critical information may be lost due to overcompression, while non-critical information consumes excessive storage resources. This makes it difficult to achieve efficient compression while maintaining video quality. This is particularly true in the field of video surveillance, where critical information such as faces, license plates, and unusual behavior are considered critical, while background images without any objects are considered non-critical. Using indiscriminate compression can blur information such as faces, rendering them meaningless for surveillance.
[0035] In order to solve the above problems, relevant solutions are provided in the embodiments of the present application, which are described in detail below.
[0036] According to an embodiment of the present application, a method embodiment of a video compression method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG1 shows a hardware structure block diagram of a computer terminal for implementing a video compression method. Figure 1 As shown, the computer terminal 10 may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0038] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10. As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the video compression method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned video compression method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0040] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0041] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .
[0042] In the above operating environment, the embodiment of the present application provides a video compression method, such as Figure 2 As shown, the method includes the following steps:
[0043] Step S202 : determining a first region and a second region in each frame of the target video, wherein the first region is a region including the detection target.
[0044] Optionally, before determining the first area and the second area in each frame of the target video, the method further includes preprocessing the video data collected in real time by the video surveillance system, including denoising, resolution adjustment and frame rate standardization.
[0045] In the technical solution provided in step S202, determining the first area and the second area in each frame of the target video includes: determining a target bounding box in the video image, wherein the target bounding box is a bounding box containing the detected target; determining the first area in the video image based on the target bounding box; and determining an area in the video image other than the first area as the second area.
[0046] Optionally, determining the first region and the second region in each frame of the target video includes analyzing the video frames using the deep learning model YOLO to identify key information (such as faces, license plates, abnormal behavior, etc.) (i.e., the first region). YOLO (You Only Look Once) is a real-time object detection algorithm based on deep learning. Its core concept is to transform the object detection problem into a regression problem, and the location and category of the target can be predicted through a single forward propagation.
[0047] The loss function of the YOLO model consists of the following parts:
[0048] Bounding box coordinate loss:
[0049]
[0050] Confidence loss:
[0051]
[0052] Class probability loss:
[0053]
[0054] The final loss function is:
[0055] L=L coord +L conf +L class
[0056] Among them, S 2 represents the number of cells into which the image is divided, B represents the number of bounding boxes predicted for each cell, Indicates whether the j-th bounding box in the i-th cell contains an object, Indicates whether the jth bounding box in the i-th cell does not contain an object, λ coord Is the adjustment factor, which is a constant greater than 1, used to increase the weight of position and size loss, λ noobjIs an adjustment factor, a constant less than 1, used to reduce the weight of the confidence loss of the bounding box that does not contain the object, (x i ,y i ) is the center coordinate of the bounding box, is the predicted bounding box center coordinate, To predict the bounding box width, To predict the bounding box height, C i represents the true confidence of the target, Represents the prediction confidence of the target, P(c i ) is the true probability distribution of the target category in the bounding box, is the predicted probability distribution of the target category in the bounding box.
[0057] As an optional implementation, determining a target bounding box in a video image includes: dividing the video image into multiple grids; for each grid in the multiple grids, determining a predicted bounding box corresponding to each grid, as well as a confidence and prediction value of the predicted bounding box, wherein the confidence is used to reflect the probability that the predicted bounding box contains the detected target, and the prediction value includes a category probability prediction value, which is used to reflect the probability that the predicted bounding box is a preset bounding box category, and different preset bounding box categories correspond to different detection target categories; the predicted bounding box is screened according to the confidence and prediction value to obtain the target bounding box.
[0058] Optionally, determining the target bounding box in the video image includes dividing the input image into an S×S grid, inputting the grid into the YOLO model, and the model predicting B bounding boxes in each grid (i.e., predicted bounding boxes). Each bounding box contains the following information: the center coordinates (x, y) of the bounding box, the width w and height h of the bounding box, the confidence C of the bounding box (indicating the probability that the bounding box contains the target), and the category probability P(c) (indicating the probability that the bounding box belongs to a certain target category). For each bounding box, the prediction result of the YOLO model can be expressed as:
[0059] Prediction value = [x,y,w,h,C,P(c1),P(c2),…,P(c n )],
[0060] Among them, the confidence C output by the YOLO model can be expressed as:
[0061] C=P(object)×IoU
[0062] The confidence P(c i ) can be expressed as:
[0063] P(c i )=P(c i |object)×P(object)
[0064] Among them, P(object) indicates whether the grid contains the target (the value is 0 (i.e., it does not contain the target) or 1 (i.e., it contains the target)), and IoU is the intersection over union ratio of the predicted bounding box and the true bounding box. The true bounding box includes the predicted bounding box with the highest confidence.
[0065] Optionally, filtering the predicted bounding boxes based on the confidence and the predicted value to obtain the target bounding box includes: filtering the predicted bounding boxes based on the confidence and the predicted value to obtain a set of candidate bounding boxes; determining the degree of overlap between each bounding box in the set of candidate bounding boxes and a reference bounding box, wherein the reference bounding box is the predicted bounding box with the highest confidence; and removing bounding boxes in the set of candidate bounding boxes other than the reference bounding box whose degree of overlap is greater than a preset threshold to obtain the target bounding box.
[0066] Optionally, the predicted bounding boxes are screened based on the confidence and prediction values to obtain a set of candidate bounding boxes, including: After obtaining the category probability value of each bounding box, it is normalized by the Softmax function. The Softmax function converts all category probability values of the bounding box into values between 0 and 1, and ensures that the sum of these values is equal to 1. In this way, the category probability of each bounding box becomes a normalized probability distribution, which is convenient for subsequent category decisions. In YOLO, the confidence C and category probability P(c n ) jointly determine the validity and category affiliation of the bounding box. The confidence C reflects the probability of the existence of an object in the bounding box and the degree of match between the predicted box and the true box, while the category probability indicates the specific category information. Only when the confidence of the bounding box is higher than a certain threshold and the category probability indicates that the bounding box contains a specific object with a high probability (that is, there is a normalized category probability greater than the preset probability threshold), the bounding box will be considered a valid detection result and added to the candidate bounding boxes.
[0067] Optionally, non-maximum suppression is performed on the filtered bounding boxes to remove alternative bounding boxes with a high degree of overlap with the reference bounding box (i.e., the overlap is greater than a preset threshold), and the optimal detection results are retained. Among the multiple bounding boxes output by the model, there may be some overlapping bounding boxes, especially multiple predicted bounding boxes of the same type. At this time, the category probability can help the NMS (non-maximum suppression) algorithm make a decision, retaining the bounding boxes with the highest category probability and confidence, and removing the bounding boxes with an overlap greater than a preset threshold and a lower confidence, to ensure that each target is marked only once.
[0068] Step S204: determining feature information of the first region and position information of the first region in the video image.
[0069] Optionally, the feature information includes at least one of the following: detection target type, texture feature, color feature, motion feature.
[0070] Optionally, the detected target (i.e., the first area) is marked and classified, such as a face, a license plate, abnormal behavior, etc. (i.e., the target type is detected). The target's content feature values (texture features, color features, motion features) and location information (bounding box coordinates) are extracted.
[0071] Step S206: Apply a first compression algorithm to the first region to obtain a first compressed code stream, and apply a second compression algorithm to the second region to obtain a second compressed code stream, wherein the compression ratio of the second compressed code stream is higher than the compression ratio of the first compressed code stream.
[0072] Optionally, a high-fidelity compression algorithm based on wavelet transform (i.e., the first compression algorithm) is used for the ROI key region (i.e., the first region) to ensure the integrity and clarity of key information. For the non-ROI key region (i.e., the second region), a common compression algorithm with a high compression ratio (i.e., the second compression algorithm, such as H.265) is used to save storage space.
[0073] Optionally, H.265 high compression ratio encoding is performed on the non-ROI area, and inter-frame prediction and transform coding techniques are used for efficient compression. The compression ratio is:
[0074] (For example, it can be 1:50)
[0075] In the technical solution provided in step S206, the first compression algorithm is used to obtain the first compressed code stream on the first area, including: performing wavelet transform processing on the first area to obtain a first component and a second component of the first area, wherein the frequency of the first component is higher than the frequency of the second component, and the first component is used to reflect the detailed feature information of the first area; performing quantization compression processing on the second component to obtain a quantization compression result; and determining the first compressed code stream based on the first component and the quantization compression result.
[0076] Optionally, wavelet transform is performed on the ROI area to extract high-frequency and low-frequency components, retain the high-frequency component (i.e., the first component, including detail information), and quantize and compress the low-frequency component (the second component). The wavelet transform formula is as follows:
[0077] C=DWT(I ROI )
[0078] Among them, DWT represents discrete wavelet transform, I ROI is the image data of the ROI area. The compression ratio is:
[0079] (For example, it can be 1:5)
[0080] Optionally, the compression effect is evaluated by the peak signal-to-noise ratio (PSNR). PSNR is used to evaluate the quality of the compressed image and is calculated as follows:
[0081]
[0082] Among them MAX i is the maximum pixel value of the image, MSE is the mean square error, and when PSNR is greater than the preset threshold, the subsequent component merging process is performed.
[0083] As an optional implementation, determining the first compressed code stream based on the first component and the quantization compression result includes: combining the first component and the quantization compression result to obtain the first compressed code stream; or, compressing the first component using lossless coding compression to obtain a lossless compression result; combining the lossless compression result and the quantization compression result to obtain the first compressed code stream.
[0084] Step S208 : Integrate the first compressed code stream and the second compressed code stream into a frame code stream, and store the frame code stream, feature information, and position information into a storage space.
[0085] Optionally, the compressed code stream of the ROI region (first compressed code stream) and the compressed code stream of the non-ROI region (second compressed code stream) are integrated to form a unified frame code stream. The integrated frame code stream and metadata (content feature values and location data of the extracted target) are uploaded to cloud storage (i.e., storage space) for subsequent retrieval and use.
[0086] Alternatively, in the daily operation of a video surveillance system, the subsequent retrieval and use of intelligently compressed video data is a critical operation. This process is particularly important when the system needs to retrieve details of a specific event or activity, such as a suspected intrusion during surveillance. A specific example is as follows:
[0087] First, the system receives a search request, which may include multiple criteria, such as the event date, time, and a specific ROI type (e.g., "face" or "license plate"). Based on these criteria, the system queries the cloud storage for metadata, which is stored in a structured form and includes, but is not limited to, the target's content features (e.g., color, texture, motion characteristics) and location data (e.g., bounding box coordinates). Through an efficient data retrieval mechanism, the system quickly locates the metadata record corresponding to the video frame that matches the query criteria.
[0088] The system then downloads the corresponding frame stream from cloud storage based on metadata information, such as timestamps and location coordinates. The frame stream contains compressed streams for both the ROI and non-ROI regions, which are combined during upload and stored as complete frames. The download process supports data transmission optimization techniques, such as segmented downloading and parallel processing, to quickly obtain the required video data.
[0089] The system then begins the decoding process, first performing high-fidelity decoding on the compressed bitstream in the ROI area (the first compressed bitstream), using decoding techniques tailored to the compression process, such as wavelet transform-based decoding, to ensure that details in key areas are fully restored. Simultaneously, the compressed bitstream in the non-ROI area (the second compressed bitstream) is decoded in a standard manner, using a fast decoding algorithm, such as the H.265 decoder, to save decoding time and computing resources.
[0090] After decoding, the system reassembles the images from the ROI and non-ROI regions into a complete video frame. This step ensures video continuity and integrity. The reassembled video frames are presented to the user or fed into analysis software for visual inspection or in-depth analysis of the event. For example, event analysis software can leverage the high-definition decoded ROI region to identify unusual behavior, such as intruder behavior patterns, or accurately read license plates.
[0091] Finally, based on the decoding and analysis results, the system generates a detailed report including a description of the incident, the type of ROI involved, timestamps, and location information. This information is crucial for rapid incident response, security incident investigations, and legal proceedings. Furthermore, the system dynamically optimizes the video compression algorithm based on the analysis results, using machine learning to adjust the compression ratio between ROI and non-ROI areas to achieve a better balance between storage efficiency and image quality.
[0092] The entire retrieval and utilization process fully utilizes the advantages brought by intelligent analysis and differentiated compression, which not only improves the storage efficiency of video data, but also maintains the integrity and clarity of key information, providing strong support for the efficient operation of the video surveillance system and event analysis.
[0093] The embodiment of the present application provides a video compression method, such as Figure 3 As shown, the method includes the following steps:
[0094] Step S301: Video acquisition and preprocessing: Collect surveillance video data and use the video frames as input images, adjusting the resolution to the input size required by the YOLO model (e.g., 416x416).
[0095] Step S302: Intelligent Analysis and ROI Key Information Identification and Marking: Analyze the video frames using the deep learning model YOLO to identify key ROI regions (such as faces, license plates, abnormal behavior, etc.). Mark and classify the identified ROI key regions, and extract their content feature values (such as texture, color, motion features) and location data (such as bounding box coordinates). Figure 4 The specific process of key information identification and labeling through the deep learning model YOLO is shown, as shown in Figure 4 As shown, the process includes the following steps:
[0096] Step S401: Video frame input and preprocessing: Use the video frame as the input image and adjust the resolution to the input size required by the YOLO model (e.g., 416x416).
[0097] Step S402: Target detection: Use the pre-trained YOLO model to perform forward propagation on the video frame to obtain the prediction result of each grid; according to the confidence C and category probability P(c i ) Filter out bounding boxes with higher confidence.
[0098] Step 403: Non-maximum suppression (NMS): Perform non-maximum suppression on the selected bounding boxes to remove bounding boxes with high overlap and retain the best detection results.
[0099] Step 404: Key Information Labeling and Classification: Label and classify the detected targets, such as faces, license plates, abnormal behaviors, etc. Extract the target's content feature values (texture, color, motion features) and location data (bounding box coordinates).
[0100] Step S303: Differential compression: A high-fidelity compression algorithm based on wavelet transform is used for the key ROI area to ensure the integrity and clarity of key information. For non-key ROI areas, a common compression algorithm with a high compression ratio (such as H.265) is used to save storage space. Figure 5 A schematic diagram of regional compression is shown, such as Figure 5 As shown, by compressing ROI key information with high fidelity and non-key information with high efficiency, regional compression is achieved, thereby minimizing the amount of data and improving storage efficiency while retaining key information.
[0101] Step S304: Data integration and storage: integrating the compressed code streams of the ROI area and the non-ROI area into a unified frame code stream, and uploading the integrated frame code stream together with the content feature value and position data to the cloud storage system for rapid positioning during subsequent retrieval.
[0102] Through the above steps, a video region compression method based on intelligent analysis can be implemented. Through intelligent analysis, ROI key information in the video can be identified, and differentiated compression algorithms can be used for ROI key information and non-ROI key information. This ensures the integrity and clarity of key information while significantly reducing the demand for cloud storage space. Specifically, the method embodiment of the present application has the following advantages:
[0103] (1) Intelligent analysis: Use the YOLO model to accurately identify key information and ROI areas to ensure that important content is not lost.
[0104] (2) Differentiated compression: A high-fidelity compression algorithm is used for the ROI area to ensure the integrity and clarity of key information; a high compression ratio algorithm is used for the non-ROI area to significantly reduce storage space requirements.
[0105] (3) Efficient retrieval: Rapid positioning and extraction of key video frames are achieved through labeling information and ROI position data.
[0106] (4) Wide range of applications: The method embodiments of the present application are applicable to a variety of video surveillance scenarios, especially in scenarios that require efficient storage and rapid retrieval of key information. Applicable scenarios include but are not limited to:
[0107] Large-scale public safety monitoring systems: such as traffic monitoring and urban security, require monitoring and saving large amounts of video data.
[0108] Enterprise-level video surveillance systems: such as factories, warehouses, offices, etc., used to ensure property safety and employee safety.
[0109] Educational and medical institutions: Ensure the long-term stability of surveillance videos to facilitate accident tracing and responsibility determination.
[0110] Smart home system: Improve the reliability of home security monitoring.
[0111] Any other video surveillance application that requires long-term storage and guaranteed data integrity.
[0112] In the above scenarios, the long-term preservation of video surveillance recordings directly affects the effectiveness of the monitoring system and the accuracy of subsequent event analysis. Therefore, it is particularly important to clearly preserve the video files. The method embodiments of the present application can improve video storage efficiency, reduce storage costs, and at the same time ensure the high fidelity of video data, thereby improving the practicality and economy of the video surveillance system.
[0113] The embodiment of the present application provides a video compression device, Figure 6 is a structural diagram of the device, such as Figure 6As shown, the device includes: a first processing module 60, used to determine a first area and a second area in each frame video image of the target video, wherein the first area is the area containing the detection target; a second processing module 62, used to determine feature information of the first area and position information of the first area in the video image; a third processing module 64, used to apply a first compression algorithm to the first area to obtain a first compressed code stream, and apply a second compression algorithm to the second area to obtain a second compressed code stream, wherein the compression ratio of the second compressed code stream is higher than the compression ratio of the first compressed code stream; a fourth processing module 66, used to integrate the first compressed code stream and the second compressed code stream into a frame code stream, and store the frame code stream, feature information and position information in a storage space.
[0114] In some embodiments of the present application, the third processing module 64 uses the first compression algorithm to obtain the first compressed code stream on the first area, including: performing wavelet transform processing on the first area to obtain the first component and the second component of the first area, wherein the frequency of the first component is higher than the frequency of the second component, and the first component is used to reflect the detailed feature information of the first area; performing quantization compression processing on the second component to obtain a quantization compression result; and determining the first compressed code stream based on the first component and the quantization compression result.
[0115] In some embodiments of the present application, the third processing module 64 determines the first compressed code stream based on the first component and the quantization compression result, including: merging the first component and the quantization compression result to obtain the first compressed code stream; or, compressing the first component using lossless coding compression to obtain a lossless compression result; merging the lossless compression result and the quantization compression result to obtain the first compressed code stream.
[0116] In some embodiments of the present application, the first processing module 60 determines the first area and the second area in each frame of the target video, including: determining a target bounding box in the video image, wherein the target bounding box is a bounding box containing the detected target; determining the first area in the video image based on the target bounding box; and determining the area in the video image other than the first area as the second area.
[0117] In some embodiments of the present application, the first processing module 60 determines the target bounding box in the video image, including: dividing the video image into multiple grids; for each grid in the multiple grids, determining the predicted bounding box corresponding to each grid, as well as the confidence and prediction value of the predicted bounding box, wherein the confidence is used to reflect the probability that the predicted bounding box contains the detected target, and the prediction value includes a category probability prediction value, which is used to reflect the probability that the predicted bounding box is a preset bounding box category, and different preset bounding box categories correspond to different detection target categories; the predicted bounding box is screened according to the confidence and prediction value to obtain the target bounding box.
[0118] In some embodiments of the present application, the first processing module 60 filters the predicted bounding boxes based on the confidence level and the predicted value to obtain the target bounding box, including: filtering the predicted bounding boxes based on the confidence level and the predicted value to obtain a set of candidate bounding boxes; determining the overlap between each bounding box in the set of candidate bounding boxes and the reference bounding box, wherein the reference bounding box is the predicted bounding box with the highest confidence level; and removing the bounding boxes in the set of candidate bounding boxes, except for the reference bounding box, whose overlap is greater than a preset threshold, to obtain the target bounding box.
[0119] In some embodiments of the present application, the feature information includes at least one of the following: detection target type, texture feature, color feature, and motion feature.
[0120] It should be noted that the various modules in the above-mentioned video compression device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0121] An embodiment of the present application provides a non-volatile storage medium, in which a program is stored. When the program is running, the device where the non-volatile storage medium is located is controlled to execute the following video compression method: determining a first area and a second area in each frame video image of a target video, wherein the first area is an area containing a detection target; determining feature information of the first area and position information of the first area in the video image; applying a first compression algorithm to the first area to obtain a first compressed code stream, and applying a second compression algorithm to the second area to obtain a second compressed code stream, wherein the compression ratio of the second compressed code stream is higher than the compression ratio of the first compressed code stream; integrating the first compressed code stream and the second compressed code stream into a frame code stream, and storing the frame code stream, feature information and position information in a storage space.
[0122] An embodiment of the present application provides an electronic device, comprising: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the program, when running, executes the following video compression method: determining a first region and a second region in each frame of a target video, wherein the first region is a region containing a detection target; determining feature information of the first region and position information of the first region in the video image; applying a first compression algorithm to the first region to obtain a first compressed code stream, and applying a second compression algorithm to the second region to obtain a second compressed code stream, wherein a compression ratio of the second compressed code stream is higher than a compression ratio of the first compressed code stream; integrating the first compressed code stream and the second compressed code stream into a frame code stream, and storing the frame code stream, the feature information, and the position information in a storage space.
[0123] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the following video compression method: determining a first area and a second area in each frame of a target video, wherein the first area is an area containing a detection target; determining feature information of the first area and position information of the first area in the video image; applying a first compression algorithm to the first area to obtain a first compressed code stream, and applying a second compression algorithm to the second area to obtain a second compressed code stream, wherein a compression ratio of the second compressed code stream is higher than a compression ratio of the first compressed code stream; integrating the first compressed code stream and the second compressed code stream into a frame code stream, and storing the frame code stream, feature information, and position information in a storage space.
[0124] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0125] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0126] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0127] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0128] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0129] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A video compression method, characterized in that: include: Determining a first area and a second area in each frame of the target video, wherein the first area is an area containing the detection target; determining feature information of the first region and position information of the first region in the video image; Applying a first compression algorithm to the first region to obtain a first compressed code stream, and applying a second compression algorithm to the second region to obtain a second compressed code stream, wherein a compression ratio of the second compressed code stream is higher than a compression ratio of the first compressed code stream; The first compressed code stream and the second compressed code stream are integrated into a frame code stream, and the frame code stream, the feature information and the position information are stored in a storage space.
2. The video compression method according to claim 1, wherein: Applying a first compression algorithm to the first region to obtain a first compressed code stream includes: Performing wavelet transform processing on the first region to obtain a first component and a second component of the first region, wherein a frequency of the first component is higher than a frequency of the second component, and the first component is used to reflect detailed feature information of the first region; performing quantization compression processing on the second component to obtain a quantization compression result; The first compressed code stream is determined according to the first component and the quantization compression result.
3. The video compression method according to claim 2, wherein: Determining the first compressed code stream according to the first component and the quantization compression result includes: Combining the first component and the quantization compression result to obtain the first compressed code stream; or, compressing the first component by using a lossless coding compression method to obtain a lossless compression result; The lossless compression result and the quantized compression result are combined to obtain the first compressed code stream.
4. The video compression method according to claim 1, wherein: Determining the first area and the second area in each frame of the target video includes: Determining a target bounding box in the video image, wherein the target bounding box is a bounding box containing the detected target; determining the first area in the video image according to the target bounding box; An area in the video image other than the first area is determined as the second area.
5. The video compression method according to claim 4, wherein: Determining a target bounding box in the video image includes: Dividing the video image into a plurality of grids; For each of the plurality of grids, determining a predicted bounding box corresponding to each grid, as well as a confidence score and a predicted value of the predicted bounding box, wherein the confidence score is used to reflect the probability that the predicted bounding box contains the detected target, and the predicted value includes a category probability prediction value, which is used to reflect the probability that the predicted bounding box is a preset bounding box category, and different preset bounding box categories correspond to different detected target categories; The predicted bounding box is filtered according to the confidence level and the predicted value to obtain the target bounding box.
6. The video compression method according to claim 5, wherein: The predicted bounding box is screened according to the confidence level and the predicted value to obtain the target bounding box, including: Filtering the predicted bounding boxes according to the confidence level and the predicted value to obtain a set of candidate bounding boxes; Determining a degree of overlap between each bounding box in the candidate bounding box set and a reference bounding box, wherein the reference bounding box is the predicted bounding box with the maximum confidence; Bounding boxes other than the reference bounding box in the candidate bounding box set and having an overlap greater than a preset threshold are removed to obtain the target bounding box.
7. The video compression method according to claim 1, wherein: The feature information includes at least one of the following: detection target type, texture feature, color feature, and motion feature.
8. A video compression device, characterized in that: include: A first processing module is configured to determine a first region and a second region in each frame of a target video, wherein the first region is a region including a detection target; a second processing module, configured to determine feature information of the first region and position information of the first region in the video image; a third processing module, configured to apply a first compression algorithm to the first region to obtain a first compressed code stream, and apply a second compression algorithm to the second region to obtain a second compressed code stream, wherein a compression ratio of the second compressed code stream is higher than a compression ratio of the first compressed code stream; The fourth processing module is configured to integrate the first compressed code stream and the second compressed code stream into a frame code stream, and store the frame code stream, the feature information, and the position information in a storage space.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the video compression method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the video compression method according to any one of claims 1 to 7 is executed when the program is run.
11. A computer program product, characterized in that The computer program comprises a computer program which, when executed by a processor, implements the video compression method according to any one of claims 1 to 7.