A real-time image character watermarking method, device and electronic equipment
By replacing preset character library data in real time in the image data stream, the problem of high hardware and memory overhead in the existing technology is solved, and the addition of character watermarks to image data in real time is realized, simplifying the software operation process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHUHAI HUGE IC CO LTD
- Filing Date
- 2026-02-11
- Publication Date
- 2026-06-09
Smart Images

Figure CN122175756A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of character watermarking technology, and in particular to a method, apparatus and electronic device for adding character watermarks to images in real time. Background Technology
[0002] In video chip design, it's common practice to add watermarks containing time or other characters to displayed or compressed images to record time or other information. Typical video chips have sensor interfaces, such as the DVP parallel interface. The DVP interface receives data into the memory (MEM), and the LCD display and encoder modules retrieve data from the MEM, then add the watermark information and display it on the LCD and compressed image, respectively.
[0003] In existing technologies, YUV data output line by line from the sensor is received into the memory MEM via the sensor DVP interface. The LCD display module retrieves the data from the MEM buffer, converts the YUV data into RGB data, and then overlays it line by line with the OSD layer before pushing it onto the screen via SPI / MIPI or other interfaces. The OSD layer then contains the watermark information. For encoders such as MJPEG or H.264, the watermark information needs to be overlaid according to the smallest encoding unit of the MCU. One MCU is 16x16 pixels. For example, for YUV420 data, one MCU contains four 8x8 Y data, one 8x8 U data, and one 8x8 V data, and the watermark information is overlaid in 8x8 blocks.
[0004] In existing technologies, both the LCD display and the encoder read data from the same MEM memory and add watermark information separately, resulting in high hardware and memory overhead, and more complex software operation processes. Summary of the Invention
[0005] This invention provides a method, apparatus, and electronic device for adding character watermarks to images in real time. It solves the technical problem in existing technologies where both the LCD display and encoder read data from the same MEM memory and add watermark information separately, resulting in high hardware and memory overhead, and more complex software operation processes. The technical solution is as follows:
[0006] In a first aspect, embodiments of the present invention provide a method for adding character watermarks to images in real time, including:
[0007] Real-time acquisition of line-by-line image data stream;
[0008] Compare the current pixel coordinates of the image data stream with the preset watermark start coordinates to see if they are the same;
[0009] If they are the same, the original image corresponding to the current pixel is replaced with the preset character library data to obtain the watermark image data; where the preset character library data is the watermark color data;
[0010] The watermark image data is written into memory, and the display module and encoding module are controlled to read the watermark image data from memory.
[0011] In some embodiments of the present invention, before acquiring the line-by-line image data stream in real time, the method further includes:
[0012] Configure watermark parameters; wherein the watermark parameters include watermark start coordinates, character width, character height, number of characters, and watermark YUV color value.
[0013] In some embodiments of the present invention, the preset character library data is an N×M binary mask pixel matrix; wherein, the number of rows N of the binary mask pixel matrix corresponds to the character height, and the number of columns M of the binary mask pixel matrix corresponds to the character width.
[0014] In some embodiments of the present invention, replacing the original image corresponding to the current pixel with preset character library data includes:
[0015] When the current pixel of the image data stream is the same as the preset watermark start coordinate, the first row of pixel data of the first character of the watermark is read sequentially from the preset character library data, and the pixels of the original image are replaced pixel by pixel according to the first row of pixel data.
[0016] After completing the operation of the first character and the first line of the preset watermark, continue to read the first line of pixel data of the next character and replace the pixels until the operation of all characters of the first line of the preset watermark is completed;
[0017] Repeat the above process until all lines of the preset watermark have been added.
[0018] In some embodiments of the present invention, the line-by-line data stream is in YUYV data format, and during the replacement operation:
[0019] The Y component is replaced independently per pixel;
[0020] UV components are replaced in pairs, maintaining UV consistency between adjacent pixels during replacement.
[0021] In some embodiments of the present invention, it further includes:
[0022] If the current pixel coordinates of the image data stream are the same as the starting coordinates of the preset watermark, then the original image corresponding to the current pixel is mixed with the preset character library data.
[0023] In some embodiments of the present invention, the step of mixing the original image corresponding to the current pixel into preset character library data includes:
[0024] The Alpha blending algorithm is used to blend the original image corresponding to the current pixel into a preset character library data.
[0025] Secondly, the present invention also provides a device for adding character watermarks to images in real time, comprising:
[0026] The acquisition module is used to acquire line-by-line image data streams in real time;
[0027] The judgment module is used to compare whether the current pixel coordinates of the image data stream are the same as the preset watermark start coordinates;
[0028] The replacement module is used to replace the original image corresponding to the current pixel with preset character library data if they are the same, so as to obtain watermark image data; wherein, the preset character library data is watermark color data;
[0029] The reading module is used to write the watermark image data into memory and control the display module and the encoding module to read the watermark image data from memory.
[0030] Thirdly, the present invention also provides an electronic device, comprising: a processor and a memory;
[0031] The memory stores a computer-readable program that can be executed by the processor;
[0032] When the processor executes the computer-readable program, it implements the steps in the real-time image character watermarking method described above.
[0033] Fourthly, the present invention also provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the steps in the real-time image character watermarking method described above.
[0034] The beneficial effects of the technical solutions provided by some embodiments of the present invention include at least the following: by setting a preset watermark, before the real-time image data is written to memory, the original pixels of the image are directly replaced at the set coordinate position using the character library data of the preset watermark, and then the replaced data is written to memory. Finally, the LCD display and encoder module are controlled to obtain the watermarked data from the memory MEM, thereby achieving the purpose of adding character watermarks to the image data line by line in real time, thus reducing the problem of large hardware and memory overhead caused by the LCD display and encoder module adding watermarks separately. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 A system architecture diagram of an embodiment of the real-time image character watermarking method provided by the present invention;
[0037] Figure 2 A flowchart illustrating an embodiment of the method for adding character watermarks to real-time images provided by the present invention;
[0038] Figure 3 A schematic diagram of character lib data in the real-time image character watermarking method provided by this invention;
[0039] Figure 4 An example diagram of an embodiment of step S103 in the method for adding character watermarks to real-time images provided by the present invention;
[0040] Figure 5 This is a schematic diagram of an embodiment of the real-time image character watermarking device provided by the present invention;
[0041] Figure 6 This is a schematic diagram of the operating environment of an embodiment of the electronic device provided by the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0043] It should be noted that the real-time image watermarking method provided in this application is generally executed by the terminal device, and correspondingly, the real-time image watermarking device is generally installed in the terminal device.
[0044] Figure 1 An exemplary system architecture is shown that can be applied to the real-time image character watermarking method or device of this application.
[0045] like Figure 1As shown, the system architecture may include: terminal device 101 and server 102. Terminal device 101 and server 102 can communicate via a network, which serves as the medium for providing communication links between the various units. The network may include various types of wired or wireless communication links, such as: wired communication links including fiber optic cables, twisted-pair cables, or coaxial cables; and wireless communication links including Bluetooth communication links, Wi-Fi communication links, or microwave communication links.
[0046] It should be noted that the terminal device 101 and the server 102 can be either hardware or software. When the terminal device 101 and the server 102 are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the terminal device 101 and the server 102 are software, they can be implemented as multiple software programs or software modules (for example, to provide distributed services), or as a single software program or software module; no specific limitations are made here.
[0047] The terminal device of this application can be equipped with various communication client applications, such as video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0048] A terminal device can be either hardware or software. When the terminal device is hardware, it can be various terminal devices with a display screen, including but not limited to smartphones, tablets, laptops, and desktop computers. When the terminal device is software, it can be installed on the terminal devices listed above. It can be implemented as multiple software programs or software modules (e.g., used to provide distributed services) or as a single software program or software module; no specific limitation is made here.
[0049] When the terminal device is hardware, it can also be equipped with a display device and a camera. The display device can be any device capable of displaying information, and the camera is used to capture video streams. For example, the display device can be a cathode ray tube display (CR), a light-emitting diode display (LED), an e-ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. Users can use the display device on the terminal device to view displayed text, images, videos, and other information.
[0050] It should be understood that Figure 1The number of terminal devices, networks, and servers shown is for illustrative purposes only. Depending on implementation needs, there can be any number of terminal devices, networks, and servers.
[0051] The following will be combined with the appendix Figure 2 This application provides a detailed description of the real-time image character watermarking method provided in its embodiments. The real-time image character watermarking device in these embodiments can be... Figure 1 The terminal device shown.
[0052] Please see Figure 2 This is a flowchart illustrating a method for adding character watermarks to images in real time, as provided in this application embodiment. Figure 2 As shown, the method described in this application embodiment may include the following steps:
[0053] S201. Real-time acquisition of line-by-line image data stream;
[0054] It should be noted that the image data stream is YUYV data, and the specific format of the image data stream depends on the specific business requirements. By acquiring the image data stream line by line in real time, data omissions can be avoided.
[0055] In a specific embodiment, the progressive image YUYV data, such as a VGA resolution image of 640*480 (y=480, 480 rows of data, x=640), with 640 pixels per row and a pixel bit width of 8 bits, is YUYV data (i.e., YUV422 data, where each pixel has one Y and adjacent pixels in each row share one U and V). Each row contains 1280 bytes of data, for a total of 1280*480=614400 data.
[0056] S202. Compare whether the current pixel coordinates of the image data stream are the same as the starting coordinates of the preset watermark;
[0057] It should be noted that the preset watermark's starting coordinates are user-configured parameters, including but not limited to watermark starting coordinates, character width, character height, number of characters, watermark content pointer, and watermark YUV color values. It should also be noted that the watermark can be one or more independent watermark layers (e.g., one layer displays the time in the upper left corner, and another displays the location in the upper right corner), each with independent position, content, color, and transparency configurations, thus greatly enhancing the functionality.
[0058] In one specific embodiment, the configuration parameters include YUV data cfg_y, cfg_u, and cfg_v, character watermark starting coordinates ch_x_loc and ch_y_loc, character width and height ch_width and ch_height, and the number of characters ch_num.
[0059] It should be noted that after the frame synchronization signal is detected, the coordinates of the pixels in the subsequent rows of data are counted. When the row count reaches the coordinates of the starting row of the watermark, pixel counting begins within the pixel row; thus determining whether the current pixel coordinates have entered the watermark area.
[0060] S203. If they are the same, replace the original image corresponding to the current pixel with the preset character library data to obtain the watermark image data; wherein, the preset character library data is the watermark color data.
[0061] It should be noted that the preset character library data is an N×M binary mask pixel matrix; wherein, the number of rows N of the binary mask pixel matrix corresponds to the character height, and the number of columns M of the binary mask pixel matrix corresponds to the character width.
[0062] It should be noted that, as Figure 3 As shown, Figure 3 For character lib data, such as an 8x8 pixel character 0, binary 0 / 1 is used to represent whether to replace the original YUV data of the image, where 0 means no replacement and 1 means replacement. To add an 8x8 pixel character 0 to a progressive scan image, it will occupy 8 rows and 8 pixels.
[0063] S204. Write the watermark image data into memory, and control the display module and encoding module to read the watermark image data from memory.
[0064] It should be noted that adding watermarks at the data source reduces the physical basis for memory access overhead.
[0065] In this embodiment, by setting a preset watermark, the original pixels of the image are directly replaced at the set coordinate position using the character library data of the preset watermark before the real-time image data is written to memory. Then, the replaced data is written to memory. Finally, the LCD display and encoder module are controlled to retrieve the watermarked data from memory MEM. This achieves the purpose of adding character watermarks to line-by-line image data in real time, thereby reducing the problem of large hardware and memory overhead caused by the LCD display and encoder module adding watermarks separately.
[0066] In some embodiments of the present invention, the step of replacing the original image corresponding to the current pixel with preset character library data is described in the following example. Figure 4 ,include:
[0067] S401. When the current pixel of the image data stream is the same as the preset watermark start coordinate, the first row of pixel data of the first character of the watermark is read sequentially from the preset character library data, and the pixels of the original image are replaced pixel by pixel according to the first row of pixel data.
[0068] S402. After completing the operation of the first character and first line of the preset watermark, continue to read the first line of pixel data of the next character and replace the pixels until the operation of all characters of the first line of the preset watermark is completed.
[0069] S403. Repeat the above process until the character addition operation for all lines of the preset watermark is completed.
[0070] It's important to note that each character in the watermark is an individual number, letter, or symbol. For example, the timestamp "12:30:05" consists of 8 characters. The character library data is the template for each character, defining its graphic shape; it's binary data stored line by line. First, the first line of character library data for the first character is read. For example, to display "12:30", the first line of data for the character "1" is read (assuming 8 bits, such as 00011000). Then, based on these 8 bits, each pixel is processed. When a 1 is encountered, the original pixel is replaced with the watermark color; when a 0 is encountered, it is retained. After completing the first 8 pixels of the first character's first line, the x-coordinate has advanced 8 pixels. At this point, the first line of character library data for the "second character" (i.e., "2") is read, and the replacement operation is performed in the next 8 pixels. This process is repeated until the first line of data for ch_num characters has been processed. When the image scans to the next line (y-coordinate increments by 1), the above process is repeated, but this time the "second line of character library data" for each character is read. Once all ch_height lines (e.g., 8 lines) have been processed, a complete watermark frame is added.
[0071] In one specific embodiment, the line-by-line data stream is in YUYV data format. During the replacement operation: the Y component is replaced independently by pixel; the UV components are replaced in pairs, maintaining UV consistency between adjacent pixels during replacement.
[0072] Overlay watermarks permanently obscure part of the image content. In some embodiments of the present invention, an Alpha blending algorithm is used to blend the original image corresponding to the current pixel into preset character library data.
[0073] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0074] Please see Figure 5 This illustration shows a schematic diagram of a real-time image character watermarking device provided in an exemplary embodiment of this application, hereinafter referred to as device 5. Device 5 can be implemented as all or part of a terminal device through software, hardware, or a combination of both. Device 5 includes:
[0075] The acquisition module 510 is used to acquire line-by-line image data streams in real time;
[0076] The judgment module 520 is used to compare whether the current pixel coordinates of the image data stream are the same as the preset watermark start coordinates;
[0077] The replacement module 530 is used to replace the original image corresponding to the current pixel with preset character library data if they are the same, so as to obtain watermark image data; wherein, the preset character library data is watermark color data;
[0078] The reading module 540 is used to write the watermark image data into memory and control the display module and the encoding module to read the watermark image data from memory.
[0079] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figure 2 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figure 2 The specific details of the illustrated embodiments will not be elaborated here.
[0080] This application also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the real-time image character watermarking method as described in the above embodiments.
[0081] Please see Figure 6 This document provides a schematic diagram of the structure of a terminal device according to an embodiment of this application. Figure 6 As shown, the terminal device 600 may include: at least one processor 601, at least one network interface 604, user interface 603, memory 605, and at least one communication bus 602.
[0082] The communication bus 602 is used to enable communication between these components.
[0083] The user interface 603 may include a display screen and a camera. Optionally, the user interface 603 may also include a standard wired interface and a wireless interface.
[0084] The network interface 604 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0085] The processor 601 may include one or more processing cores. The processor 601 connects to various parts within the terminal device 600 using various interfaces and lines, and performs various functions and processes data of the terminal device 600 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 605, and by calling data stored in the memory 605. Optionally, the processor 601 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 601 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display on the screen; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 601 and may be implemented as a separate chip.
[0086] The memory 605 may include random access memory (RAM) or read-only memory. Optionally, the memory 605 may include a non-transitory computer-readable storage medium. The memory 605 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 605 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 605 may also be at least one storage device located remotely from the aforementioned processor 601. Figure 6 As shown, the memory 605, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.
[0087] exist Figure 6In the terminal device 600 shown, the user interface 603 is mainly used to provide an input interface for the user and to obtain the user's input data; while the processor 601 can be used to call the application program stored in the memory 605 and specifically execute, such as Figure 2 The method shown can be referred to for details. Figure 2 As shown, it will not be elaborated further here.
[0088] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0089] The above description discloses only preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.
Claims
1. A method for adding character watermarks to images in real time, characterized in that, include: Real-time acquisition of line-by-line image data stream; Compare whether the current pixel coordinates of the image data stream are the same as the starting coordinates of the preset watermark; If they are the same, the original image corresponding to the current pixel is replaced with the preset character library data to obtain the watermark image data; where the preset character library data is the watermark color data; The watermark image data is written into memory, and the display module and encoding module are controlled to read the watermark image data from memory.
2. The method for adding character watermarks to real-time images according to claim 1, characterized in that, Before acquiring the line-by-line image data stream in real time, the following is also included: Configure watermark parameters; wherein the watermark parameters include watermark start coordinates, character width, character height, number of characters, and watermark YUV color value.
3. The method for adding character watermarks to real-time images according to claim 2, characterized in that, The preset character library data is an N×M binary mask pixel matrix; wherein, the number of rows N of the binary mask pixel matrix corresponds to the character height, and the number of columns M of the binary mask pixel matrix corresponds to the character width.
4. The method for adding character watermarks to real-time images according to claim 1, characterized in that, The step of replacing the original image corresponding to the current pixel with preset character library data includes: When the current pixel of the image data stream is the same as the preset watermark start coordinate, the first row of pixel data of the first character of the watermark is read sequentially from the preset character library data, and the pixels of the original image are replaced pixel by pixel according to the first row of pixel data. After completing the operation of the first character and the first line of the preset watermark, continue to read the first line of pixel data of the next character and replace the pixels until the operation of all characters of the first line of the preset watermark is completed; Repeat the above process until all lines of the preset watermark have been added.
5. The method for adding character watermarks to real-time images according to claim 1, characterized in that, The line-by-line data stream is in YUYV data format. During the replacement operation: The Y component is replaced independently per pixel; UV components are replaced in pairs, maintaining UV consistency between adjacent pixels during replacement.
6. The method for adding character watermarks to real-time images according to claim 1, characterized in that, Also includes: If the current pixel coordinates of the image data stream are the same as the starting coordinates of the preset watermark, then the original image corresponding to the current pixel is mixed with the preset character library data.
7. The method for adding character watermarks to real-time images according to claim 1, characterized in that, The step of mixing the original image corresponding to the current pixel into preset character library data includes: The Alpha blending algorithm is used to blend the original image corresponding to the current pixel into a preset character library data.
8. A device for adding character watermarks to images in real time, characterized in that, include: The acquisition module is used to acquire line-by-line image data streams in real time; The judgment module is used to compare whether the current pixel coordinates of the image data stream are the same as the preset watermark start coordinates; The replacement module is used to replace the original image corresponding to the current pixel with preset character library data if they are the same, so as to obtain watermark image data; wherein, the preset character library data is watermark color data; The reading module is used to write the watermark image data into memory and control the display module and the encoding module to read the watermark image data from memory.
9. An electronic device, characterized in that, include: Processor and memory; The memory stores a computer-readable program that can be executed by the processor; When the processor executes the computer-readable program, it implements the steps of the real-time image character watermarking method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the steps of the real-time image character watermarking method as described in any one of claims 1-7.