A method and device for processing video data
By grayscale and encoding value processing of video frames, minor modifications to the video content are achieved, which solves the problems of complex processing and high computational overhead in the existing technology, protects user privacy and prevents illegal AI identification, and achieves real-time processing and low cost. Overhead video privacy protection.
Patent Information
- Application Number
- CN202110009538.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-05
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-01-05
AI Technical Summary
Existing video processing methods have problems such as complex processing and high computational overhead, making it difficult to effectively protect user privacy and prevent illegal AI identification.
By grayscaleing the video frame to be processed, calculating the encoding value, and processing the pixels in the video frame according to the encoding value, the encoded video is synthesized, achieving minor modifications to the video content, and masking the recognition ability of the AI.
Without affecting the distortion of video content, it protects user privacy, prevents leakage of user information, simplifies the processing process, reduces computing overhead, and can process in real time to avoid illegal AI identification.
Smart Images

Figure CN113766273B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video processing technology, and in particular to a method and device for processing video data. Background Art
[0002] With the development of science and technology, Internet services are increasingly integrated into people's lives, replacing many traditional operating methods. Internet applications and small programs have become indispensable tools in people's lives and work. More and more users share photos or videos of their lives on short videos, microblogs and other applications, or when handling online business, when it comes to important business such as money and health, financial institutions, medical institutions, etc. passively collect user information through video methods such as liveness detection.
[0003] If hacked or a security hole is implanted in the user terminal application, the video data will be leaked, which will lead to the leakage of user image information. Criminals will use this user image information to train a face model for user identity verification. Therefore, video data needs to be processed to protect user privacy.
[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0005] Existing video processing methods have technical problems such as complex processing and high computational overhead. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a method and apparatus for processing video data to solve the technical problems of complex processing and high computational overhead.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for processing video data is provided, comprising:
[0008] Obtain a video frame to be processed from the video to be processed;
[0009] Gray-scaling the video frame to be processed to obtain a grayscale histogram;
[0010] Calculating the encoding value of the video frame to be processed according to the grayscale histogram;
[0011] Processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, so as to obtain an encoded video frame;
[0012] The to-be-processed video frame is replaced by the encoded video frame, thereby synthesizing an encoded video.
[0013] Optionally, graying the video frame to be processed to obtain a grayscale histogram includes:
[0014] Gray-scaling the video frame to be processed to obtain a first gray-scale histogram;
[0015] According to a preset color interval step, the color intervals of the first grayscale histogram are merged to obtain a second grayscale histogram.
[0016] Optionally, the abscissa of the first grayscale histogram consists of 256 color intervals, the abscissa of the second grayscale histogram consists of 8 color intervals, and the color interval step is 32.
[0017] Optionally, calculating the encoding value of the to-be-processed video frame according to the grayscale histogram includes:
[0018] Calculating the median color interval of the grayscale histogram;
[0019] The encoding value of the video frame to be processed is calculated according to the grayscale histogram and the median color interval.
[0020] Optionally, calculating the median color interval of the grayscale histogram includes:
[0021] Calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels;
[0022] The median color interval to which the median of the total number of pixels belongs is found from the grayscale histogram.
[0023] Optionally, calculating the encoding value of the to-be-processed video frame according to the grayscale histogram and the median color interval includes:
[0024] Compare the number of pixels corresponding to each color interval of the grayscale histogram with the number of pixels corresponding to the median color interval;
[0025] According to the comparison result, a binary string of the grayscale histogram is obtained; wherein the comparison result is distinguished by 0 and 1;
[0026] According to the binary string, a coding value of the video frame to be processed is calculated.
[0027] Optionally, according to the comparison result, a binary string of the grayscale histogram is obtained, including:
[0028] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining a binary string of the grayscale histogram; or,
[0029] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining a binary string of the grayscale histogram.
[0030] Optionally, calculating the encoding value of the to-be-processed video frame according to the binary string includes:
[0031] Performing a reverse operation on the binary string to obtain a reverse binary string;
[0032] The reverse binary string is converted into a decimal string, thereby obtaining the encoding value of the video frame to be processed.
[0033] Optionally, processing each pixel in the to-be-processed video frame according to the encoding value of the to-be-processed video frame to obtain an encoded video frame includes:
[0034] For each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame;
[0035] Wherein, M is greater than zero.
[0036] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for processing video data, including:
[0037] An acquisition module, used for acquiring a video frame to be processed from the video to be processed;
[0038] A grayscale module, used for grayscale the video frame to be processed to obtain a grayscale histogram;
[0039] A calculation module, used for calculating the encoding value of the video frame to be processed according to the grayscale histogram;
[0040] An encoding module, used for processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, so as to obtain an encoded video frame;
[0041] The synthesis module is used to replace the to-be-processed video frame with the encoded video frame, thereby synthesizing the encoded video.
[0042] Optionally, the grayscale module is further used for:
[0043] Gray-scaling the video frame to be processed to obtain a first gray-scale histogram;
[0044] According to a preset color interval step, the color intervals of the first grayscale histogram are merged to obtain a second grayscale histogram.
[0045] Optionally, the abscissa of the first grayscale histogram consists of 256 color intervals, the abscissa of the second grayscale histogram consists of 8 color intervals, and the color interval step is 32.
[0046] Optionally, the calculation module is further used for:
[0047] Calculating the median color interval of the grayscale histogram;
[0048] The encoding value of the video frame to be processed is calculated according to the grayscale histogram and the median color interval.
[0049] Optionally, the calculation module is further used for:
[0050] Calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels;
[0051] The median color interval to which the median of the total number of pixels belongs is found from the grayscale histogram.
[0052] Optionally, the calculation module is further used for:
[0053] Compare the number of pixels corresponding to each color interval of the grayscale histogram with the number of pixels corresponding to the median color interval;
[0054] According to the comparison result, a binary string of the grayscale histogram is obtained; wherein the comparison result is distinguished by 0 and 1;
[0055] According to the binary string, a coding value of the video frame to be processed is calculated.
[0056] Optionally, the calculation module is further used for:
[0057] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining a binary string of the grayscale histogram; or,
[0058] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining a binary string of the grayscale histogram.
[0059] Optionally, the calculation module is further used for:
[0060] Performing a reverse operation on the binary string to obtain a reverse binary string;
[0061] The reverse binary string is converted into a decimal string, thereby obtaining the encoding value of the video frame to be processed.
[0062] Optionally, the encoding module is further used for:
[0063] For each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame;
[0064] Wherein, M is greater than zero.
[0065] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:
[0066] one or more processors;
[0067] a storage device for storing one or more programs,
[0068] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0069] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0070] One embodiment of the above invention has the following advantages or beneficial effects: because each pixel in the video frame to be processed is processed according to the coding value of the video frame to be processed, thereby synthesizing the coded video, the technical problems of complex processing and high computational overhead in the prior art are overcome. The embodiment of the present invention modifies the video content by processing the video frame at the pixel level, thereby protecting the user's privacy and preventing the user's privacy from being stolen without affecting the distortion of the video content. Moreover, the method has a simple processing process, very low computational overhead, and can be processed in real time. Therefore, the embodiment of the present invention not only does not affect the user's viewing of the video, but also deceives the illegal use of AI-related content recognition algorithms (such as face recognition, OCR recognition, action recognition, scene recognition, etc.) to parse the video content, thereby preventing the user information from being leaked.
[0071] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0073] Figure 1 is a schematic diagram of the main flow of a method for processing video data according to an embodiment of the present invention;
[0074] Figure 2 is a schematic diagram of the main flow of a method for processing video data according to a reference embodiment of the present invention;
[0075] Figure 3 is a schematic diagram of the main flow of a method for processing video data according to another reference embodiment of the present invention;
[0076] Figure 4 is a schematic diagram of main modules of an apparatus for processing video data according to an embodiment of the present invention;
[0077] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0078] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0079] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0080] At present, the processing methods of video data are mainly divided into the following categories:
[0081] 1) Use adversarial network conversion methods
[0082] Privacy protection is achieved by converting images through adversarial networks. Cycle-GAN derived from the generative adversarial network GAN is used for conversion. This method has some advantages in image style transfer. It can convert images from domain X to domain Y, and then restore them from domain Y to domain X. Structurally, one discriminator of Cycle-GAN shares two generators, and each generator has a discriminator.
[0083] 2) Methods based on video encryption
[0084] The method encrypts the video pixel value and the video content to obtain the encrypted video and the video key. The random arrangement of the generated key is generated by a pseudo-random generator that randomly arranges integers within a random seed range to generate variables.
[0085] 3) Method based on replacement processing
[0086] This method replaces the part of the video containing sensitive information, such as coding, replacing the background, replacing it with other images or other synthetic faces, etc.
[0087] The above processing method has the following main disadvantages:
[0088] 1) Using adversarial network conversion method: When the application scenario only needs to convert video frames from domain X to domain Y, there is a redundant discriminator, which will cause loss, resulting in loss rate not easy to converge, training time increased, and low generalization ability.
[0089] 2) Video encryption-based method: This method requires running all calculations on the user terminal. Since data is constantly encrypted and decrypted, it causes a lot of computing overhead. This method is too complex for applications and requires more example support and hardware support.
[0090] 3) Method based on replacement processing: This method cannot meet the purpose of using video for recognition while protecting user privacy.
[0091] In order to solve the technical problems existing in the prior art, an embodiment of the present invention provides a method for processing video data, which makes slight modifications at the pixel level on the video frame image to deceive the scrutiny of AI. In fact, for deep neural networks, some small disturbances can change the model's cognition. The embodiment of the present invention uses imperceptible slight data disturbances to process video content to protect user privacy. In this way, even if the user's video data on the Internet is illegally captured, the face model trained with this data cannot successfully identify the user's identity.
[0092] Figure 1 FIG. 1 is a schematic diagram of the main flow of a method for processing video data according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for processing video data may include:
[0093] Step 101: Obtain a video frame to be processed from a video to be processed.
[0094] A frame capture tool may be used to capture at least one video frame from the video to be processed as the video frame to be processed. Optionally, the video frame capture may be performed with equal step lengths to obtain multiple video frames, which constitute a video frame sequence. The step size may be set according to actual needs, and the embodiment of the present invention does not limit this.
[0095] Step 102: grayscale the video frame to be processed to obtain a grayscale histogram.
[0096] For each frame of the video to be processed obtained from the video to be processed, steps 102-105 are performed. Specifically, in step 102, for each frame of the video to be processed, the video frame to be processed is grayed to obtain a grayscale histogram of the video frame to be processed, which is the basis for subsequent processing of each video frame to be processed.
[0097] Optionally, step 102 may include: graying the video frame to be processed to obtain a first grayscale histogram; merging the color intervals of the first grayscale histogram according to a preset color interval step to obtain a second grayscale histogram. Optionally, the abscissa of the first grayscale histogram consists of 256 color intervals, and the abscissa of the second grayscale histogram consists of 8 color intervals, and the color interval step is 32. In an embodiment of the present invention, the grayscale formula can be used to grayscale the video frame to be processed to obtain a first grayscale histogram (i.e., a 256-bin grayscale histogram, with the abscissa taking an integer of [0, 255]), and then bin merging the first grayscale histogram with a step of 32 to obtain a second grayscale histogram (i.e., an 8-bin grayscale histogram). The horizontal axis of the 8-bin grayscale histogram includes eight bins, namely: [0, 31], [32, 63], [64, 95], [96, 127], [128, 159], [150, 191], [192, 223], and [224, 255].
[0098] The embodiment of the present invention combines the 256-bin grayscale histogram into an 8-bin grayscale histogram, which is to facilitate the use of eight-bit binary numbers to represent the grayscale histogram of the video frame to be processed, so as to calculate the encoding value based on the eight-bit binary number. Therefore, after the processing of step 102, each video frame to be processed can obtain an 8-bin grayscale histogram.
[0099] Step 103: Calculate the encoding value of the to-be-processed video frame according to the grayscale histogram.
[0100] After obtaining the grayscale histogram of the video frame to be processed, the encoding value of the video frame to be processed is calculated according to the grayscale histogram. Optionally, step 103 may include: calculating the median color interval of the grayscale histogram; and calculating the encoding value of the video frame to be processed according to the grayscale histogram and the median color interval. In an embodiment of the present invention, the median bin of the grayscale histogram is first calculated according to the grayscale histogram of the video frame to be processed, and then the encoding value of the video frame to be processed is calculated according to the grayscale histogram and the median bin.
[0101] Optionally, calculating the median color interval of the grayscale histogram includes: calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels; and finding the median color interval to which the median of the total number of pixels belongs from the grayscale histogram. For example, the ordinate value of the 8-bin grayscale histogram (indicating the number of pixels corresponding to each color interval) is [10, 20, 20, 10, 10, 10, 20, 0], then the total number of pixels of the video frame to be processed is 10+20+20+10+10+10+20+0=100, and the median of the total number of pixels is 50 (it can also be 51, which is not limited in the embodiment of the present invention). Since the color interval to which the 50th pixel belongs is the third in the sequence (i.e., the color interval corresponding to 20), [64, 95] is used as the median color interval.
[0102] It should be noted that if the median of the total number of pixels is 51, since the color interval to which the 50th pixel belongs is the fourth in the sequence (ie, the color interval corresponding to 10), [96, 127] is taken as the median color interval.
[0103] Optionally, the coding value of the video frame to be processed is calculated according to the grayscale histogram and the median color interval, including: comparing the number of pixels corresponding to each color interval of the grayscale histogram with the number of pixels corresponding to the median color interval; obtaining a binary string of the grayscale histogram according to the comparison result; wherein the comparison result is distinguished by 0 and 1; and calculating the coding value of the video frame to be processed according to the binary string. After determining the median bin in the grayscale histogram, the number of pixels corresponding to each bin in the grayscale histogram (i.e., the vertical coordinate value of the grayscale histogram) is compared with the number of pixels corresponding to the median bin, and then an eight-bit binary string is obtained according to the comparison result. Since the grayscale histogram is 8bin, an eight-bit binary string can be obtained, which is convenient for converting the binary string into a decimal coding value.
[0104] Optionally, based on the comparison result, a binary string of the grayscale histogram is obtained, including: for each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining the binary string of the grayscale histogram; or, for each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining the binary string of the grayscale histogram.
[0105] For example, the ordinate values of the 8-bin grayscale histogram are [10, 20, 20, 10, 10, 10, 20, 0], and [64, 95] is the median bin. Then, by comparing the number of pixels corresponding to each bin in the sequence with the number of pixels corresponding to [64, 95], we can get [0, 1, 1, 0, 0, 0, 1, 0], and the resulting binary string is 01100010.
[0106] Optionally, according to the binary string, the encoding value of the video frame to be processed is calculated, including: reversing the binary string to obtain a reversed binary string; converting the reversed binary string into a decimal string, thereby obtaining the encoding value of the video frame to be processed. The eight-bit binary string is converted into a decimal string to obtain an encoding value in the range of 0 to 255. Since the horizontal axis values of the grayscale histogram increase in order from left to right, which is opposite to the carry order of the binary number, it is necessary to reverse the binary string so that the sorting direction of the horizontal axis values of the grayscale histogram is the same as the sorting direction of the binary number.
[0107] For example, a reverse operation is performed on the binary string 01100010 to obtain a reverse binary string 01000110, which is converted into a decimal string 70, and 70 is the encoding value of the video frame to be processed.
[0108] Step 104 : Process each pixel in the video frame to be processed according to the coding value of the video frame to be processed, so as to obtain a coded video frame.
[0109] After calculating the coding value of the video frame to be processed, each pixel in the video frame to be processed is processed according to the coding value, so as to obtain a processed coded video frame. In fact, this step is to perform pixel-level coding processing on the video frame to be processed, so as to protect user privacy.
[0110] Optionally, step 104 may include: for each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame; wherein M is greater than zero. The embodiment of the present invention performs pixel-level micro-modification on the video frame to be processed according to the encoding value of the video frame to be processed, which can not only prevent illegal AI recognition, but also does not affect the user's viewing of the video. The recognition ability of AI recognition for artificially modified pictures or videos is basically 0, because the generalization ability of its trained model to a certain extent follows a certain regular distribution, and after pixel-level re-encoding, the unknown distribution of pictures or videos makes the AI recognition ability disordered, and obtains erroneous recognition results, thereby achieving the purpose of protecting user privacy and preventing illegal AI recognition.
[0111] Optionally, the value of M can be between 1-3 to avoid the processed video affecting the user's viewing. For example, for each channel of each pixel in the video frame to be processed (each pixel generally has three channels of RGB), if the pixel value of the channel is less than the encoding value, the pixel value of the channel is subtracted by 1 (if the pixel value of the channel is 0, no processing is performed), and if the pixel value of the channel is greater than or equal to the encoding value, the pixel value of the channel is added by 1 (if the pixel value of the channel is 255, no processing is performed). Since the pixel values of the video frame are 0-255, after pixel-level encoding according to the above method, it does not affect the user's viewing, and it can also prevent illegal AI recognition and theft of user privacy. In fact, step 104 is to perform unsmoothing processing on the video frame to be processed, so that the pixels change from smooth to unsmooth, which can reduce the recognition ability of AI.
[0112] Step 105: Replace the to-be-processed video frame with the encoded video frame, thereby synthesizing an encoded video.
[0113] After processing each to-be-processed video frame, the coded video frames corresponding to each to-be-processed video frame are obtained respectively, and then the corresponding to-be-processed video frames are replaced with the coded video frames respectively, so as to obtain the coded video frames, that is, the processed video.
[0114] According to the various embodiments described above, it can be seen that the embodiments of the present invention solve the technical problems of complex processing and high computational overhead in the prior art by processing each pixel in the video frame to be processed according to the coding value of the video frame to be processed, thereby synthesizing the coded video. The embodiments of the present invention modify the video content by processing the video frame at the pixel level, thereby protecting the user's privacy and preventing the user's privacy from being stolen without affecting the distortion of the video content. Moreover, the method has a simple processing process, very low computational overhead, and can be processed in real time. Therefore, the embodiments of the present invention will not only not affect the user's viewing of the video, but also deceive the illegal use of AI-related content recognition algorithms (such as face recognition, OCR recognition, action recognition, scene recognition, etc.) to parse the video content, thereby preventing the user information from being leaked.
[0115] Figure 2 FIG. 1 is a schematic diagram of the main flow of a method for processing video data according to a reference embodiment of the present invention. As another embodiment of the present invention, Figure 2 As shown, the method for processing video data may include:
[0116] Step 201 : obtaining a plurality of to-be-processed video frames from the to-be-processed video according to a preset time step.
[0117] The size of the time step can be set according to actual needs, and the embodiment of the present invention does not limit this. Multiple video frames obtained from the video to be processed form a video frame sequence, and steps 202-211 are executed for each video frame to be processed.
[0118] Step 202: grayscale the video frame to be processed to obtain a 256-bin grayscale histogram.
[0119] Step 203, with a step length of 32, the 256-bin grayscale histogram is bin-merged to obtain an 8-bin grayscale histogram.
[0120] Among them, the horizontal axis of the 8-bin grayscale histogram includes eight bins, namely: [0, 31], [32, 63], [64, 95], [96, 127], [128, 159], [150, 191], [192, 223], and [224, 255].
[0121] The embodiment of the present invention combines the 256-bin grayscale histogram into an 8-bin grayscale histogram. This is to facilitate the use of eight-bit binary numbers to represent the grayscale histogram of the video frame to be processed, thereby calculating the encoding value based on the eight-bit binary number.
[0122] Step 204: calculate the total number of pixels of the to-be-processed video frame to determine the median of the total number of pixels.
[0123] Step 205: Find the median bin to which the median of the total number of pixels belongs from the 8-bin grayscale histogram.
[0124] Step 206 : Compare the number of pixels corresponding to each color interval of the 8-bin grayscale histogram with the number of pixels corresponding to the median bin.
[0125] Step 207: Obtain a binary string of the 8-bin grayscale histogram according to the comparison result.
[0126] For example, for each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median bin, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining a binary string of the grayscale histogram; or, for each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median bin, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining a binary string of the 8-bin grayscale histogram.
[0127] Step 208: Perform a reverse operation on the binary string to obtain a reverse binary string.
[0128] Step 209: convert the reverse binary string into a decimal string, thereby obtaining the encoding value of the video frame to be processed.
[0129] Step 210: Process each pixel in the video frame to be processed according to the coding value of the video frame to be processed, so as to obtain a coded video frame.
[0130] Step 211: Replace the to-be-processed video frame with the encoded video frame, thereby synthesizing an encoded video.
[0131] In addition, the specific implementation content of the method for processing video data in a reference embodiment of the present invention has been described in detail in the method for processing video data described above, so the repeated content will not be described here.
[0132] Figure 3 Schematic diagram of the main flow of a method for processing video data according to another reference embodiment of the present invention. As another embodiment of the present invention, Figure 3 As shown, the method for processing video data may include:
[0133] Step 301: Acquire multiple frames of video to be processed from the video to be processed according to a preset time step.
[0134] Step 302: grayscale the video frame to be processed to obtain a grayscale histogram.
[0135] Step 303: Calculate the encoding value of the to-be-processed video frame according to the grayscale histogram.
[0136] Step 304, for each channel of each pixel point in the video to be processed, determine whether the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed; if so, execute step 305; if not, execute step 306.
[0137] Step 305, adding M to the pixel value of the channel, where the value of M can be between 1-3.
[0138] Step 306, subtract M from the pixel value of the channel, where the value of M can be between 1-3.
[0139] Step 307: Replace the to-be-processed video frame with the encoded video frame, thereby synthesizing an encoded video.
[0140] In addition, the specific implementation content of the method for processing video data in another reference embodiment of the present invention has been described in detail in the method for processing video data described above, so the repeated content will not be described here.
[0141] Figure 4 is a schematic diagram of main modules of an apparatus for processing video data according to an embodiment of the present invention, such as Figure 4 As shown, the device 400 for processing video data includes an acquisition module 401, a grayscale module 402, a calculation module 403, a coding module 404 and a synthesis module 405; wherein the acquisition module 401 is used to obtain a video frame to be processed from the video to be processed; the grayscale module 402 is used to grayscale the video frame to be processed to obtain a grayscale histogram; the calculation module 403 is used to calculate the coding value of the video frame to be processed according to the grayscale histogram; the coding module 404 is used to process each pixel in the video frame to be processed according to the coding value of the video frame to be processed, so as to obtain a coded video frame; the synthesis module 405 is used to replace the video frame to be processed with the coded video frame, so as to synthesize the coded video.
[0142] Optionally, the grayscale module 402 is further used for:
[0143] Gray-scaling the video frame to be processed to obtain a first gray-scale histogram;
[0144] According to a preset color interval step, the color intervals of the first grayscale histogram are merged to obtain a second grayscale histogram.
[0145] Optionally, the abscissa of the first grayscale histogram consists of 256 color intervals, the abscissa of the second grayscale histogram consists of 8 color intervals, and the color interval step is 32.
[0146] Optionally, the calculation module 403 is further used for:
[0147] Calculating the median color interval of the grayscale histogram;
[0148] The encoding value of the video frame to be processed is calculated according to the grayscale histogram and the median color interval.
[0149] Optionally, the calculation module 403 is further used for:
[0150] Calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels;
[0151] The median color interval to which the median of the total number of pixels belongs is found from the grayscale histogram.
[0152] Optionally, the calculation module 403 is further used for:
[0153] Compare the number of pixels corresponding to each color interval of the grayscale histogram with the number of pixels corresponding to the median color interval;
[0154] According to the comparison result, a binary string of the grayscale histogram is obtained; wherein the comparison result is distinguished by 0 and 1;
[0155] According to the binary string, a coding value of the video frame to be processed is calculated.
[0156] Optionally, the calculation module 403 is further used for:
[0157] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining a binary string of the grayscale histogram; or,
[0158] For each color interval of the grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining a binary string of the grayscale histogram.
[0159] Optionally, the calculation module 403 is further used for:
[0160] Performing a reverse operation on the binary string to obtain a reverse binary string;
[0161] The reverse binary string is converted into a decimal string, thereby obtaining the encoding value of the video frame to be processed.
[0162] Optionally, the encoding module 404 is further used for:
[0163] For each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame;
[0164] Wherein, M is greater than zero.
[0165] According to the various embodiments described above, it can be seen that the embodiments of the present invention solve the technical problems of complex processing and high computational overhead in the prior art by processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, thereby synthesizing the encoded video. The embodiments of the present invention modify the video content by processing the video frame at the pixel level, thereby protecting the user's privacy and preventing the user's privacy from being stolen without affecting the distortion of the video content. Moreover, the processing process of the device is simple, the computational overhead is very small, and real-time processing can be performed. Therefore, the embodiments of the present invention will not only not affect the user's viewing of the video, but also deceive the illegal use of AI-related content recognition algorithms (such as face recognition, OCR recognition, action recognition, scene recognition, etc.) to parse the video content, thereby preventing the user information from being leaked.
[0166] It should be noted that the specific implementation content of the apparatus for processing video data in the present invention has been described in detail in the method for processing video data described above, so the repeated content will not be described here.
[0167] Figure 5 An exemplary system architecture 500 is shown to which the method for processing video data or the apparatus for processing video data according to the embodiments of the present invention can be applied.
[0168] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0169] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0170] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0171] Server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as item information query requests, and feed back the processing results to the terminal device.
[0172] It should be noted that the method for processing video data provided in the embodiment of the present invention is generally executed by the server 505, and accordingly, the apparatus for processing video data is generally set in the server 505. The method for processing video data provided in the embodiment of the present invention can also be executed by the terminal devices 501, 502, 503, and accordingly, the apparatus for processing video data can be set in the terminal devices 501, 502, 503.
[0173] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0174] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0175] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0176] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0177] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0178] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0179] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0180] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module, a grayscale module, a calculation module, an encoding module and a synthesis module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0181] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: obtaining a video frame to be processed from the video to be processed; graying the video frame to be processed to obtain a grayscale histogram; calculating the encoding value of the video frame to be processed according to the grayscale histogram; processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, thereby obtaining an encoded video frame; replacing the video frame to be processed with the encoded video frame, thereby synthesizing an encoded video.
[0182] According to the technical solution of the embodiment of the present invention, because each pixel in the video frame to be processed is processed according to the coding value of the video frame to be processed, thereby synthesizing the coded video, the technical problems of complex processing and high computational overhead in the prior art are overcome. The embodiment of the present invention modifies the video content by processing the video frame at the pixel level, protects the user's privacy and prevents the user's privacy from being stolen without affecting the distortion of the video content, and the method has a simple processing process, very low computational overhead, and can be processed in real time. Therefore, the embodiment of the present invention will not only not affect the user's viewing of the video, but also deceive the illegal use of AI-related content recognition algorithms (such as face recognition, OCR recognition, action recognition, scene recognition, etc.) to parse the video content, thereby preventing the user information from being leaked.
[0183] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing video data, characterized in that: include: Obtain a video frame to be processed from the video to be processed; Graying the video frame to be processed to obtain a grayscale histogram; wherein graying the video frame to be processed to obtain a grayscale histogram includes: graying the video frame to be processed to obtain a first grayscale histogram; merging the color intervals of the first grayscale histogram according to a preset color interval step to obtain a second grayscale histogram; Calculating the encoding value of the to-be-processed video frame according to the second grayscale histogram; Processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, so as to obtain an encoded video frame; Replacing the to-be-processed video frame with the encoded video frame, thereby synthesizing an encoded video; Calculating the encoding value of the to-be-processed video frame according to the second grayscale histogram includes: Calculating the median color interval of the second grayscale histogram; Calculating the encoding value of the video frame to be processed according to the second grayscale histogram and the median color interval; Calculating the encoding value of the to-be-processed video frame according to the second grayscale histogram and the median color interval includes: Compare the number of pixels corresponding to each color interval of the second grayscale histogram with the number of pixels corresponding to the median color interval; According to the comparison result, a binary string of the second grayscale histogram is obtained; wherein the comparison result is distinguished by 0 and 1; Calculating the encoding value of the video frame to be processed according to the binary string; Processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, thereby obtaining an encoded video frame, including: For each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame; Wherein, M is greater than zero; Calculating the median color interval of the second grayscale histogram includes: Calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels; The median color interval to which the median of the total number of pixels belongs is found from the second grayscale histogram.
2. The method according to claim 1, characterized in that: The abscissa of the first grayscale histogram consists of 256 color intervals, the abscissa of the second grayscale histogram consists of 8 color intervals, and the color interval step is 32.
3. The method according to claim 1, characterized in that According to the comparison result, a binary string of the second grayscale histogram is obtained, including: For each color interval of the second grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 1, otherwise, it is set to 0, thereby obtaining a binary string of the second grayscale histogram; or, For each color interval of the second grayscale histogram, if the number of pixels corresponding to the color interval is greater than or equal to the number of pixels corresponding to the median color interval, the value corresponding to the color interval is set to 0, otherwise, it is set to 1, thereby obtaining a binary string of the second grayscale histogram.
4. The method according to claim 1, characterized in that: Calculating the encoding value of the video frame to be processed according to the binary string includes: Performing a reverse operation on the binary string to obtain a reverse binary string; The reverse binary string is converted into a decimal string, thereby obtaining the encoding value of the video frame to be processed.
5. A device for processing video data, characterized in that: include: An acquisition module, used for acquiring a video frame to be processed from the video to be processed; A grayscale module, used to grayscale the video frame to be processed to obtain a grayscale histogram; the grayscale module is also used to: grayscale the video frame to be processed to obtain a first grayscale histogram; according to a preset color interval step, color interval merging of the first grayscale histogram to obtain a second grayscale histogram; A calculation module, used for calculating the encoding value of the video frame to be processed according to the second grayscale histogram; An encoding module, used for processing each pixel in the video frame to be processed according to the encoding value of the video frame to be processed, so as to obtain an encoded video frame; A synthesis module, used for replacing the to-be-processed video frame with the coded video frame, thereby synthesizing a coded video; The calculation module is also used for: Calculating the median color interval of the second grayscale histogram; Calculating the encoding value of the video frame to be processed according to the second grayscale histogram and the median color interval; The calculation module is also used for: Compare the number of pixels corresponding to each color interval of the second grayscale histogram with the number of pixels corresponding to the median color interval; According to the comparison result, a binary string of the second grayscale histogram is obtained; wherein the comparison result is distinguished by 0 and 1; Calculating the encoding value of the video frame to be processed according to the binary string; The encoding module is also used for: For each channel of each pixel point in the video to be processed, if the pixel value of the channel is greater than or equal to the encoding value of the video frame to be processed, then add M to the pixel value of the channel, otherwise, subtract M, so as to obtain an encoded video frame; Wherein, M is greater than zero; The calculation module is also used for: Calculating the total number of pixels of the video frame to be processed to determine the median of the total number of pixels; The median color interval to which the median of the total number of pixels belongs is found from the second grayscale histogram.
6. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
