CN112004148A - Video processing method, video processing device, computer equipment and storage medium - Google Patents

Video processing method, video processing device, computer equipment and storage medium Download PDF

Info

Publication number
CN112004148A
CN112004148A CN202010910582.2A CN202010910582A CN112004148A CN 112004148 A CN112004148 A CN 112004148A CN 202010910582 A CN202010910582 A CN 202010910582A CN 112004148 A CN112004148 A CN 112004148A
Authority
CN
China
Prior art keywords
video
image
pixel value
range
binary data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010910582.2A
Other languages
Chinese (zh)
Other versions
CN112004148B (en
Inventor
陈朝虹
马华冠
赵洁
崔晓东
王立福
黄维
刘译聪
李辛
潘晓霞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010910582.2A priority Critical patent/CN112004148B/en
Publication of CN112004148A publication Critical patent/CN112004148A/en
Application granted granted Critical
Publication of CN112004148B publication Critical patent/CN112004148B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/46Embedding additional information in the video signal during the compression process
    • H04N19/467Embedding additional information in the video signal during the compression process characterised by the embedded information being invisible, e.g. watermarking
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/83Generation or processing of protective or descriptive data associated with content; Content structuring
    • H04N21/835Generation of protective data, e.g. certificates
    • H04N21/8358Generation of protective data, e.g. certificates involving watermark

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Image Processing (AREA)

Abstract

The application provides a video processing method, a video processing device, computer equipment and a storage medium, and belongs to the technical field of image processing. The method comprises the following steps: responding to a watermark adding instruction of the first video, acquiring watermark information, and performing binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character; adjusting the pixel value of a first image in the first video based on the binary data, wherein the frequency change trend corresponding to the pixel value of the adjusted first image corresponds to the binary data; and generating a second video added with the watermark information based on the adjusted first image. The method and the device for displaying the watermark information represent the watermark information by the frequency variation trend corresponding to the pixel value, after the video is attacked, the frequency variation trend is not easy to damage, the watermark information can still be represented, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and robustness is enhanced.

Description

Video processing method, video processing device, computer equipment and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a video processing method and apparatus, a computer device, and a storage medium.
Background
Digital watermarking technology is an effective method for copyright protection, and can be used for copyright protection of videos, such as protection of some game videos through watermarking technology. Through the digital watermark technology, the copyright information of the video can be embedded into the video as the digital watermark. The digital watermark embedded in the video can identify the copyright owner of the video, and is hidden in the video and not easy to be detected and perceived. The digital watermark can be extracted from the video by a mode corresponding to the embedding of the digital watermark in the video, so as to prove the copyright owner of the video, thereby realizing copyright protection.
The video embedded with the digital watermark may be subjected to scaling, rotation, translation, distortion, compression and other attacks during the propagation process so as to destroy the synchronicity of the video and the digital watermark. Although the digital watermark still exists in the attacked video, the digital watermark is misplaced, and the digital watermark extracted from the attacked video has errors and is not accurate enough. The digital watermark cannot effectively resist attack and is weak in robustness.
Disclosure of Invention
The embodiment of the application provides a video processing method and device, computer equipment and a storage medium, which can accurately extract watermark information from a video after the video added with the watermark information is attacked, so that the watermark information can effectively resist the attack and the robustness is enhanced. The technical scheme is as follows:
in one aspect, a video processing method is provided, and the method includes:
responding to a watermark adding instruction of a first video, acquiring watermark information, and performing binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character;
adjusting the pixel value of a first image in the first video based on the binary data, wherein the frequency change trend corresponding to the adjusted pixel value of the first image corresponds to the binary data;
and generating a second video added with the watermark information based on the adjusted first image.
In an optional implementation, the adjusting the pixel value of the first image in the first video based on the binary data includes:
extracting a single-channel image of a target color channel based on the first image;
adjusting pixel values of the single-channel image based on the binary data.
In another alternative implementation, the determining a plurality of target-wide pixel value ranges according to the pixel value distribution of the first image and the bit number of the binary data includes:
determining an average value of pixel values of the first image according to the pixel value distribution of the first image;
and respectively determining pixel value ranges of the target width from two sides of the average value by taking the average value as a center to obtain a plurality of pixel value ranges, wherein the number of the pixel value ranges is the same as the number of bits of the binary data.
In another optional implementation manner, after determining a plurality of pixel value ranges of the target width according to the pixel value distribution of the first image and the bit number of the binary data, the method further includes:
adding the first image to the second video in response to the determined boundary value of the pixel value range exceeding a pixel value reference range.
In one aspect, a video processing method is provided, and the method includes:
responding to the watermark extraction instruction, and acquiring a third video added with watermark information;
determining binary data corresponding to a second image based on a frequency change trend corresponding to pixel values of the second image in the third video, wherein the frequency change trend corresponding to the pixel values of the second image corresponds to the binary data corresponding to the second image;
determining watermark information for the third video based on the binary data.
In an optional implementation manner, the obtaining the histogram of the second image includes:
extracting a single-channel image of a target color channel based on the second image;
and counting the frequency of each pixel value in the single-channel image to obtain a histogram of the second image.
In another alternative implementation, the determining a plurality of pixel value ranges according to the pixel value distribution of the second image includes:
determining a minimum boundary of the plurality of pixel value ranges according to the pixel value distribution of the second image;
and determining a plurality of pixel value ranges of the target width by taking the minimum boundary as a starting point.
In another alternative implementation, the determining the minimum boundary of the plurality of pixel value ranges according to the pixel value distribution of the second image includes:
determining an average value of the pixel values of the second image according to the pixel value distribution of the second image;
determining a minimum reference boundary for range division based on the average, the target width, and the number of bits of the binary data;
determining a search range corresponding to the minimum boundary based on the minimum reference boundary and the search width;
and respectively taking a plurality of numerical values in the search range as the minimum boundaries.
In one aspect, a video processing apparatus is provided, the apparatus comprising:
the watermark information acquisition module is used for responding to a watermark adding instruction of the first video and acquiring watermark information;
the binary conversion module is used for carrying out binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character;
the pixel adjusting module is used for adjusting the pixel value of a first image in the first video based on the binary data, wherein the frequency change trend corresponding to the adjusted pixel value of the first image corresponds to the binary data;
and the video generation module is used for generating a second video added with the watermark information based on the adjusted first image.
In an optional implementation manner, the pixel adjusting module includes:
a pixel range acquisition unit for acquiring a pixel value range corresponding to a value in the binary data;
and the pixel adjusting unit is used for adjusting the pixel value of a target pixel point in the first image according to the numerical value, and the original pixel value of the target pixel point is located in the pixel value range corresponding to the numerical value.
In another alternative implementation, the range of pixel values corresponding to the numerical value includes a first sub-range and a second sub-range, and the pixel values in the first sub-range are greater than the pixel values in the second sub-range;
the pixel adjustment unit is configured to:
in response to that the numerical value is 1, reducing the pixel value of a first target pixel point in the first image by a first numerical value, wherein the original pixel value of the first target pixel point is located in the first sub-range, and the first numerical value is the width of the first sub-range;
and in response to the value being 0, increasing the pixel value of a second target pixel point in the first image by a second value, wherein the original pixel value of the second target pixel point is located in the second sub-range, and the second value is the width of the second sub-range.
In another optional implementation manner, the pixel adjusting module is configured to:
extracting a single-channel image of a target color channel based on the first image;
adjusting pixel values of the single-channel image based on the binary data.
In another optional implementation manner, the pixel range obtaining unit includes:
a first determining unit configured to determine pixel value ranges of a plurality of target widths based on a pixel value distribution of the first image and a bit number of the binary data;
and the second determining unit is used for determining the pixel value range corresponding to the numerical value according to the position of the numerical value in the binary data.
In another optional implementation manner, the first determining unit is configured to:
determining an average value of pixel values of the first image according to the pixel value distribution of the first image;
and respectively determining pixel value ranges of the target width from two sides of the average value by taking the average value as a center to obtain a plurality of pixel value ranges, wherein the number of the pixel value ranges is the same as the number of bits of the binary data.
In another optional implementation manner, the video generation module is further configured to:
adding the first image to the second video in response to the determined boundary value of the pixel value range exceeding a pixel value reference range.
In another optional implementation manner, the binary conversion module includes:
the code conversion unit is used for converting characters in the watermark information into binary coded data;
the position conversion unit is used for determining binary position data corresponding to the characters according to the positions of the characters in the watermark information;
and the binary generating unit is used for generating binary data corresponding to the characters according to the coded data and the position data.
In another optional implementation manner, the binary generation unit is configured to:
determining check bit data according to the number of 1's included in the encoded data and the position data;
and forming the coded data, the position data and the check bit data into binary data corresponding to the characters.
In another optional implementation manner, the apparatus further includes:
the display module is used for displaying a watermark adding interface, and the watermark adding interface comprises a video selection control and a watermark adding control;
the first video acquisition module is used for responding to the interactive operation of the video selection control to acquire a first video;
and the instruction generating module is used for responding to the interactive operation of the watermark adding control to generate a watermark adding instruction of the first video.
In one aspect, a video processing apparatus is provided, the apparatus comprising:
the second video acquisition module is used for responding to the watermark extraction instruction and acquiring a third video added with watermark information;
a binary data determining module, configured to determine binary data corresponding to a second image based on a frequency variation trend corresponding to a pixel value of the second image in the third video, where the frequency variation trend corresponding to the pixel value of the second image corresponds to the binary data corresponding to the second image;
and the watermark information determining module is used for determining the watermark information of the third video based on the binary data.
In an optional implementation manner, the binary data determining module includes:
a third determining unit configured to determine a plurality of pixel value ranges according to a pixel value distribution of the second image;
the fourth determining unit is used for determining a numerical value corresponding to the pixel value range according to the frequency change trend corresponding to the pixel value in the pixel value range;
and the binary data determining unit is used for forming the binary data by the numerical values corresponding to the pixel value ranges.
In another alternative implementation, the range of pixel values includes a first sub-range and a second sub-range, the pixel values in the first sub-range being greater than the pixel values in the second sub-range; the fourth determining unit is configured to:
in response to the frequency count of the pixel values in the second sub-range being greater than the frequency count of the pixel values in the first sub-range, determining that the pixel value range corresponds to a value of 1;
in response to the frequency count of pixel values in the second sub-range being less than or equal to the frequency count of pixel values in the first sub-range, determining that the range of pixel values corresponds to a value of 0.
In another optional implementation manner, the apparatus further includes:
a histogram obtaining module, configured to obtain a histogram of the second image, where the histogram is used to represent frequency distribution of each pixel value in the second image;
and the trend determining module is used for determining the frequency change trend corresponding to the pixel values in the pixel value range according to the histogram.
In another optional implementation manner, the histogram obtaining module is configured to:
extracting a single-channel image of a target color channel based on the second image;
and counting the frequency of each pixel value in the single-channel image to obtain a histogram of the second image.
In another optional implementation manner, the third determining unit includes:
a boundary determining subunit, configured to determine a minimum boundary of the plurality of pixel value ranges according to the pixel value distribution of the second image;
a range determining subunit, configured to determine pixel value ranges of a plurality of target widths with the minimum boundary as a starting point.
In another optional implementation manner, the boundary determining subunit is configured to:
determining an average value of the pixel values of the second image according to the pixel value distribution of the second image;
determining a minimum reference boundary for range division based on the average, the target width, and the number of bits of the binary data;
determining a search range corresponding to the minimum boundary based on the minimum reference boundary and the search width;
and respectively taking a plurality of numerical values in the search range as the minimum boundaries.
In another optional implementation manner, the watermark information determining module is configured to:
determining characters corresponding to the binary data and positions of the characters in the watermark information based on the binary data;
determining a character with the largest number from a plurality of characters on the same position determined based on a plurality of second images as a target character on the position;
and the watermark information is formed by target characters on a plurality of positions of the watermark information.
In one aspect, a computer device is provided, where the computer device includes a processor and a memory, where at least one program code is stored in the memory, and the at least one program code is loaded and executed by the processor to implement the video processing method according to any one of the above-mentioned optional implementation manners.
In one aspect, a computer-readable storage medium is provided, where at least one program code is stored, and the at least one program code is loaded and executed by a processor to implement the video processing method according to any one of the above-mentioned optional implementation manners.
In one aspect, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer program code, the computer program code being stored in a computer-readable storage medium, the computer program code being read by a processor of a computer device from the computer-readable storage medium, the computer program code being executable by the processor to cause the computer device to perform the video processing method according to any one of the alternative implementations described above.
According to the technical scheme provided by the embodiment of the application, characters in the watermark information are converted into binary data represented by 0 and 1, the pixel value of the image in the video is adjusted based on the condition that the value of the binary data is 0 or 1, the frequency variation corresponding to the pixel value of the adjusted image is represented as the trend corresponding to 0 or 1, the watermark information is represented by the frequency variation trend corresponding to the pixel value, and the watermark information is embedded into the image of the video. After the video is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of an image in the video can change, but the frequency change trend corresponding to the pixel value is not easily damaged, the frequency change trend can still represent watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic illustration of an implementation environment provided by an embodiment of the present application;
fig. 2 is a flowchart of a video processing method according to an embodiment of the present application;
fig. 3 is a flowchart of a video processing method according to an embodiment of the present application;
fig. 4 is a flowchart of a video processing method according to an embodiment of the present application;
fig. 5 is a schematic diagram of a watermarking interface provided in an embodiment of the present application;
fig. 6 is a schematic diagram of a watermarking interface provided in an embodiment of the present application;
fig. 7 is a schematic diagram of a watermarking process provided by an embodiment of the present application;
fig. 8 is a flowchart of a video processing method according to an embodiment of the present application;
fig. 9 is a schematic diagram of a watermark extraction process provided by an embodiment of the present application;
fig. 10 is a block diagram of a video processing apparatus according to an embodiment of the present application;
fig. 11 is a block diagram of a video processing apparatus according to an embodiment of the present application;
fig. 12 is a block diagram of a terminal according to an embodiment of the present application;
fig. 13 is a block diagram of a server according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. The term "plurality" in the present application means two or more. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
For convenience of understanding, terms referred to in the embodiments of the present application are explained below.
Watermarking: watermarking, also known as Digital Watermark (Digital Watermark), is a kind of protection information that is embedded in a carrier file using computer algorithms. Digital watermarking is an effective method for protecting information safety, realizing anti-counterfeiting tracing and copyright protection, and is an important branch and research direction in the field of information hiding technology research. Digital watermarking is both covert and robust. Taking the carrier file as the video as an example, the concealment refers to that the digital watermark is not easy to perceive and perceive after being embedded into the video, and does not influence the visual perception of the video. Robustness refers to the ability to accurately extract a digital watermark from a video after the video has undergone an unintentional or intentional signal processing process. Possible signal processing procedures include size change, compression coding, translation, cropping, warping, noise, painting, and the like.
Video blind watermarking: the digital watermark is divided into a blind watermark and a non-blind watermark according to the extraction process of the watermark. Non-blind watermarking requires watermark extraction with the original video. The blind watermark can be extracted directly based on the video added with the watermark without the help of the original video.
Histogram: and taking [0,255] as an interval, counting the frequency of each pixel value in the image, taking the pixel value as an abscissa and the frequency as an ordinate, and obtaining a statistical chart which is a histogram. The frequency of any pixel value represents the number of pixels of which the pixel value is the pixel value in the image.
Geometric attack: the modification of the video geometry is affected by the change in size, cropping, distortion, etc. of the watermarked video.
JPEG (Joint Photographic Experts Group) compression attack: JPEG is a file compression format that has the characteristics of extremely high compression ratio and that can maintain high image quality. After the video added with the watermark is compressed and stored in a JPEG format, if most watermark information can still be extracted, the watermark information can resist JPEG compression attack.
The video processing method related to the present application is a video blind watermarking method, and is specifically described by the following embodiments.
Fig. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application. Referring to fig. 1, the implementation environment includes a terminal 101.
Optionally, the terminal 101 is a desktop computer, a notebook computer, a tablet computer, a smart phone, or the like, but is not limited thereto. The terminal 101 is provided with a watermark management application, the watermark management application at least provides a watermark adding function, and a user can add a watermark in a video through the watermark management application on the terminal 101. Optionally, the watermark management application is further provided with a watermark extraction function, and a user can extract a watermark from the watermarked video through the watermark management application on the terminal 101.
In an optional implementation manner, the adding and extracting of the watermark are performed by the terminal 101, taking watermark adding as an example, the terminal 101 responds to a watermark adding instruction to obtain a video to which the watermark needs to be added; the watermarking process is performed locally at the terminal 101 based on the video to be watermarked.
In another alternative implementation, the addition and extraction of the watermark is performed by the terminal 101 instructing the server 102. The implementation environment also includes a server 102. Taking watermark adding as an example, the terminal 101 responds to the watermark adding instruction to obtain a video needing to be added with a watermark; sending a watermark adding instruction and a video needing to be added with a watermark to the server 102; the server 102 performs a watermarking process on the server 102 based on the received watermarking instruction and the video to be watermarked.
Optionally, the terminal 101 and the server 102 are directly or indirectly connected through wired or wireless communication, and the application is not limited herein. Alternatively, the server 102 is a stand-alone physical server; alternatively, the server 102 is a server cluster or distributed system composed of a plurality of physical servers; or the server 102 is a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, web services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
Optionally, the technical solution provided by the embodiment of the present application is implemented by a terminal or a server as an execution subject; or, the technical solution provided in the embodiment of the present application is implemented through interaction between a terminal and a server, which is not limited in the present application. In the embodiment of the present application, an example in which an execution subject of the technical solution is a terminal is described.
Fig. 2 is a flowchart of a video processing method according to an embodiment of the present application. Referring to fig. 2, an embodiment of the present application is described with reference to adding watermark information in a video as an example, and the embodiment includes:
201. the terminal responds to the watermark adding instruction of the first video, obtains watermark information, and performs binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character.
The watermarking instructions are for instructing to add watermarking information in the first video. The watermark information is used for identifying a copyright owner of the first video, and optionally, the watermark information is a character string used for identifying the copyright owner of the first video.
The watermark information comprises at least one character, and the terminal performs binary conversion on each character in the watermark information to obtain binary data corresponding to each character. A binary data is used to represent a character, a binary data includes a plurality of numerical values, and the numerical value in the binary data is 0 or 1. For example, the watermark information includes a character "a", and the binary data corresponding to the character is "000011100001"; the watermark information includes another character "b" corresponding to binary data "000101100010".
202. The terminal adjusts the pixel value of the first image in the first video based on the binary data, wherein the frequency change trend corresponding to the pixel value of the adjusted first image corresponds to the binary data.
The first image is a frame image in the first video. The frequency corresponding to the pixel value is the number of the pixel points of which the pixel value is the pixel value in the first image. For example, if there are 10 pixels with a pixel value of 100 in the first image, the frequency corresponding to the pixel value of 100 is 10.
The frequency numbers corresponding to the pixel values in the first image are different, and the frequency number change trend corresponding to the pixel values is formed according to the sequence from small to large of the pixel values. And the terminal adjusts the pixel value of the first image based on the value 0 or 1 in the binary data, so that the frequency change trend corresponding to the pixel value of the adjusted first image corresponds to the binary data. For example, if the value in the binary data is 1, the value 1 is represented by a descending trend of frequency change; if the value in the binary data is 0, the value 0 is represented by a section of ascending frequency variation trend.
Optionally, the terminal adjusts a first image based on binary data corresponding to a character to embed a character in the watermark information into a frame of image. Correspondingly, the multi-frame images in the first video are respectively embedded with one character in the watermark information. Or the terminal adjusts a first image based on binary data corresponding to a plurality of characters so as to embed the characters in the watermark information into a frame of image. Correspondingly, the multi-frame images in the first video are respectively embedded with a plurality of characters in the watermark information.
In the embodiments of the present application, a terminal is used to process one frame of image in a video as an example. And in the process of adding the watermark, the terminal also processes images of other frames in the video so as to embed the watermark information into the multi-frame images. The process of processing images of other frames in the video by the terminal is the same as the process of processing one frame of image by the terminal.
203. And the terminal generates a second video added with the watermark information based on the adjusted first image.
The terminal adjusts the plurality of first images in the first video based on at least one binary datum corresponding to the watermark information. And the terminal reconstructs the plurality of adjusted first images and a plurality of other images which are not adjusted into a frame sequence according to the positions of the images in the frame sequence of the first video and encodes the second video added with the watermark information.
According to the technical scheme provided by the embodiment of the application, characters in the watermark information are converted into binary data represented by 0 and 1, the pixel value of the image in the video is adjusted based on the condition that the value of the binary data is 0 or 1, the frequency variation corresponding to the pixel value of the adjusted image is represented as the trend corresponding to 0 or 1, the watermark information is represented by the frequency variation trend corresponding to the pixel value, and the watermark information is embedded into the image of the video. After the video is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of an image in the video can change, but the frequency change trend corresponding to the pixel value is not easily damaged, the frequency change trend can still represent watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
Fig. 3 is a flowchart of a video processing method according to an embodiment of the present application. Referring to fig. 3, in the embodiment of the present application, taking an example of extracting watermark information from a third video as an example, an extracting process of the watermark information is an inverse process of the adding process of the watermark information, and the embodiment includes:
301. and the terminal responds to the watermark extraction instruction and acquires the third video added with the watermark information.
And the watermark extraction instruction is used for indicating the watermark extraction of the third video added with the watermark information. And the terminal acquires the third video indicated by the watermark extraction instruction based on the watermark extraction instruction.
302. The terminal determines binary data corresponding to the second image based on the frequency change trend corresponding to the pixel value of the second image in the third video, wherein the frequency change trend corresponding to the pixel value of the second image corresponds to the binary data corresponding to the second image.
Optionally, the second image is any frame image in the third video; or the second image is an image of the third video with embedded watermark information. The frequency numbers corresponding to the pixel values in the second image are different, and a frequency number change trend corresponding to the pixel values is formed according to the sequence from small to large of the pixel values. And the terminal determines binary data corresponding to the second image based on the frequency change trend corresponding to the pixel value. For example, if a section of frequency variation trend is descending, the value in the binary data corresponding to the frequency variation trend is 1; if the frequency variation trend of a section is ascending, the value in the binary data corresponding to the frequency variation trend is 0.
It should be noted that, when at least one character in the watermark information is embedded in the plurality of second images in the third video, the terminal determines at least one piece of binary data representing the character in the watermark information based on each second image, so as to determine a plurality of pieces of binary data based on the plurality of second images. Wherein each binary data is used to represent a character in the watermark information.
303. The terminal determines watermark information of the third video based on the binary data.
The terminal converts each binary data into a character, and the characters converted from the plurality of binary data form watermark information of the third video.
According to the technical scheme provided by the embodiment of the application, binary data corresponding to characters in the watermark information are represented by the frequency variation trend corresponding to the pixel value of the image in the video, so that the watermark information embedded in the video is determined based on the frequency variation trend corresponding to the pixel value of the image in the video. After the video added with the watermark information is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of the image in the video can change, but the frequency change trend corresponding to the pixel value is not easy to damage, the frequency change trend can still represent the watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
Fig. 4 is a flowchart of a video processing method according to an embodiment of the present application. Referring to fig. 4, in the embodiment of the present application, taking the example of adding watermark information in a video as an example, the embodiment includes:
401. and the terminal displays a watermark adding interface, wherein the watermark adding interface comprises a video selection control and a watermark adding control.
Optionally, a watermark management application is set on the terminal, and the terminal displays a watermark adding interface based on the watermark management application. The watermarking interface is used for providing a watermarking function for the video. The video selection control in the watermark adding interface is used for indicating and selecting a video needing to be added with a watermark; the watermarking control is used to indicate the start of watermarking in the selected video.
Fig. 5 is a schematic diagram of a watermarking interface provided in an embodiment of the present application, and referring to fig. 5, the watermarking interface includes a video selection control 501 and a watermarking control 502. Optionally, the watermarking interface further includes an additional property editing area 503. The additional attribute editing area 503 is used to edit additional attribute information of the selected video. For example, the additional attribute information includes a video name, a video album number, a copyright owner of the video, a video usage, and the like. The additional attribute editing area 503 includes an input control of a video name, a selection control of a video set number, a selection control of a copyright owner of the video, and a selection control of a video use.
Optionally, the watermarking interface further includes a location selection control 504, where the location selection control 504 is used to support user-defined storage location of the video after the watermarking information is added.
Optionally, the watermarking interface further includes a clear watermark setting control 505 and a content input control 506. The clear watermark setting control 505 is used to set whether to add a clear watermark in the video. The content input control 506 is used to set the content of the plain watermark. Wherein the bright watermark is a watermark that is visible to the naked eye displayed in the video. Optionally, if the bright watermark is added in the video through the bright watermark setting control 505, displaying the bright watermark in the upper left corner of the video; if the bright watermark is set not to be added in the video through the bright watermark setting control 505, the bright watermark is not displayed in the video. Optionally, the terminal further supports the user to set specific content of the plain watermark, and the terminal acquires the input text content in response to the interactive operation on the content input control 506 under the condition that the plain watermark setting control 505 is used to indicate that the plain watermark is added in the video; and taking the input text content as the content of the clear watermark.
402. And the terminal responds to the interactive operation on the video selection control to acquire the first video.
The first video is the video needing to be added with the watermark information. The terminal supports processing a first video. The user can select one video to process by performing interface interaction in the watermark adding interface, and correspondingly, the terminal responds to the interactive operation on the video selection control to obtain a first video. Optionally, the terminal further supports batch processing of the plurality of first videos at the same time, the user can select the plurality of videos in batch for processing by performing interface interaction in the watermark adding interface, and correspondingly, the terminal obtains the plurality of first videos in response to interaction operation on the video selection control. Optionally, the video selection control includes at least one of a video selection button and a video drag area.
In an alternative implementation, the terminal displays a file selection window in response to an interactive operation on a video selection button; and responding to the selected operation of the video in the file selection window, and taking the selected video as the first video needing to be added with the watermark information.
In another optional implementation manner, the terminal takes the video dragged into the video dragging area as the first video to which the watermark information needs to be added.
Fig. 6 is a schematic diagram of a watermarking interface provided by an embodiment of the present application, and referring to fig. 6, a terminal displays at least one selected first video in the watermarking interface. Optionally, the terminal represents the first video by displaying a cover of the first video in the watermarking interface. Optionally, the terminal further displays a deletion control 507 corresponding to the first video. The terminal responds to the interactive operation of the deletion control 507, the video corresponding to the deletion control 507 is no longer used as the first video needing to be added with the watermark information, and the video cover corresponding to the deletion control 507 is deleted from the watermark adding interface. Optionally, the watermarking interface after displaying the first video further includes a video selection control, so that the user can continuously select the video to which the watermarking information needs to be added.
Alternatively, the terminal supports the user to edit the additional attribute information of the video in the additional attribute editing area 503. For example, the user selects to add watermark information to the videos of the 1 st to 10 th sets of the "one-two-three" television series, and inputs the video name "one-two-three" in the additional attribute editing area; selecting 1 to 10 sets of video sets; selecting a copyright owner of the video as an A video platform; the video purpose is propaganda use. Optionally, the terminal supports the user to customize the storage location of the video after adding the watermark information through the location selection control 504, for example, the storage location selected by the user through the location selection control 504 is "D \ one, two, and three". Optionally, the terminal supports adding the bright watermark in the video through the bright watermark setting control 505 and the content input control 506, for example, the user sets adding the bright watermark in the video through the bright watermark setting control 505 and sets the content of the bright watermark to be "a video" through the content input control 506.
403. And the terminal responds to the interactive operation of the watermark adding control to generate a watermark adding instruction of the first video.
The watermarking control is used to indicate the start of watermarking in the selected video. And the terminal responds to the interactive operation of the watermark adding control to generate a watermark adding instruction so as to instruct the terminal to start adding watermark information in the first video through the watermark adding instruction. For example, with continued reference to fig. 6, the terminal generates watermarking instructions in response to interoperating the watermarking control 502.
In an optional implementation manner, before the terminal responds to the interactive operation on the watermarking control, and acquires a first video, the terminal generates a watermarking instruction on the first video.
In another optional implementation manner, before the terminal responds to the interactive operation on the watermarking control, a plurality of first videos are acquired, and the terminal generates watermarking instructions for the plurality of first videos.
404. And the terminal responds to the watermark adding instruction of the first video to acquire watermark information.
The watermark information is used for identifying a copyright owner of the first video, and optionally, the watermark information is a character string used for identifying the copyright owner of the first video. According to the embodiment of the application, the watermark information for identifying the copyright is added into the video in a concealed manner, so that the watermark information for identifying the copyright can be extracted from the video after the watermark information is added, the copyright owner of the video is determined, and copyright protection is realized.
In an alternative implementation manner, the watermarking instruction is used for instructing to add watermarking information to a first video, and the terminal generates watermarking information for the first video. Optionally, the step 404 includes: the terminal responds to a watermark adding instruction of the first video to acquire additional attribute information of the first video; and generating watermark information corresponding to the first video based on the additional attribute information of the first video. For example, the terminal generates watermark information corresponding to the first video through a message digest algorithm based on the video name of the first video and additional attribute information such as the copyright owner of the video.
In another optional implementation manner, the watermarking instruction is used to instruct to add watermarking information to the plurality of first videos, and the terminal generates the same watermarking information for the plurality of first videos. Accordingly, the step 404 includes: the terminal responds to the watermark adding instruction and obtains the same additional attribute information of the first videos; and generating watermark information corresponding to the first video based on the same additional attribute information of the plurality of first videos. For example, if the same additional attribute information of the plurality of first videos is the copyright owner of the video, the terminal generates watermark information based on the copyright owner of the video.
In another optional implementation manner, the watermarking instruction is used to instruct to add watermarking information to a plurality of first videos, and the terminal generates watermarking information for each first video. The process of generating a watermark information for each first video by the terminal is the same as the process of generating a watermark information for a first video by the terminal, and is not described herein again.
It should be noted that, optionally, the terminal does not generate the watermark information according to the additional attribute information of the first video. The terminal obtains the corresponding relation between the copyright owner and the watermark information, and obtains the watermark information corresponding to the copyright owner of the first video from the corresponding relation between the copyright owner and the watermark information. Optionally, the terminal locally stores a corresponding relationship between the copyright owner and the watermark information, and the terminal obtains the watermark information corresponding to the copyright owner of the first video from the locally stored corresponding relationship; or, the corresponding relation between the copyright owner and the watermark information is stored in the server, and the terminal acquires the watermark information corresponding to the copyright owner of the first video by sending a watermark information acquisition request to the server.
Another point to be noted is that the terminal can obtain the watermark information corresponding to the first video through any one of the above optional implementation manners. Optionally, the terminal may further be configured to acquire the watermark information corresponding to the first video in another way of acquiring the watermark information, and in this embodiment, the content of the watermark information and the way of acquiring the watermark information are not limited.
405. And the terminal performs binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character.
It should be noted that, if the watermark information includes a character, the terminal obtains binary data corresponding to the character, and the binary data is used to represent the character. If the watermark information comprises a plurality of characters, the terminal performs binary conversion on each character in the plurality of characters to obtain binary data corresponding to each character, wherein the binary data corresponding to each character are used for representing the character and the position of the character in the watermark information. In the embodiment of the present application, an example in which watermark information includes a plurality of characters is described.
The process of obtaining the binary data corresponding to each character by the terminal performing binary conversion on each character in the plurality of characters is the same. In the following, a terminal performs binary conversion on one character to obtain binary data corresponding to the character. The step of the terminal performing binary conversion on the characters in the watermark information to obtain binary data corresponding to the characters includes the following steps 4051 to 4053.
4051. And the terminal converts the characters in the watermark information into binary coded data.
Optionally, the terminal converts the character into binary encoded data according to an encoding format corresponding to the character. If the character is an english character or a numeric character, the encoding format corresponding to the character is ASCII (American Standard Code for Information exchange Code). And the terminal acquires the ASCII code value corresponding to the character and converts the ASCII code value of the character into binary data. For example, the character is "a", the ASCII code value corresponding to "a" is "97", and the character is converted into binary code "1100001". If the character is a Chinese character, the character is converted into binary coded data according to the coding format corresponding to the Chinese character. For example, the code data is converted into binary code data according to UTF-8(8-bit Unicode Transformation Format, variable length character coding for Unicode) or GB2312 (chinese character set for information exchange). In the embodiment of the present application, an example in which characters in watermark information are english characters or numeric characters is described.
4052. And the terminal determines binary position data corresponding to the characters according to the positions of the characters in the watermark information.
The plurality of characters are arranged in the watermark information in a positional order. For example, if the watermark information is "abcd 1," a "is at the 1 st position in the watermark information," b "is at the 2 nd position in the watermark information, and so on. The binary position data of each character is used to indicate the position of the character in the watermark information. For example, binary position data corresponding to "a" is "0000", binary position data corresponding to "b" is "0001", binary position data corresponding to "c" is "0010", binary position data corresponding to "d" is "0011", and binary position data corresponding to "1" is "0100".
Note that the watermark information includes a plurality of characters, and is expressed in the form of a character string. The bit number of the position data corresponding to the watermark information is related to the maximum length of the watermark information, and the maximum length of the watermark information is the maximum number of characters included in the watermark information. Since n-bit binary data can represent 2nAnd the terminal can determine the bit number of the position data according to the maximum length of the watermark information, wherein n is used for representing the bit number of the binary data, and n is a positive integer. Correspondingly, the step of determining the bit number of the position data by the terminal according to the maximum length of the watermark information comprises the following steps: the terminal determines the product of 2 of the target number; in response to the product of 2 of the target number being greater than or equal to the maximum length of the watermark information, the target number is determined as the number of bits of the position data. For example, if the maximum length of the watermark information is 16, the number of bits of the position data is 4; if the maximum length of the watermark information is 128, the number of bits of the position data is 7.
4053. And the terminal generates binary data corresponding to the characters according to the coded data and the position data.
In an alternative implementation, the terminal combines the encoded data and the position data into binary data corresponding to characters. For example, if the watermark information is "abcd 1", the binary data corresponding to "a" is "00001100001".
According to the technical scheme provided by the embodiment of the application, the binary data corresponding to each character is generated based on the coded data representing the character and the position data representing the position of the character in the watermark information, so that the generated binary data can represent the character and can represent the position of the character in the watermark information, and therefore when the watermark is extracted, the watermark information can be reversely determined based on a plurality of binary data, the accuracy of watermark extraction is improved, and effective copyright protection is further realized.
In another optional implementation manner, the terminal obtains the check bits based on the encoded data and the position data, and combines the encoded data, the position data, and the check bits into binary data corresponding to the characters. Accordingly, step 4053 includes: the terminal determines check bit data according to the number of 1 included in the coded data and the position data; and the terminal forms the coded data, the position data and the check bit data into binary data corresponding to the characters.
Optionally, the terminal determines the check bit data to be 1 in response to the number of 1's included in the encoded data and the position data being an odd number; the check bit data is determined to be 0 in response to the number of 1's included in the encoded data and the position data being an even number. For example, if the encoded data having watermark information "abcd 1", "a" is "1100001", and the position data "0000", "1100001", and "0000" include 3 pieces of 1, the parity data is 1. Alternatively, the terminal generates binary data corresponding to characters in the order of the position data, the check bit data, and the encoded data, and the binary data corresponding to "a" is "000011100001".
According to the technical scheme, check bit data are generated based on coded data and position data of characters, and the coded data, the position data and the check bit data form binary data. Since the parity data is a binary number indicating whether the number of 1's in the encoded data and the position data is an odd number or an even number, and the parity data is represented as 0 or 1 in the case where the number of 1's is an odd number or an even number, the number of 1's in the binary data to which the parity data is added is fixed to an odd number or an even number. Therefore, in the watermark extraction process, the legality of the binary data needing further processing can be ensured by checking the number of 1 in the binary data, the accuracy of watermark extraction is improved, and effective copyright protection is further realized.
After the terminal obtains binary data corresponding to each character, the pixel value of a first image in the first video is adjusted based on the binary data respectively, so that one character is embedded in one frame of image of the first video. It should be noted that, optionally, the terminal embeds each character in the watermark information into one frame of image of the first video respectively; or the terminal embeds each character in the watermark information into a multi-frame image of the first video respectively; or the terminal cyclically embeds a plurality of characters in the watermark information into each frame of image of the first video in sequence. In the embodiment of the present application, the number and the ratio of the adjusted first images in the first video are not limited. The embodiment of the present application takes as an example that a terminal embeds the same character into multiple frames of images of a first video, respectively, to ensure accuracy of watermark extraction. The process of embedding the same character into multiple frames of images by the terminal is the same as the process of embedding one character into one frame of image by the terminal, and the following description will be given by taking the example of embedding one character into one frame of image by the terminal.
Optionally, the terminal adjusts the pixel value within the pixel value range corresponding to each value based on each value in the binary data. The terminal obtains the pixel value range corresponding to the value in the binary data through the following steps 406 to 407.
406. The terminal determines a plurality of target-wide pixel value ranges based on the pixel value distribution of the first image and the number of bits of the binary data.
The pixel value distribution is used for representing the distribution range of the pixel values of each pixel point in the image. Optionally, the terminal represents the distribution of pixel values of the first image by acquiring a histogram of the first image. The binary data is composed of a plurality of values, and the number of the plurality of values constituting the binary data is the number of bits of the binary data. For example, binary data is "000011100001", and the bit number of the binary data is 12. The terminal divides a plurality of pixel value ranges for a plurality of values in the binary data respectively by taking the target width as a unit, and the width of the pixel value range is the target width. For example, the target width is a value of 6, 8, 10, etc. For example, the target width is 6 and the pixel value range is [84,90 ].
In an alternative implementation, the terminal obtains a plurality of pixel value ranges with reference to an average value of pixel values of the first image. Accordingly, the above step 406 is realized by the following steps 4061 to 4062.
4061. The terminal determines an average value of the pixel values of the first image according to the pixel value distribution of the first image.
And the terminal divides the sum of the pixel values of the pixels in the first image and the number of the pixels in the first image according to the pixel value distribution of the first image to obtain the average value of the pixel values of the first image.
4062. And the terminal respectively determines pixel value ranges of the target width from two sides of the average value by taking the average value as a center to obtain a plurality of pixel value ranges, wherein the number of the pixel value ranges is the same as the number of bits of the binary data.
For example, if the average value is avg, the target width is w, and the number of bits of binary data is N, the minimum boundary value in the plurality of pixel value ranges is avg-N × w/2, and the maximum boundary value in the plurality of pixel value ranges is avg + N × w/2. The plurality of pixel value ranges are [ avg-Nxw/2, avg-Nxw/2 + w), [ avg-Nxw/2 + w, avg-Nxw/2 +2 xw), [ avg-Nxw/2 +2 xw, avg-Nxw/2 +3 xw), and so on. Wherein avg is any value between 0 and 255; w is any value greater than 0; n is a positive integer.
According to the technical scheme, the average value of the pixel values of the first image is used as the center, and the pixel value ranges of the target widths are determined from the two sides of the average value respectively. Because the number of the pixel points covered by the pixel values around the average value is large, the pixel values of the plurality of covered pixel points are adjusted, the frequency variation trend corresponding to the pixel values of the adjusted first image can be more obvious, and the watermark is extracted based on the more obvious frequency variation trend in the watermark extraction process, so that the accuracy of the watermark extraction can be improved.
It should be noted that, optionally, the terminal determines pixel value ranges of a plurality of target widths from the right side of the minimum pixel value, respectively, with the minimum pixel value of the first image as a reference; or the terminal respectively determines a plurality of pixel value ranges of the target width from the left side of the maximum pixel value by taking the maximum pixel value of the first image as a reference; alternatively, the terminal determines pixel value ranges of a plurality of target widths from both sides of a pixel value of the first image or from one side of the pixel value with reference to the pixel value. In the embodiment of the present application, the manner of determining the pixel value ranges of the plurality of target widths is not limited.
Another point to be described is that, if the boundary value of the pixel value range determined based on the pixel value distribution of the first image exceeds the normal value range of the pixel value, the pixel value of the first image is not adjusted, and the second video is generated directly based on the unadjusted first image. Accordingly, after determining the plurality of pixel value ranges, the terminal further performs the steps of: the terminal adds the first image to the second video in response to the determined boundary value of the pixel value range exceeding the pixel value reference range. Wherein the reference range of pixel values is [0,255 ]. If the boundary value of the pixel value range is less than 0 or greater than 255, the first image is added to the second video.
According to the technical scheme, the pixel value beyond the normal range of the pixel value does not exist, and if the pixel value within the pixel value range is still adjusted based on the binary data, the binary data cannot be effectively embedded into the first image, so that the watermark information is lost. Therefore, under the condition that the boundary value of the pixel value range corresponding to the first image exceeds the normal value range of the pixel value, the first image is not adjusted, the first image is directly added into the second video, and the binary data is embedded into another frame of image which is extracted again, so that the integrity of the added watermark information is ensured, and the effectiveness of copyright protection is improved.
Another point to be noted is that, optionally, the terminal adjusts a pixel value of a single-channel image of the first image, and accordingly, the terminal determines a pixel value range of a plurality of target widths according to a pixel value distribution of the single-channel image of the first image. Accordingly, the pixel value distribution of the first image is the pixel value distribution of a single-channel image of the first image. Before the terminal determines the pixel value ranges of a plurality of target widths according to the pixel value distribution of the first image and the bit number of binary data, extracting a single-channel image of a target color channel based on the first image; and acquiring the pixel value distribution of the single-channel image. Optionally, the terminal converts the first image to a target color space; from the first image converted into the target color space, a single-channel image of the target color channel is extracted. For example, the terminal converts the first image into a YUV (a color coding method) color space, and extracts a Y-channel image from the first image converted into the YUV color space.
407. And the terminal determines the pixel value range corresponding to the numerical value according to the position of the numerical value in the binary data.
The range of pixel values corresponding to a value in the binary data is related to the position of the value in the binary data. Alternatively, the binary data is represented in the form of an array, and the position of a value in the binary data is represented by a subscript representing the element of the value. For example, the position of a numerical value in binary data is represented as the ith bit, i being a subscript to the element representing the numerical value, where i is a non-negative integer. For example, the binary data is "000011100001", the binary data is represented as an array a0=0,a1=0,a2=0,a3=0,a4=1,a5The corresponding numerical values are 0 th bit, 1 st bit, 2 nd bit, 3 rd bit, and so on. And the terminal determines the pixel value range corresponding to the numerical value as [ avg-Nxw/2 + i xw, avg-Nxw/2 + (i +1) × w) according to the i corresponding to the numerical value.
The technical scheme provided by the embodiment of the application, based on the pixel value distribution of the first image, the pixel value range of a target width is determined for each value according to the position of each value in the binary data, and then each value is determined based on the pixel value range corresponding to the value in the first image, so that one value in the binary data influences the pixel value in one pixel value range.
408. And the terminal adjusts the pixel value of a target pixel point in the first image according to the numerical value in the binary data, and the original pixel value of the target pixel point is located in the pixel value range corresponding to the numerical value.
And the terminal adjusts the pixel value of the target pixel point according to the numerical value in the binary data so that the frequency variation trend corresponding to the pixel value of the adjusted first image corresponds to the binary data.
In an optional implementation manner, the terminal divides a pixel value range corresponding to one numerical value in the binary data into two sub-ranges, so that the frequency counts corresponding to the pixel values in the two sub-ranges are mutually referred to, the frequency counts corresponding to the pixel values in the two sub-ranges represent frequency change trends, and the frequency change trends corresponding to the two sub-ranges correspond to the numerical values in the binary data. Accordingly, the terminal divides a pixel value range into a first sub-range and a second sub-range, and the pixel values in the first sub-range are greater than the pixel values in the second sub-range, and the step 408 includes: the terminal responds to the value of 1, the pixel value of a first target pixel point in the first image is reduced by a first value, the original pixel value of the first target pixel point is located in a first sub-range, and the first value is the width of the first sub-range; and the terminal responds to the value of 0, the pixel value of a second target pixel point in the first image is increased by a second value, the original pixel value of the second target pixel point is located in a second sub-range, and the second value is the width of the second sub-range.
Optionally, the width of the first sub-range is the same as the width of the second sub-range, and is half of the target width. For the ith bit value in the binary data, the first sub-range is [ avg-Nxw/2 + i xw + w/2, avg-Nxw/2 + (i +1) × w ], and the second sub-range is [ avg-Nxw/2 + i × w, avg-Nxw/2 + i × w + w/2 ]). If the ith bit value is 1, subtracting w/2 from the original pixel values of the pixels in the range of avg-Nxw/2 + i xw + w/2, avg-Nxw/2 + (i +1) xw). If the ith bit value is 0, adding w/2 to the original pixel values of the pixel points in the range of avg-Nxw/2 + i xw, avg-Nxw/2 + i xw + w/2).
For example, the widths of the two sub-ranges are 3, if the first sub-range is [90,93 ], the second sub-range is [87,90), and the corresponding values are 1, the pixel values of the first target pixels whose original pixel values are located in the first sub-range are all decreased by 3, and the range to which the adjusted pixel values of the first target pixels belong is changed into the second sub-range. The frequency of the pixel values in the first sub-range decreases and the frequency of the pixel values in the second sub-range increases. The frequency variation trend corresponding to the pixel values of the second sub-range pointing to the first sub-range direction is descending. Similarly, if the value in the binary data is 0, the frequency variation trend corresponding to the pixel value of the second sub-range pointing to the first sub-range direction is rising.
According to the technical scheme, the pixel values of the pixel points belonging to the sub-ranges are adjusted respectively based on two different situations that the numerical value in the binary data is 0 or 1, so that the frequency variation trends corresponding to the pixel values in the two sub-ranges correspond to the numerical value in the binary data, the binary data corresponding to the character of the watermark information is represented by the frequency variation trend corresponding to the pixel value, and the watermark information is embedded into the image of the video. Even if the pixel value or the image characteristic changes when the video is subjected to size change, compression coding, translation, cutting, distortion, noise, painting and other processing in the transmission process, the frequency change trend corresponding to the pixel value in the image embedded with the watermark information still exists, and the watermark information can still be accurately extracted based on the frequency change trend, so that the watermark information can effectively resist attack and the robustness is enhanced.
Another point to be noted is that, optionally, the terminal directly determines two pixel value ranges for each value in the binary data through a process similar to the process from step 406 to step 407; through the process similar to step 408, the pixel values of the pixels whose original pixel values are within the two pixel value ranges corresponding to the values are adjusted according to the values in the binary data.
Another point to be noted is that, optionally, the terminal adjusts the pixel values of the single-channel image of the target color channel of the first image based on the binary data. For example, the terminal adjusts the pixel values of the Y-channel image of the first image based on the binary data. Correspondingly, the pixel value of the target pixel point in the first image is the pixel value of the target pixel point in the first image on the single-channel image.
409. And the terminal generates a second video added with the watermark information based on the adjusted first image.
The terminal embeds the binary data corresponding to each character in the watermark information into the plurality of first images of the first video respectively through the steps 406 to 408 to obtain the plurality of adjusted first images. In the embodiment of the present application, binary data corresponding to one character is embedded in a plurality of first images of a first video, respectively. For example, the watermark information includes 10 characters, and if each character is embedded in 10 frames of images, the number of the adjusted first images is 100.
A video is composed of a plurality of consecutive images and is a sequence of images. And after the terminal finishes processing the first image extracted from the first video, adding the adjusted first image into the image sequence for coding according to the sequence position corresponding to the first image to obtain a second video added with the watermark information. Optionally, the terminal adjusts the plurality of first images in the first video, and does not adjust other images in the first video, and then the terminal adds each image to the image sequence according to the sequence position corresponding to each image in the plurality of first images and other images, and encodes the image sequence to obtain the second video to which the watermark information is added.
According to the technical scheme provided by the embodiment of the application, characters in the watermark information are converted into binary data represented by 0 and 1, the pixel value of the image in the video is adjusted based on the condition that the value of the binary data is 0 or 1, the frequency variation corresponding to the pixel value of the adjusted image is represented as the trend corresponding to 0 or 1, the watermark information is represented by the frequency variation trend corresponding to the pixel value, and the watermark information is embedded into the image of the video. After the video is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of an image in the video can change, but the frequency change trend corresponding to the pixel value is not easily damaged, the frequency change trend can still represent watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
One point to be described is that if the terminal adjusts the single-channel image of the target color channel of the first image, the terminal merges the single-channel image after adjustment and two other single-channel images that are not adjusted to obtain a three-channel image; and generating a second video based on the adjusted three-channel image. Optionally, if the target color space corresponding to the target color channel is the same as the original color space corresponding to the first image, the terminal merges the adjusted single-channel image and the two other unadjusted single-channel images into a three-channel image. If the target color space corresponding to the target color channel is different from the original color space corresponding to the first image, the terminal converts the adjusted single-channel image and the two other unadjusted single-channel images into the original color space; and merging the three single-channel images converted into the original color space to obtain a three-channel image.
In order to make the process of adding the watermark information clearer, the following description is made with reference to fig. 7. Referring to fig. 7, optionally, the watermarking process includes: 701. for a video needing to be added with watermark information, taking out a frame of image from a source video file frame sequence of the video; 702. carrying out YUV channel decomposition on the frame image to obtain a Y channel image of the frame image; 703. adjusting the pixel value of the Y-channel image based on the binary data converted from the watermark information, that is, adjusting the pixel value of the Y-channel image, and embedding the watermark information (1,0), where the specific implementation processes 701 to 703 are as in steps 404 to 408; 704. merging YUV channels of the Y channel image, the U channel image and the V channel image to obtain a merged three-channel image; 705. the merged three-channel image is added to the watermarked sequence of video file frames, and the specific implementation process of steps 704 to 705 is as described in step 409. Before adjusting the pixel values of the Y-channel image, calculating a histogram for the Y-channel image, wherein a part of the obtained histogram is schematically shown as 706; after the pixel values of the Y-channel image are adjusted, the histogram of the adjusted Y-channel image changes accordingly, as shown at 707. Comparing 706 and 707, if the value of the binary data converted from the watermark information is 1, adjusting the Y-channel image, so that the histogram trend of the adjusted Y-channel image in a certain pixel value range is shown to be reduced; if the value of the binary data converted from the watermark information is 0, the Y-channel image is adjusted, so that the histogram trend of the adjusted Y-channel image in a certain pixel value range is shown to be increased.
Another point to be described is that the terminal supports batch processing on multiple videos at the same time, the above steps 404 to 409 take the example that the terminal adds the watermark information to one first video as an example, and the process of adding the watermark information to each first video in the multiple first videos by the terminal is the same as the above steps 404 to 409, which is not described herein again.
It should be noted that the above embodiment is described by taking an example of embedding a character in one frame of image of a video. Alternatively, the terminal can embed a plurality of characters in one frame image. The process of embedding a plurality of characters in one frame image by the terminal is the same as the process of embedding one character in one frame image by the terminal. When the terminal embeds a character in one frame of image, the number of the determined multiple pixel value ranges is the same as the number of bits of binary data corresponding to the character. If the terminal embeds a plurality of characters in one frame of image, a plurality of pixel value ranges are required to be determined for each character in the plurality of characters respectively, wherein the plurality of pixel value ranges corresponding to each character are the same as the bit number of binary data corresponding to each character. For example, the terminal embeds two characters in one frame of image, and the bit numbers of binary data corresponding to the two characters are both 12, the terminal determines 12 pixel value ranges for each character, and the total pixel value ranges are 24. There is no cross-over overlap of the above 24 pixel value ranges.
Another point to be noted is that the number of characters that can be embedded in one frame image by the terminal is limited. The maximum number of characters should ensure that the determined pixel value ranges are within the normal pixel value range, i.e. the pixel value ranges should be as much as possible within 0,255.
Fig. 8 is a flowchart of a video processing method according to an embodiment of the present application. Referring to fig. 8, in the embodiment of the present application, taking an example of extracting watermark information from a video as an example, a process of extracting watermark information from a video corresponds to a process of adding watermark information to a video, and the embodiment includes:
801. and the terminal responds to the watermark extraction instruction and acquires the third video added with the watermark information.
Optionally, the terminal displays a watermark extraction interface, wherein the watermark extraction interface comprises a video selection control and a watermark extraction control; the terminal responds to the interactive operation on the video selection control and determines a third video needing watermark extraction; generating a watermark extraction instruction in response to the interactive operation on the watermark extraction control, wherein the watermark extraction instruction is used for indicating the watermark extraction of the third video; and the terminal responds to the watermark extraction instruction and acquires the third video added with the watermark information.
The watermark information includes a plurality of characters, and the plurality of characters of the watermark information are respectively embedded in the multi-frame images of the third video. Optionally, the image of the character embedded with the watermark information carries a watermark, and the terminal extracts a multi-frame image carrying the watermark from the third video as a second image on which the watermark extraction is based; or the image of the character embedded with the watermark information does not carry the watermark, and the terminal randomly extracts a multi-frame image from the third video to serve as a second image based on the watermark extraction. It should be noted that the process of the terminal extracting the characters in the watermark information from the plurality of second images is the same as the process of the terminal extracting the characters in the watermark information based on one second image, and the following description will take the process of the terminal extracting one character in the watermark information based on one second image as an example.
Optionally, the terminal adjusts the image in the third video according to the division of the plurality of pixel value ranges, so that the frequency change trend corresponding to the pixel value in each pixel value range corresponds to the numerical value in the binary data corresponding to the character. Correspondingly, the terminal determines a plurality of pixel value ranges, so as to determine the numerical value in the binary data based on the frequency variation trend corresponding to the pixel value in each pixel value range. The terminal realizes a process of determining a plurality of pixel value ranges from the pixel value distribution of the second image by the following steps 802 to 803.
802. The terminal determines a minimum boundary of the plurality of pixel value ranges according to the pixel value distribution of the second image in the third video.
In the embodiment of the present application, a terminal acquires a plurality of pixel value ranges based on an average value of pixel values of an image in a watermarking process as an example. Correspondingly, in an optional implementation manner, the terminal determines an average value of the pixel values of the second image according to the pixel value distribution of the second image; a minimum boundary of the plurality of pixel value ranges is determined based on the average, a target width of the pixel value range, and a number of bits of binary data used to represent the character.
For example, if the average value is avg, the target width is w, and the number of bits of binary data is N, the minimum boundary in the multiple pixel value ranges is avg-N × w/2, where avg is any value between 0 and 255; w is any value greater than 0; n is a positive integer.
In another alternative implementation, the terminal uses a plurality of values within a certain range as the minimum boundaries of the plurality of pixel value ranges, respectively. Accordingly, step 802 is implemented by the following steps 8021 to 8024.
8021. The terminal determines an average value of the pixel values of the second image according to the pixel value distribution of the second image.
And the terminal divides the sum of the pixel values of the pixels in the second image and the number of the pixels in the second image according to the pixel value distribution of the second image to obtain the average value of the pixel values of the second image.
8022. The terminal determines a minimum reference boundary of the range division based on the average value, the target width and the bit number of binary data corresponding to the second image.
The target width is a width of a preset pixel value range, for example, the target width is a value of 6, 8, or 10. The number of bits of the binary data is the number of values included in the binary data for representing characters in the watermark information. For example, the average value is denoted as avg, the target width is denoted as w, the number of bits of binary data is denoted as N, and the terminal determines the minimum reference boundary among the plurality of pixel value ranges to be avg-N × w/2, and the minimum reference boundary is denoted as B _ low.
8023. And the terminal determines a search range corresponding to the minimum boundary based on the minimum reference boundary and the search width.
The search width is a preset search width for the minimum boundary. Optionally, the search width is related to the target width, e.g. the search width is 2 or 3 times the target width. If the search width is 2s, the search range corresponding to the minimum boundary is [ B _ low-s, B _ low + s ], where s is any value greater than 0.
8024. The terminal takes a plurality of numerical values in the search range as minimum boundaries respectively.
And the terminal respectively takes the plurality of numerical values in the search range as minimum boundaries to obtain a plurality of minimum boundaries. For example, the minimum boundary is denoted as search _ start, and then search _ start is respectively B _ low-1, B _ low +1, B _ low-2, B _ low +2, B _ low-3, B _ low +3, … B _ low-s, and B _ low + s.
According to the technical scheme, the video is possibly attacked in the transmission process, so that the pixel value of the image in the video is changed, and further the average value of the pixel value of the image is changed. If the plurality of pixel value ranges are still determined based on the average value of the pixel values of the second image, the determined plurality of pixel value ranges may be shifted from the plurality of pixel value ranges actually processed in the watermark adding process, which may affect the accuracy of watermark extraction. Thus, a value within a certain range is determined as a plurality of minimum boundaries based on the average value of the pixel values of the second image; respectively determining a plurality of pixel value ranges based on the plurality of minimum boundaries; and extracting characters in the watermark information respectively based on the frequency change trend of the pixel values in the plurality of pixel value ranges corresponding to each minimum boundary until the characters meeting legal conditions are extracted, so that the watermark information can be still accurately extracted under the condition that the video is attacked, and the accuracy of watermark extraction is improved.
It should be noted that, if the terminal determines a minimum boundary, a binary data is determined based on the minimum boundary. If the terminal determines the minimum boundaries, the terminal determines one binary data based on each minimum boundary to obtain a plurality of binary data. The following steps 802 to 804 are described by taking an example in which the terminal determines a binary data based on a minimum boundary. The terminal determines a binary data process based on each minimum boundary.
803. The terminal determines a plurality of target-wide pixel value ranges starting from the minimum boundary.
For example, the minimum boundary is denoted as search _ start, the target width is w, and the plurality of pixel value ranges are [ search _ start, search _ start + w), [ search _ start + w, search _ start +2w), [ search _ start +2w, search _ start +3w), and so on.
It should be noted that the plurality of pixel value ranges respectively correspond to one-bit binary values in the binary data. Each pixel value range is associated with the position of its corresponding value in the binary data. For example, if the position of the value of the binary data in the binary data is represented as the ith bit, the pixel value range corresponding to the ith bit value is represented as [ search _ start + i × w, search _ start + (i +1) × w ], where i is a non-negative integer.
804. And the terminal determines the numerical value in the binary data corresponding to the pixel value range according to the frequency variation trend corresponding to the pixel value in the pixel value range.
The terminal divides the pixel value range into two sub-ranges to represent the frequency variation trend, and the frequency variation trends represented by the two sub-ranges correspond to the numerical values in the binary data. Correspondingly, the terminal divides the pixel value range into a first sub-range and a second sub-range, and the pixel values in the first sub-range are greater than the pixel values in the second sub-range, and the step 804 includes: the terminal responds to the frequency count of the pixel values in the second sub-range being larger than the frequency count of the pixel values in the first sub-range, and the corresponding value of the pixel value range is determined to be 1; the terminal determines that the value corresponding to the pixel value range is 0 in response to the frequency count of the pixel values in the second sub-range being less than or equal to the frequency count of the pixel values in the first sub-range.
Optionally, the width of the first sub-range is the same as the width of the second sub-range, and is half of the target width. For the ith bit value in the binary data, the first sub-range is [ search _ start + i × w + w/2, search _ start + (i +1) × w), and the second sub-range is [ search _ start + i × w, search _ start + i × w + w/2). If the frequency count of the pixel value in [ search _ start + i × w, search _ start + i × w + w/2) is greater than the frequency count of the pixel value in [ search _ start + i × w + w/2, search _ start + (i +1) × w ], the value of the ith bit in the binary data is 1; if the frequency count of the pixel values in [ search _ start + i × w, search _ start + i × w + w/2) is less than or equal to the frequency count of the pixel values in [ search _ start + i × w + w/2, search _ start + (i +1) × w), the value of the ith bit in the binary data is 0.
According to the technical scheme, the numerical values in the binary data are determined by comparing the frequency numbers of the pixel values in the two sub-ranges according to the frequency number change trends in the two sub-ranges. Even if the video is attacked in the transmission process, the pixel value or the image characteristic of the image in the video changes, the frequency variation trend corresponding to the pixel value still exists, the numerical value in the binary data can be accurately extracted based on the frequency variation trend, and the added watermark information is determined based on the extracted binary data, so that the watermark information can effectively resist the attack, and the robustness is enhanced.
Optionally, before the terminal determines the value in the binary data corresponding to the pixel value range according to the frequency variation trend corresponding to the pixel value in the pixel value range, the terminal further obtains a histogram of the second image, and determines the frequency variation trend corresponding to the pixel value in the pixel value range according to the histogram. The histogram is used for representing the frequency distribution of each pixel value in the second image. Optionally, in the process of adding the watermark, the terminal adjusts a single-channel image of the image, and represents binary data corresponding to the characters in the watermark information by using a frequency variation trend corresponding to the single-channel image. Accordingly, in the watermark extraction process, the terminal determines the frequency change trend based on the histogram of the single-channel image. The process that the terminal acquires the histogram of the second image comprises the following steps: the terminal extracts a single-channel image of the target color channel based on the second image; and the terminal counts the frequency of each pixel value in the single-channel image to obtain a histogram of the second image. Optionally, the terminal converts the second image to a target color space; from the second image converted into the target color space, a single-channel image of the target color channel is extracted. For example, the terminal converts the second image into a YUV color space, and extracts a Y-channel image from the second image converted into the YUV color space.
In order to make the process of extracting binary data from the image of the video clearer, the following description is made with reference to fig. 9, and referring to fig. 9, optionally, the watermark extraction process includes: 901. for the video needing extracting the watermark information, extracting a frame of image from the video file frame sequence added with the watermark; 902. carrying out YUV channel decomposition on the frame image to obtain a Y channel image of the frame image; 903. calculating a histogram of the Y-channel image; 904. determining the frequency variation trend corresponding to the pixel value based on the obtained histogram; and determining the numerical value in the binary data based on the frequency change trend. The specific implementation processes of 901 to 904 are referred to in steps 801 to 804. If the frequency change trend represented by the two sub-ranges in one pixel value range is descending, the value corresponding to the pixel value range is 1; if the frequency variation trend represented by the two sub-ranges in a pixel value range is rising, the value corresponding to the pixel value range is 0.
805. The terminal combines the values corresponding to the plurality of pixel value ranges into binary data.
Each pixel value range corresponds to a bit value in the binary data. And the terminal combines the numerical values corresponding to the plurality of pixel value ranges into binary data according to the position sequence of each numerical value.
It should be noted that, if check bit data is added to the binary data in the watermark adding process, the terminal can check the validity of the binary data based on the number of 1's in the binary data in the watermark extracting process. For example, if the terminal determines that the check bit data is 1 in response to the number of 1's included in the encoded data and the position data being an odd number during the watermarking, the number of 1's in the binary data is an even number. Correspondingly, in the watermark extraction process, the binary data with the number of 1 being an even number in the binary data is legal; binary data in which the number of 1 s is odd is illegal. The terminal discards the illegal binary data. Watermark information is determined based on the legitimate binary data.
According to the technical scheme, the legality of the binary data is verified based on the check bit data, the illegal binary data is discarded, the watermark information is determined based on the legal binary data, the interference of the illegal binary data on the determination of the watermark information is reduced, and the accuracy of determining the watermark information can be improved.
Another point to be described is that, optionally, the terminal determines a plurality of minimum boundaries, and determines a binary data based on a plurality of pixel value ranges corresponding to each minimum boundary in sequence; judging whether the determined binary data is legal or not; if the binary data is legal, the binary data is used as the binary data for determining the watermark information, and the step of determining the binary data based on the plurality of pixel value ranges corresponding to the minimum boundary is not executed any more; if the binary data is illegal, the binary data is discarded, and the binary data is determined based on a plurality of pixel value ranges corresponding to another minimum boundary.
806. The terminal determines watermark information of the third video based on the binary data.
In the embodiment of the present application, an example is described in which the watermark information includes a plurality of characters, and each character is embedded in each of the plurality of frames of images of the third video. The terminal determines a plurality of characters at each position in the watermark information from the plurality of second images based on the above steps 802 to 805. The terminal determines a target character at each position from a plurality of characters at the position, thereby determining the watermark information. Accordingly, step 806 is implemented by the following steps 8061 to 8064.
8061. And the terminal determines the characters corresponding to the binary data and the positions of the characters in the watermark information based on the binary data.
Optionally, in the watermarking process, the binary data corresponding to the characters is composed of position data, check bit data and encoded data. The terminal determines the position of the character represented by the binary data in the watermark based on the position data in the binary data. For example, the first 4 bits in the binary data are position data, and if the position data is "0000", this indicates that this character is the 1 st character in the watermark information in the left-to-right direction; if the position data is "0010", it means that the character is the 3 rd character in the watermark information in the left-to-right direction. The terminal determines the characters corresponding to the binary data based on the encoded data in the binary data. For example, the last 7 bits of binary data are coded data, and if the coded data is "1100001", the character corresponding to the binary data is "a".
8062. The terminal determines, as a target character at the position, one of the characters at the largest number from among the characters at the same position determined based on the plurality of second images.
And respectively embedding characters at the same position in the watermark information into a plurality of second images in the video, and respectively determining the characters at the position by the terminal based on each second image to obtain a plurality of characters. For example, the terminal determines that the positions of 10 characters in the watermark information are all the 1 st positions, and the 10 characters include 7 "a", 2 "s", and 1 "b". And the terminal takes the character with the largest number as the target character at the position, and the target character at the 1 st position in the watermark information is 'a'.
8063. The terminal forms watermark information by target characters on a plurality of positions of the watermark information.
The terminal determines target characters at a plurality of positions based on step 8062, and combines the plurality of target characters into watermark information according to the position sequence.
According to the technical scheme, a plurality of characters at the same position in the watermark information are determined from a plurality of frames of images, then voting is carried out on the plurality of characters, and the character with the largest number is determined as the target character at the position to form the watermark information. Even if the video is attacked in the transmission process, the pixel value or the image characteristic of the image in the video is changed, so that the binary data determined based on the changed image has deviation from the binary data added in the watermark adding process, and by determining a plurality of characters and voting the plurality of characters, the watermark information closest to the added watermark information can be determined as much as possible, and the accuracy of watermark extraction is improved.
It should be noted that, in the experimental process, the watermark information added based on the technical scheme provided by the embodiment of the present application can effectively resist the geometric attack of size reduction with width and height reduced by more than 2 times. Moreover, the method can resist common attack means such as JPEG compression attack, translation, cutting, distortion, noise, painting and the like. After the video added with the watermark information is subjected to format conversion and resolution adjustment, the watermark can still be accurately extracted, and the robustness is high. Compared with the related technology, the method has better practical value because the watermark information can not be accurately extracted under the condition that the width and the height are reduced by more than 2 times.
It should be noted that, if the watermark information includes one character and the one character is embedded in one frame of image, the terminal converts the determined one binary data into the character as the watermark information of the third video. If the watermark information comprises one character and the character is embedded into the multi-frame images, the terminal determines a plurality of characters respectively based on the multi-frame images, and takes the character with the largest number as the watermark information of the third video.
According to the technical scheme provided by the embodiment of the application, binary data corresponding to characters in the watermark information are represented by the frequency variation trend corresponding to the pixel value of the image in the video, so that the watermark information embedded in the video is determined based on the frequency variation trend corresponding to the pixel value of the image in the video. After the video added with the watermark information is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of the image in the video can change, but the frequency change trend corresponding to the pixel value is not easy to damage, the frequency change trend can still represent the watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
All the above optional technical solutions may be combined arbitrarily to form optional embodiments of the present application, and are not described herein again.
Fig. 10 is a block diagram of a video processing apparatus according to an embodiment of the present application. Referring to fig. 10, the apparatus includes:
a watermark information obtaining module 1001 configured to obtain watermark information in response to a watermark adding instruction for a first video;
a binary conversion module 1002, configured to perform binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character;
the pixel adjusting module 1003 is configured to adjust a pixel value of a first image in the first video based on the binary data, where a frequency change trend corresponding to the adjusted pixel value of the first image corresponds to the binary data;
and a video generating module 1004, configured to generate a second video to which the watermark information is added, based on the adjusted first image.
According to the technical scheme provided by the embodiment of the application, characters in the watermark information are converted into binary data represented by 0 and 1, the pixel value of the image in the video is adjusted based on the condition that the value of the binary data is 0 or 1, the frequency variation corresponding to the pixel value of the adjusted image is represented as the trend corresponding to 0 or 1, the watermark information is represented by the frequency variation trend corresponding to the pixel value, and the watermark information is embedded into the image of the video. After the video is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of an image in the video can change, but the frequency change trend corresponding to the pixel value is not easily damaged, the frequency change trend can still represent watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
In an alternative implementation, the pixel adjustment module 1003 includes:
a pixel range acquisition unit for acquiring a pixel value range corresponding to a value in the binary data;
and the pixel adjusting unit is used for adjusting the pixel value of a target pixel point in the first image according to the numerical value, and the original pixel value of the target pixel point is located in the pixel value range corresponding to the numerical value.
In another alternative implementation, the range of pixel values corresponding to the numerical value includes a first sub-range and a second sub-range, and the pixel values in the first sub-range are greater than the pixel values in the second sub-range;
a pixel adjustment unit to:
in response to the value being 1, reducing the pixel value of a first target pixel point in the first image by a first value, wherein the original pixel value of the first target pixel point is located in a first sub-range, and the first value is the width of the first sub-range;
and responding to the value of 0, increasing the pixel value of a second target pixel point in the first image by a second value, wherein the original pixel value of the second target pixel point is positioned in a second sub-range, and the second value is the width of the second sub-range.
In another alternative implementation, the pixel adjustment module 1003 is configured to:
extracting a single-channel image of a target color channel based on the first image;
the pixel values of the single-channel image are adjusted based on the binary data.
In another alternative implementation, the pixel range obtaining unit includes:
a first determination unit configured to determine pixel value ranges of a plurality of target widths based on a pixel value distribution of the first image and a bit number of the binary data;
and the second determining unit is used for determining the pixel value range corresponding to the numerical value according to the position of the numerical value in the binary data.
In another optional implementation manner, the first determining unit is configured to:
determining an average value of pixel values of the first image according to the pixel value distribution of the first image;
and respectively determining pixel value ranges of the target width from two sides of the average value by taking the average value as a center to obtain a plurality of pixel value ranges, wherein the number of the pixel value ranges is the same as the number of bits of the binary data.
In another alternative implementation, the video generating module 1004 is further configured to:
the first image is added to the second video in response to the determined boundary value of the pixel value range exceeding the pixel value reference range.
In another alternative implementation, the binary conversion module 1002 includes:
the encoding conversion unit is used for converting characters in the watermark information into binary encoding data;
the position conversion unit is used for determining binary position data corresponding to the characters according to the positions of the characters in the watermark information;
and the binary generating unit is used for generating binary data corresponding to the characters according to the coded data and the position data.
In another alternative implementation, the binary generation unit is configured to:
determining check bit data according to the number of 1 included in the coded data and the position data;
and forming the coded data, the position data and the check bit data into binary data corresponding to characters.
In another optional implementation manner, the apparatus further includes:
the display module is used for displaying a watermark adding interface, and the watermark adding interface comprises a video selection control and a watermark adding control;
the first video acquisition module is used for responding to the interactive operation on the video selection control to acquire a first video;
and the instruction generating module is used for responding to the interactive operation of the watermark adding control to generate a watermark adding instruction of the first video.
It should be noted that: in the video processing apparatus provided in the above embodiment, when performing video processing, only the division of the above functional modules is taken as an example, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the above described functions. In addition, the video processing apparatus and the video processing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments in detail and are not described herein again.
Fig. 11 is a block diagram of a video processing apparatus according to an embodiment of the present application. Referring to fig. 11, the apparatus includes:
a second video obtaining module 1101, configured to obtain, in response to the watermark extraction instruction, a third video to which watermark information has been added;
a binary data determining module 1102, configured to determine binary data corresponding to a second image based on a frequency variation trend corresponding to a pixel value of the second image in a third video, where the frequency variation trend corresponding to the pixel value of the second image corresponds to the binary data corresponding to the second image;
a watermark information determining module 1103, configured to determine watermark information of the third video based on the binary data.
According to the technical scheme provided by the embodiment of the application, binary data corresponding to characters in the watermark information are represented by the frequency variation trend corresponding to the pixel value of the image in the video, so that the watermark information embedded in the video is determined based on the frequency variation trend corresponding to the pixel value of the image in the video. After the video added with the watermark information is attacked by scaling, rotation, translation, distortion, compression and the like, the pixel value of the image in the video can change, but the frequency change trend corresponding to the pixel value is not easy to damage, the frequency change trend can still represent the watermark information, accurate watermark information can still be extracted from the attacked video, the watermark information can effectively resist the attack, and the robustness is enhanced.
In an alternative implementation, the binary data determining module 1102 includes:
a third determining unit configured to determine a plurality of pixel value ranges from a pixel value distribution of the second image;
the fourth determining unit is used for determining a numerical value corresponding to the pixel value range according to the frequency change trend corresponding to the pixel value in the pixel value range;
and the binary data determining unit is used for forming the numerical values corresponding to the pixel value ranges into binary data.
In another alternative implementation, the range of pixel values includes a first sub-range and a second sub-range, the pixel values in the first sub-range being greater than the pixel values in the second sub-range; a fourth determination unit configured to:
in response to the frequency count of the pixel values in the second sub-range being greater than the frequency count of the pixel values in the first sub-range, determining that the value corresponding to the pixel value range is 1;
in response to the frequency count of the pixel values in the second sub-range being less than or equal to the frequency count of the pixel values in the first sub-range, determining that the range of pixel values corresponds to a value of 0.
In another optional implementation manner, the apparatus further includes:
the histogram acquisition module is used for acquiring a histogram of the second image, and the histogram is used for representing frequency distribution of each pixel value in the second image;
and the trend determining module is used for determining the frequency change trend corresponding to the pixel values in the pixel value range according to the histogram.
In another optional implementation manner, the histogram obtaining module is configured to:
extracting a single-channel image of the target color channel based on the second image;
and counting the frequency of each pixel value in the single-channel image to obtain a histogram of the second image.
In another optional implementation manner, the third determining unit includes:
a boundary determining subunit, configured to determine a minimum boundary of the plurality of pixel value ranges according to the pixel value distribution of the second image;
and the range determining subunit is used for determining pixel value ranges of a plurality of target widths by taking the minimum boundary as a starting point.
In another alternative implementation, the boundary determining subunit is configured to:
determining an average value of pixel values of the second image according to the pixel value distribution of the second image;
determining a minimum reference boundary for range division based on the average value, the target width, and the number of bits of the binary data;
determining a search range corresponding to the minimum boundary based on the minimum reference boundary and the search width;
and respectively taking a plurality of numerical values in the search range as minimum boundaries.
In another alternative implementation, the watermark information determining module 1103 is configured to:
determining characters corresponding to the binary data and positions of the characters in the watermark information based on the binary data;
determining a character with the largest number from a plurality of characters on the same position determined based on a plurality of second images as a target character on the position;
the watermark information is composed of target characters at a plurality of positions of the watermark information.
It should be noted that: in the video processing apparatus provided in the above embodiment, when performing video processing, only the division of the above functional modules is taken as an example, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the above described functions. In addition, the video processing apparatus and the video processing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments in detail and are not described herein again.
In the embodiment of the present application, the computer device may be configured as a terminal or a server. If the computer device is configured as a terminal, the terminal is used as an execution subject to implement the technical solution provided by the embodiment of the present application. If the computer device is configured as a server, the server serves as an execution subject to implement the technical solution provided by the embodiment of the present application. Or, the technical solution provided by the present application is implemented through interaction between a terminal and a server, which is not limited in the embodiments of the present application.
If the computer device is configured as a terminal, fig. 12 is a block diagram of a terminal provided in an embodiment of the present application. The terminal 1200 may be a smartphone, a tablet, a laptop, or a desktop computer. Terminal 1200 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, and so forth.
In general, terminal 1200 includes: a processor 1201 and a memory 1202.
The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, or the like. The processor 1201 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 1201 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 1201 may be integrated with a GPU (Graphics Processing Unit) for rendering and drawing content required to be displayed by the display screen. In some embodiments, the processor 1201 may further include an AI (Artificial Intelligence) processor for processing a computing operation related to machine learning.
Memory 1202 may include one or more computer-readable storage media, which may be non-transitory. Memory 1202 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in the memory 1202 is used to store at least one program code for execution by the processor 1201 to implement the video processing methods provided by the method embodiments herein.
In some embodiments, the terminal 1200 may further optionally include: a peripheral interface 1203 and at least one peripheral. The processor 1201, memory 1202, and peripheral interface 1203 may be connected by a bus or signal line. Various peripheral devices may be connected to peripheral interface 1203 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of radio frequency circuitry 1204, display 1205, camera assembly 1206, audio circuitry 1207, positioning assembly 1208, and power supply 1209.
In some embodiments, terminal 1200 also includes one or more sensors 1210. The one or more sensors 1210 include, but are not limited to: acceleration sensor 1211, gyro sensor 1212, pressure sensor 1213, fingerprint sensor 1214, optical sensor 1215, and proximity sensor 1216.
Those skilled in the art will appreciate that the configuration shown in fig. 12 is not intended to be limiting of terminal 1200 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
If the computer device is configured as a server, fig. 13 is a block diagram of a server provided in this embodiment of the present application, where the server 1300 may generate a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 1301 and one or more memories 1302, where at least one program code is stored in the memory 1302, and the at least one program code is loaded and executed by the processor 1301 to implement the video Processing method provided in each of the above method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input/output, and the server may also include other components for implementing the functions of the device, which are not described herein again.
In an exemplary embodiment, there is also provided a computer readable storage medium having at least one program code stored therein, the at least one program code being executable by a processor in a computer device to perform the video processing method in the above embodiments. For example, the computer-readable storage medium may be a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present application also provides a computer program product or a computer program comprising computer program code stored in a computer-readable storage medium, which is read by a processor of a computer device from the computer-readable storage medium, and which is executed by the processor to cause the computer device to execute the video processing method in the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only exemplary of the present application and should not be taken as limiting, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. A method of video processing, the method comprising:
responding to a watermark adding instruction of a first video, acquiring watermark information, and performing binary conversion on at least one character in the watermark information to obtain binary data corresponding to the character;
adjusting the pixel value of a first image in the first video based on the binary data, wherein the frequency change trend corresponding to the adjusted pixel value of the first image corresponds to the binary data;
and generating a second video added with the watermark information based on the adjusted first image.
2. The method of claim 1, wherein adjusting pixel values of a first image in the first video based on the binary data comprises:
acquiring a pixel value range corresponding to a numerical value in the binary data;
and adjusting the pixel value of a target pixel point in the first image according to the numerical value, wherein the original pixel value of the target pixel point is located in the pixel value range corresponding to the numerical value.
3. The method of claim 2, wherein the range of pixel values to which the values correspond includes a first sub-range and a second sub-range, and wherein pixel values in the first sub-range are greater than pixel values in the second sub-range;
the adjusting the pixel value of the target pixel point in the first image according to the numerical value includes:
in response to that the numerical value is 1, reducing the pixel value of a first target pixel point in the first image by a first numerical value, wherein the original pixel value of the first target pixel point is located in the first sub-range, and the first numerical value is the width of the first sub-range;
and in response to the value being 0, increasing the pixel value of a second target pixel point in the first image by a second value, wherein the original pixel value of the second target pixel point is located in the second sub-range, and the second value is the width of the second sub-range.
4. The method of claim 2, wherein obtaining a range of pixel values corresponding to values in the binary data comprises:
determining pixel value ranges of a plurality of target widths according to the pixel value distribution of the first image and the bit number of the binary data;
and determining a pixel value range corresponding to a numerical value according to the position of the numerical value in the binary data.
5. The method according to claim 1, wherein the binary converting at least one character in the watermark information to obtain binary data corresponding to the character comprises:
converting characters in the watermark information into binary coded data;
according to the position of the character in the watermark information, binary position data corresponding to the character is determined;
and generating binary data corresponding to the characters according to the coded data and the position data.
6. The method according to claim 5, wherein generating binary data corresponding to the character based on the encoded data and the position data comprises:
determining check bit data according to the number of 1's included in the encoded data and the position data;
and forming the coded data, the position data and the check bit data into binary data corresponding to the characters.
7. The method of claim 1, wherein before obtaining the watermark information in response to the watermarking instruction for the first video, the method further comprises:
displaying a watermark adding interface, wherein the watermark adding interface comprises a video selection control and a watermark adding control;
responding to the interactive operation of the video selection control, and acquiring a first video;
and generating a watermarking instruction for the first video in response to the interactive operation of the watermarking control.
8. A method of video processing, the method comprising:
responding to the watermark extraction instruction, and acquiring a third video added with watermark information;
determining binary data corresponding to a second image based on a frequency change trend corresponding to pixel values of the second image in the third video, wherein the frequency change trend corresponding to the pixel values of the second image corresponds to the binary data corresponding to the second image;
determining watermark information for the third video based on the binary data.
9. The method of claim 8, wherein determining the binary data corresponding to the second image based on the trend of change of frequency count corresponding to the pixel values of the second image in the third video comprises:
determining a plurality of pixel value ranges according to the pixel value distribution of the second image;
determining a numerical value corresponding to the pixel value range according to the frequency variation trend corresponding to the pixel value in the pixel value range;
and composing the binary data by the numerical values corresponding to the plurality of pixel value ranges.
10. The method of claim 9, wherein the range of pixel values comprises a first sub-range and a second sub-range, wherein pixel values in the first sub-range are greater than pixel values in the second sub-range;
determining a value corresponding to the pixel value range according to the frequency variation trend corresponding to the pixel value in the pixel value range, including:
in response to the frequency count of the pixel values in the second sub-range being greater than the frequency count of the pixel values in the first sub-range, determining that the pixel value range corresponds to a value of 1;
in response to the frequency count of pixel values in the second sub-range being less than or equal to the frequency count of pixel values in the first sub-range, determining that the range of pixel values corresponds to a value of 0.
11. The method of claim 9, wherein before determining the value corresponding to the pixel value range according to the frequency variation trend of the pixel value in the pixel value range, the method further comprises:
acquiring a histogram of the second image, wherein the histogram is used for representing the frequency distribution of each pixel value in the second image;
and determining the frequency variation trend corresponding to the pixel values in the pixel value range according to the histogram.
12. The method of claim 8, wherein determining watermark information for the third video based on the binary data comprises:
determining characters corresponding to the binary data and positions of the characters in the watermark information based on the binary data;
determining a character with the largest number from a plurality of characters on the same position determined based on a plurality of second images as a target character on the position;
and the watermark information is formed by target characters on a plurality of positions of the watermark information.
13. A video processing apparatus, characterized in that the apparatus comprises a plurality of functional modules for implementing the video processing method according to any one of claims 1 to 12.
14. A computer device comprising a processor and a memory, the memory having stored therein at least one program code, the at least one program code being loaded and executed by the processor to implement the video processing method according to any of claims 1-12.
15. A computer-readable storage medium having stored therein at least one program code, the at least one program code being loaded and executed by a processor to implement the video processing method according to any one of claims 1 to 12.
CN202010910582.2A 2020-09-02 2020-09-02 Video processing method, video processing device, computer equipment and storage medium Active CN112004148B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010910582.2A CN112004148B (en) 2020-09-02 2020-09-02 Video processing method, video processing device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010910582.2A CN112004148B (en) 2020-09-02 2020-09-02 Video processing method, video processing device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112004148A true CN112004148A (en) 2020-11-27
CN112004148B CN112004148B (en) 2021-09-28

Family

ID=73465883

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010910582.2A Active CN112004148B (en) 2020-09-02 2020-09-02 Video processing method, video processing device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112004148B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114913050A (en) * 2022-05-30 2022-08-16 南京数睿数据科技有限公司 Watermark embedding method, device, electronic equipment and computer readable medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160035058A1 (en) * 2014-07-29 2016-02-04 Tata Consultancy Services Limited Digital watermarking
CN105848008A (en) * 2012-05-31 2016-08-10 富士通株式会社 Digital watermark detecting equipment and digital watermark detecting method
CN110267115A (en) * 2019-06-17 2019-09-20 东软集团股份有限公司 A kind of Video security control method, device, equipment and medium
CN110971931A (en) * 2018-09-30 2020-04-07 北京微播视界科技有限公司 Video watermark adding method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105848008A (en) * 2012-05-31 2016-08-10 富士通株式会社 Digital watermark detecting equipment and digital watermark detecting method
US20160035058A1 (en) * 2014-07-29 2016-02-04 Tata Consultancy Services Limited Digital watermarking
CN110971931A (en) * 2018-09-30 2020-04-07 北京微播视界科技有限公司 Video watermark adding method and device, electronic equipment and storage medium
CN110267115A (en) * 2019-06-17 2019-09-20 东软集团股份有限公司 A kind of Video security control method, device, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114913050A (en) * 2022-05-30 2022-08-16 南京数睿数据科技有限公司 Watermark embedding method, device, electronic equipment and computer readable medium
CN114913050B (en) * 2022-05-30 2023-09-12 南京数睿数据科技有限公司 Watermark embedding method, watermark embedding device, electronic equipment and computer readable medium

Also Published As

Publication number Publication date
CN112004148B (en) 2021-09-28

Similar Documents

Publication Publication Date Title
Atta et al. A high payload steganography mechanism based on wavelet packet transformation and neutrosophic set
CN111768327B (en) Watermark adding and extracting method and device based on deep learning and storage medium
US20230008085A1 (en) Method for embedding watermark in video data and apparatus, method for extracting watermark in video data and apparatus, device, and storage medium
KR101877372B1 (en) Method for embedding and extraction of watermarking data
US11134167B2 (en) Method of embedding and extracting watermark data using a correction image comparison with a noise-based image in the frequency domain
CN102147912A (en) Adaptive difference expansion-based reversible image watermarking method
KR101960290B1 (en) Method for embedding and extraction of watermarking data
CN113538197B (en) Watermark extraction method, watermark extraction device, storage medium and electronic equipment
CN112070648A (en) Watermark embedding method, watermark extracting method, watermark embedding device, watermark extracting device and electronic equipment
CN112004148B (en) Video processing method, video processing device, computer equipment and storage medium
CN114880687A (en) Document security protection method and device, electronic equipment and storage medium
CN113962838A (en) Watermark image embedding/enhancing method, device and computer system
US10706489B2 (en) Image processing device, image processing method, and program for generating water marks
CN109309869B (en) Watermark embedding method, device and storage medium
CN116127419A (en) Data processing method, data identification method, font file generation method and device
JP5036643B2 (en) Information processing apparatus, information processing method, and program
CN113409181A (en) Watermark processing method and device for watermark carrier
CN113538198B (en) Watermark adding method, device, storage medium and electronic equipment
Li et al. Block mapping and dual-matrix-based watermarking for image authentication with self-recovery capability
CN115937338B (en) Image processing method, device, equipment and medium
CN110662023B (en) Method and device for detecting video data loss and storage medium
Xia et al. Perceptual image hashing using rotation invariant uniform local binary patterns and color feature
CN112907429A (en) Digital signature setting and extracting method and device, storage medium and electronic equipment
CN117670639A (en) Normal map processing method and device, storage medium and electronic equipment
Borra et al. Watermarking Techniques for Copyright Protection of Texts in Document Files

Legal Events

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