Timestamp watermark data generation method and apparatus, electronic device, and storage medium
By disassembling the target timestamp and generating initial timestamp watermark data during image data capture, and adjusting the color using a dynamic color mode, the problem of poor performance in adding timestamp watermarks in existing technologies is solved, achieving efficient, real-time generation and readability of timestamp watermarks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
- Filing Date
- 2026-03-10
- Publication Date
- 2026-05-29
AI Technical Summary
In mobile video application scenarios, existing technologies for adding timestamp watermarks have poor performance, cannot achieve real-time generation, and suffer from high memory consumption and high implementation complexity.
By acquiring image data in a preset format, the target timestamp is broken down into multiple character data, and the corresponding target character data is determined from a pre-built character dataset to generate initial timestamp watermark data. The color is dynamically adjusted in combination with the watermark color mode to finally generate the target timestamp watermark data. This supports instant generation and real-time saving during image data capture.
It achieves efficient and real-time generation of timestamp watermarks, reduces memory consumption, ensures effective recognition and readability of timestamp information in various scenarios, and improves the performance of timestamp watermark addition in the system.
Smart Images

Figure CN122120560A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, electronic device and storage medium for generating timestamp watermark data. Background Technology
[0002] In mobile video applications, timestamp watermarks, as a key information carrier recording the video capture time, are widely used in security monitoring, evidence preservation, and motion recording. Their core function is to provide an immutable time credential for video content, ensuring the timeliness, authenticity, and traceability of video data. Especially in scenarios requiring event retracing, accurate, reliable, and visual timestamp watermarks have become a crucial component of video data integrity. Therefore, how to add timely and accurate timestamp watermarks to video data has become a hot research topic. Summary of the Invention
[0003] This application discloses a method, apparatus, electronic device, and storage medium for generating timestamp watermark data, which solves the technical problem of poor performance in adding timestamp watermarks.
[0004] In a first aspect, this application provides a method for generating timestamp watermark data. The method includes: acquiring image data in a preset format, the image data carrying a target timestamp, the target timestamp being used to represent the acquisition time of the image data; decomposing the target timestamp to obtain multiple target time characters included in the target timestamp, and determining target character data corresponding to each target time character from a pre-constructed character dataset; generating initial timestamp watermark data of the image data based on the multiple target character data, the character dataset including multiple character data in a preset format, each character data corresponding to a time character used to compose the timestamp; and generating target timestamp watermark data of the image data based on the watermark color mode and the initial timestamp watermark data.
[0005] Secondly, this application also provides a device for generating timestamp watermark data. The device includes: an acquisition module for acquiring image data in a preset format, the image data carrying a target timestamp, the target timestamp representing the acquisition time of the image data; a generation module for decomposing the target timestamp to obtain multiple target time characters included in the target timestamp, determining target character data corresponding to each target time character from a pre-constructed character dataset, and generating initial timestamp watermark data of the image data based on the multiple target character data, the character dataset including multiple character data in a preset format, each character data corresponding to a time character used to compose the timestamp; the generation module is further configured to generate target timestamp watermark data of the image data based on the watermark color mode and the initial timestamp watermark data.
[0006] Thirdly, this application also provides an electronic device, including: a processor; and a storage device for storing a program, which, when executed by the processor, causes the electronic device to implement the method for generating timestamp watermark data as described above.
[0007] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer's processor, causes the computer to perform the method for generating timestamp watermark data as described above.
[0008] The beneficial effects of this application: This application provides a method, apparatus, electronic device, and storage medium for generating timestamp watermark data. First, image data in a preset format is acquired. This image data carries a target timestamp to represent the acquisition time of the image data. Then, the target timestamp is decomposed to obtain multiple target time characters included in the target timestamp. Target character data corresponding to each target time character is determined from a pre-constructed character dataset. Initial timestamp watermark data for the image data is generated based on the multiple target character data. The character dataset includes multiple character data in a preset format, each character data corresponding to a time character used to compose the timestamp. Finally, target timestamp watermark data for the image data is generated based on the watermark color mode and the initial timestamp watermark data. This is achieved by pre-constructing... When image data is captured, the system can directly determine multiple target character data corresponding to the target timestamp of the image data from the pre-built character dataset to generate initial timestamp watermark data. It then dynamically adjusts the watermark color based on the watermark color mode to generate the target timestamp watermark data. This supports real-time generation of timestamp watermarks during image data capture, enabling real-time preview and saving. It eliminates the need for bitmap conversion and overlay operations on the timestamp of each frame, reducing memory consumption and achieving efficient, real-time generation of timestamp watermarks. Furthermore, it possesses the ability to dynamically adjust the timestamp watermark color according to the watermark color mode, ensuring effective recognition of timestamp information in various scenarios. This solves the problem of poor readability of timestamp watermarks and improves the system's timestamp watermark addition performance. Attached Figure Description
[0009] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0010] In the attached diagram:
[0011] Figure 1 This is a schematic diagram illustrating an implementation environment of an optional timestamp watermark data generation apparatus, as shown in an exemplary embodiment of this application. Figure 2 This is a schematic flowchart illustrating an optional timestamp watermark data generation method in an exemplary embodiment of this application; Figure 3 This is a schematic diagram illustrating an optional process for constructing a character dataset, as shown in an exemplary embodiment of this application. Figure 4 This is a schematic diagram illustrating an optional process for generating initial timestamp watermark data, as shown in an exemplary embodiment of this application. Figure 5 This is a schematic diagram illustrating an optional process for generating target timestamp watermark data, as shown in an exemplary embodiment of this application. Figure 6 This is a schematic diagram illustrating an optional process for determining target values for color components, as shown in an exemplary embodiment of this application. Figure 7 This is a schematic diagram illustrating another optional process for generating target timestamp watermark data, as shown in an exemplary embodiment of this application. Figure 8 This is a schematic diagram illustrating an optional overlay timestamp watermark process in an exemplary embodiment of this application; Figure 9 This is a flowchart illustrating an optional specific timestamp watermark overlay method as shown in an exemplary embodiment of this application; Figure 10 This is a block diagram illustrating an optional timestamp watermark data generation apparatus according to an exemplary embodiment of this application; Figure 11 This is a schematic diagram illustrating the structure of an optional electronic device, as shown in an exemplary embodiment of this application. Detailed Implementation
[0012] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0013] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. The drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the shape, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0014] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the present application. However, it will be apparent to those skilled in the art that embodiments of the present application may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the present application.
[0015] Timestamp watermarks, as a key information carrier for recording the time of video recording, are widely used in security monitoring, evidence preservation, and motion recording. Technical solutions for adding timestamp watermarks mainly fall into two categories: post-processing and real-time addition, but both have significant limitations in practical applications.
[0016] On the one hand, post-processing techniques rely on FFmpeg (an audio and video codec tool). This involves reusing and decoding the saved original video recordings to obtain frame data in YUV (Lumaand Chrominance) or RGB (Red, Green, Blue) formats. Then, libfreetype (a font rendering library) loads the font, draws the timestamp text at a specified position in each frame, and finally re-encodes the processed frames to add the timestamp watermark. However, this approach is inefficient, unable to achieve real-time display, and fails to meet real-time requirements. Furthermore, it relies on accurate recording start times, making it susceptible to system time jumps, leading to inconsistencies between the timestamp watermark and the actual recording time. Additionally, it involves complex JNI (Java Native Interface) layer interactions, library file trimming, and hardware encoding / decoding adaptation, increasing development time and maintenance costs.
[0017] On the other hand, real-time watermarking solutions rely on either CameraAPI + Canvas (camera application programming interface combined with canvas drawing) or CameraAPI + OpenGLES (camera application programming interface combined with open graphics library embedded system). The former obtains the camera preview image through SurfaceView or TextureView, and in the onDraw() callback, uses Canvas.drawText() to draw the formatted current system time onto the preview layer. The latter uses ImageReader to obtain the raw image data, and in onImageAvailable(), generates a watermark image containing a timestamp through bitmap pixel manipulation, then performs hardware encoding using a media codec. More complex implementations further combine OpenGLES, using a custom GLSurfaceView to implement timestamp texture overlay in the shader, leveraging the parallel computing power of the graphics processor to improve watermark drawing efficiency. While this approach satisfies the real-time requirements and ensures consistency between the timestamp watermark and the actual shooting time to some extent, using a canvas or bitmap for watermark overlay results in high memory consumption, leading to time-consuming processing. Furthermore, the implementation scheme is relatively complex, and issues such as limited real-time performance, high implementation complexity, and inability to guarantee watermark display quality still exist.
[0018] Therefore, please see Figure 1 , Figure 1 This is a schematic diagram illustrating an implementation environment of an optional timestamp watermark data generation apparatus, as shown in an exemplary embodiment of this application. Figure 1 As shown, the implementation environment may include a timestamp watermark data generation device 110 and a computer device 120. The timestamp watermark data generation device 110 can be installed within the computer device 120 to generate timestamp watermark data. The computer device 120 can be at least one of a desktop graphics processing unit (GPU) computer, a GPU computing cluster, or a neural network computer. This timestamp watermark data generation device 110 generates initial timestamp watermark data by determining multiple target character data corresponding to the target timestamp from a pre-built character dataset, and dynamically adjusts the watermark color based on the watermark color mode to generate the target timestamp watermark data. It supports real-time generation of timestamp watermarks during image data capture, enabling real-time preview and real-time saving. It eliminates the need for bitmap conversion and overlay operations on the timestamp of each frame of data, reducing memory consumption and achieving efficient, real-time generation of timestamp watermarks. Furthermore, it has the ability to dynamically adjust the timestamp watermark color according to the watermark color mode, ensuring effective recognition of timestamp information in various scenarios, solving the problem of poor readability of timestamp watermarks, and improving the system's timestamp watermark addition performance.
[0019] Please see Figure 2 , Figure 2 This is a schematic flowchart illustrating an optional timestamp watermark data generation method according to an exemplary embodiment of this application. This method can be applied to... Figure 1 The implementation environment shown is specifically executed by the timestamp watermark data generation device 110 in that implementation environment. It should be understood that this method can also be applied to other exemplary implementation environments and specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment to which the method is applicable.
[0020] In addition, this method for generating timestamp watermark data is applicable to various operating systems, including but not limited to the generation of timestamp watermark data for image data under the Android operating system.
[0021] like Figure 2 As shown, in an exemplary embodiment, the method for generating timestamp watermark data includes at least steps S210 to S230, which are described in detail below: Step S210: Obtain image data in a preset format. The image data carries a target timestamp, which is used to indicate the acquisition time of the image data.
[0022] Image data can be obtained through methods such as shooting, screen recording, screenshotting, and scanning. It is usually stored in a specific data format and contains the color information of the image. The target timestamp refers to the actual time when the image data was acquired, which is usually provided by the system's internal clock.
[0023] Step S220: Decompose the target timestamp to obtain multiple target time characters included in the target timestamp, and determine the target character data corresponding to each target time character from the pre-built character dataset, as well as the initial timestamp watermark data of the image data generated based on the multiple target character data. The character dataset includes multiple character data in a preset format, and each character data corresponds to a time character used to form the timestamp.
[0024] The character dataset refers to a pre-built set of character data that contains all possible characters used to represent timestamps. Each character data in this dataset has the same data format as the image data to facilitate subsequent overlay processing. The initial timestamp watermark data refers to the preliminary timestamp watermark data that is extracted from the character dataset based on the multiple target time characters included in the target timestamp. This data is consistent with the image data in format.
[0025] Step S230: Generate target timestamp watermark data for image data based on watermark color mode and initial timestamp watermark data.
[0026] Among them, the watermark color mode refers to the preset rules used to determine the final display color of the timestamp watermark; the target timestamp watermark data refers to the timestamp watermark data that is finally superimposed on the image data after further processing based on the initial timestamp watermark data according to the selected watermark color mode. This data contains complete display information of the timestamp, such as content and color, and is consistent with the image data in format.
[0027] In this embodiment, initial timestamp watermark data is generated by determining multiple target character data corresponding to the target timestamp from a pre-built character dataset. Target timestamp watermark data is then generated by dynamically adjusting the watermark color based on the watermark color mode. This supports real-time generation of timestamp watermarks during image data capture, enabling real-time preview and saving. It eliminates the need for bitmap conversion and overlay operations on the timestamp of each frame, reducing memory consumption and achieving efficient, real-time generation of timestamp watermarks. Furthermore, it possesses the ability to dynamically adjust the timestamp watermark color according to the watermark color mode, ensuring effective recognition of timestamp information in various scenarios. This solves the problem of poor readability of timestamp watermarks and improves the system's timestamp watermark addition performance.
[0028] For example, the preset format is the input format required by the media codec.
[0029] The image data output by the camera is in YUV420SP (YUV 4:2:0 Semi-Planar), which includes two sub-formats: NV21 and NV12. Both are YUV 4:2:0 semi-plane VU interleaved formats, but the former stores chroma components in VU order, while the latter stores chroma components in UV order. Typically, the image data output by the camera is configured in NV21 format. For example, on the Android platform, the camera output data is configured in NV21 format, while the media codec typically inputs NV12 data. Therefore, the image data mentioned above is YUV data in NV12 format, while the camera output data is configured in NV21 format. Thus, obtaining image data involves converting from NV21 to NV12 format.
[0030] For example, the color component values include luminance component values and chromaticity component values, wherein the luminance component values include the Y component and the chromaticity component values include the UV components.
[0031] In one possible embodiment, considering that the only difference between NV21 and NV12 formats is the order of UV data, when converting from NV21 to NV12, only the UV components need to be considered, and their positions adjusted. The conversion of the camera's output raw data into image data includes: determining the total number of pixels in the displayed image based on the image resolution, and determining the total length of the raw data based on the total number of pixels; copying the first few bytes of the raw data to the positions of the first few bytes of the image data to complete the conversion of the luminance component values; setting a traversal index j after the first few bytes of the raw data, and traversing in groups of two bytes; for each group of bytes, writing the (j+1)th byte of the raw data to the j-th position of the image data, and writing the j-th byte of the raw data to the (j+1)-th position of the image data to complete the conversion of the chrominance component values.
[0032] For example, an image resolution of 8 4. Therefore, the total number of pixels in the displayed image is 32. The raw data (NV21 format) output by the camera is shown in Table 1: Table 1
[0033] Image data (NV12 format) is shown in Table 2: Table 2
[0034] As shown in Table 1 and Table 2, when converting the original data into image data, only the position adjustment of the UV components needs to be performed.
[0035] In one embodiment, please refer to Figure 3 , Figure 3 which is a schematic flow chart of an optional process for constructing a character data set shown in an exemplary embodiment of the present application. As Figure 3 shown, the method for constructing the character data set at least includes: Step S310, determining a set of time characters for forming a time stamp watermark according to a preset time stamp format; Step S320, converting each time character in the set of time characters into a bitmap image according to a preset image resolution and a preset character display ratio; Step S330, for each time character, converting the bitmap image corresponding to the time character into character data in a preset format; Step S340, forming a character data set according to each character data.
[0036] Among them, the time stamp format is used to clarify the display structure and content of the time stamp watermark; the image resolution and the character display ratio are jointly used to accurately control the visual size of each character on the screen.
[0037] In addition, the present application does not limit the specific time stamp format. For example, if the time stamp format is YYYY-MM-dd HH:mm:ss, the corresponding all time stamp characters include the numbers "0-9", the separator "-", the colon and the space, or if it is YYYY year MM month dd day HH hour mm minute ss second, the corresponding all time stamp characters include the numbers "0-9" and the words "year", "month", "day", "hour", "minute", and "second".
[0038] In this embodiment, considering that in the generation of time stamp watermark data, if the bitmap image generation operation of each time stamp character is performed each time, it will increase the system consumption and affect the watermark overlay efficiency. Therefore, all the time characters used to form the time stamp watermark are pre-converted into character data in the same format as the image data to form a character data set, thereby reducing the system consumption and ensuring the watermark overlay efficiency during the generation process of the time stamp watermark data.
[0039] Specifically, by determining the required set of time characters through a preset timestamp format, the integrity and standardization of the timestamp content are ensured. A bitmap image is generated by combining the image resolution and character display ratio, ensuring that the visual presentation of each character matches the image size. This improves the readability of watermarks that are too large or too small, and is adaptable to timestamp watermark overlay at different image resolutions. Converting the obtained bitmap image into character data with the same format as the image data solves the data format incompatibility problem, laying the foundation for seamless watermark overlay. Finally, by constructing a structured character dataset, centralized management and efficient retrieval of all character data are achieved. This ensures that the generated timestamp watermarks are visually clear, appropriately sized, and highly compatible with the image data at the data level, significantly improving the accuracy, efficiency, and overall display quality of timestamp watermark overlay.
[0040] In one possible embodiment, the character dataset exists in the form of an index or mapping, thereby enabling the rapid retrieval and acquisition of multiple target character data based on multiple target time characters included in the target timestamp.
[0041] In one possible embodiment, for each time character, the bitmap image corresponding to the time character is converted into character data in a preset format, including: extracting the red component value, green component value and blue component value of each pixel in the bitmap image; calculating the luminance component value of each pixel based on the red component value, green component value and blue component value, and generating character data in a preset format based on the luminance component value of each pixel.
[0042] As one possible implementation, before generating character data in a preset format based on the luminance component values of each pixel, if the luminance component value corresponding to any pixel is negative, then the luminance component value corresponding to that pixel is set to 0; if the luminance component value corresponding to any pixel is greater than 255, then the luminance component value corresponding to that pixel is set to 255. This effectively ensures that the luminance component values are always within the legal range of [0, 255], improving watermark distortion or display abnormalities caused by numerical overflow.
[0043] For example, the formula for calculating the luminance component value is: Equation (1) in, Indicates the luminance component value; Indicates the red component value; Indicates the green component value; This represents the blue component value.
[0044] In addition, the character data in a preset format generated according to the luminance component values of each pixel represents a black-and-white timestamp watermark. If a color timestamp watermark is required, the chrominance component values of each pixel need to be calculated according to the red component value, green component value, and blue component value, and the corresponding character data is generated according to the luminance component value and chrominance component value of each pixel.
[0045] In one embodiment, please refer to Figure 4 , Figure 4 which is a schematic flow diagram of an optional method for generating initial timestamp watermark data shown in an exemplary embodiment of the present application. As Figure 4 shown, generating the initial timestamp watermark data of the image data according to multiple target character data at least includes: step S410, determining the arrangement order of multiple target time characters according to the target timestamp; step S420, arranging the multiple target character data according to the arrangement order to obtain the initial timestamp watermark data.
[0046] Here, "multiple" means three or more, and there may be the same time characters among the multiple target time characters. For example, if the acquisition time is 09:30:00 on December 30, 2025, then there are 3 time characters "2" corresponding to it.
[0047] In this embodiment, by determining the arrangement order of multiple target time characters according to the target timestamp and arranging the multiple target character data accordingly to generate the initial timestamp watermark data, the watermark content can be strictly consistent with the image acquisition time, ensuring the accuracy of the timestamp watermark.
[0048] Continuing with the example where the acquisition time is 09:30:00 on December 30, 2025, if the timestamp format is YYYY year MM month dd day HH hour mm minute ss second, then the target time characters and their arrangement order determined according to this acquisition time are 2, 0, 2, 5, year, 1, 2, month, 3, 0, day, 0, 9, hour, 3, 0, minute, 0, 0, second. Then, the corresponding target character data is determined from the character data set according to these target characters, and the target character data is arranged according to the above arrangement order to obtain the initial timestamp watermark data corresponding to this acquisition time.
[0049] In one embodiment, please refer to Figure 5 , Figure 5 which is a schematic flow diagram of an optional method for generating target timestamp watermark data shown in an exemplary embodiment of the present application. As Figure 5As shown, generating target timestamp watermark data for image data based on watermark color mode and initial timestamp watermark data includes at least the following steps: Step S510, in response to the watermark color mode being a dynamic color mode, color sampling is performed on the image data according to a preset watermark display area and a preset pixel sampling interval to obtain multiple color component sampling values; Step S520, based on the multiple color component sampling values, the target color component values of the timestamp watermark are determined; Step S530, the initial timestamp watermark data is color-adjusted according to the target color component values to obtain the target timestamp watermark data.
[0050] Among them, dynamic color mode means that the color of the timestamp watermark will be adaptively adjusted according to the background color of the image data overlaid on it; watermark display area refers to the specific area in the image data where the timestamp watermark data needs to be overlaid; pixel sampling interval is used to control the density of color sampling in the watermark display area, for example, sampling once every N pixels; the watermark display area and pixel sampling interval can be set according to specific situations or needs.
[0051] In this embodiment, considering that the background color of the image data can lead to poor display of the timestamp watermark, the color of the timestamp watermark is determined according to the background color of the image data in order to improve the clarity and readability of the timestamp watermark.
[0052] Specifically, instead of traversing the entire displayed image, color sampling is performed only in the watermark display area using a sampling interval method. This obtains multiple representative background color component sampling values, thereby determining the target values of the color components of the timestamp watermark data. This not only effectively ensures the clarity of the timestamp watermark but also reduces performance loss. In this way, by accurately perceiving the background color and adaptively adjusting the watermark color, the problem of unclear display and poor readability of the timestamp watermark due to its similarity to the background color is effectively solved in complex or variable image backgrounds. It can also cope with the problem of poor display effect of timestamp watermark in images displayed under extreme lighting conditions such as outdoors and at night.
[0053] For example, adjusting the color of the initial timestamp watermark data according to the target value of the color components to obtain the target timestamp watermark data includes: modifying the color component values in the initial timestamp watermark data according to the target value of the color components to obtain the target timestamp watermark data.
[0054] In one embodiment, please refer to Figure 6 , Figure 6 This is a schematic diagram illustrating an optional process for determining target values for color components, as shown in an exemplary embodiment of this application. Figure 6As shown, determining the target value of the color components of the timestamp watermark based on multiple color component sampling values includes at least the following steps: Step S610, calculating the average value of multiple color component sampling values; Step S621, if the average value is greater than or equal to a preset threshold, then determining the preset dark color component value as the target value of the color component; Step S622, if the average value is less than the preset threshold, then determining the preset light color component value as the target value of the color component.
[0055] In this embodiment, the average value is compared with a preset threshold. If the average value is greater than or equal to the preset threshold, it indicates that the background area where the timestamp watermark will be superimposed is generally too bright. Therefore, the preset dark color component value is determined as the target value of the color component, so that the color of the timestamp watermark will be set to dark to ensure that it is clearly visible. If the average value is less than the preset threshold, it indicates that the background area where the timestamp watermark will be superimposed is generally too dark. Therefore, the preset light color component value is determined as the target value of the color component, so that the color of the timestamp watermark will be set to light to ensure that it is clearly visible.
[0056] In this way, by calculating the average value of the sampling area and comparing it with a preset threshold, the dark or light color is intelligently selected as the target value of the color component of the watermark, so that the timestamp watermark can maintain good contrast and clarity in the bright or dark areas of the image.
[0057] For example, the color component sample values include luminance component sample values and / or chrominance component sample values; the color component target values include luminance component target values and / or chrominance component target values.
[0058] In this exemplary embodiment, if the color component sample value only includes the luminance component sample value, then the color component target value only includes the luminance component target value.
[0059] For example, the color component sampling value only includes the luminance component sampling value, the corresponding preset threshold is set to 128, the dark color component value is set to 0, and the light color component value is set to 255. In this case, if the luminance component sampling value is greater than or equal to the corresponding 128, the color component target value is 0, and the corresponding timestamp watermark is a black watermark. If the luminance component sampling value is less than 128, the color component target value is 255, and the corresponding timestamp watermark is a white watermark.
[0060] In one embodiment, please refer to Figure 7 , Figure 7 This is a schematic diagram illustrating another optional process for generating target timestamp watermark data, as shown in an exemplary embodiment of this application. Figure 7As shown, the method for generating target timestamp watermark data for image data based on watermark color mode and initial timestamp watermark data includes at least the following steps: Step S710, in response to the watermark color mode being a static color mode and the set color being a default color, determining the initial timestamp watermark data as target timestamp watermark data, wherein the default color is the color of each character data in the character dataset; Step S720, in response to the watermark color mode being a static color mode and the set color being a custom color, adjusting the initial timestamp watermark data according to the color component values corresponding to the custom color to obtain target timestamp watermark data.
[0061] Among them, static color mode means that the color of the timestamp watermark is fixed based on a pre-set value; default color means that the preset color information carried by each character data itself when constructing the character dataset, for example, when generating a bitmap image of a character, it can be set to white, black or other specific colors, and the generated character data carries the corresponding color information; custom color means that the user specifies the color, such as red, and can also extend to more colors, such as blue, green, etc.
[0062] In this embodiment, if the watermark color mode is static color mode and the set color is the default color, it means that there is no need to modify the color of the initial timestamp watermark data, and it can be directly regarded as the final target timestamp watermark data; if the watermark color mode is static color mode and the set color is a custom color, it means that the color of the initial timestamp watermark data needs to be modified, that is, based on the initial timestamp watermark data, its original color information is replaced with the color component values of the custom color, thereby generating the target timestamp watermark data.
[0063] For example, if the custom color is dark red, the corresponding color component value will replace the original color information carried by the initial timestamp watermark data.
[0064] In this way, by introducing a static color mode and combining it with a dynamic color mode, the flexibility and applicability of overlaying colors in timestamp watermarks are greatly enhanced, thereby optimizing the visual effect and user experience of timestamp watermarks.
[0065] For example, adjusting the color of the initial timestamp watermark data according to the color component value corresponding to the custom color to obtain the target timestamp watermark data includes: traversing the target pixels that constitute the time character in the initial timestamp watermark data and modifying the color component value of the target pixel to the color component value corresponding to the custom color.
[0066] In one possible embodiment, generating target timestamp watermark data for image data based on watermark color mode and initial timestamp watermark data further includes: in response to the watermark color mode being a static color mode and the set color being a custom color, if the average value of multiple color component sampling values corresponding to the image data is greater than or equal to a preset threshold, then determining the dark color component value corresponding to the custom color as the target color component value; in response to the watermark color mode being a static color mode and the set color being a custom color, if the average value of multiple color component sampling values corresponding to the image data is less than a preset threshold, then determining the light color component value corresponding to the custom color as the target color component value; and adjusting the initial timestamp watermark data according to the target color component value to obtain the target timestamp watermark data.
[0067] For example, if the custom color is red, then if the average of the sampled values of multiple color components corresponding to the image data is greater than or equal to a preset threshold, the dark color component value corresponding to red will be determined as the target value of the color component, that is, the timestamp watermark will be dark red. If the average of the sampled values of multiple color components corresponding to the image data is less than the preset threshold, the light color component value corresponding to red will be determined as the target value of the color component, that is, the timestamp watermark will be bright red.
[0068] As one possible implementation, in custom color mode, the shade of the custom color can be determined based on the background color of the image, balancing the visual effect of the timestamp watermark with the user's customization experience.
[0069] In one embodiment, please refer to Figure 8 , Figure 8 This is a schematic diagram illustrating an optional overlay timestamp watermark process, as shown in an exemplary embodiment of this application. Figure 8 As shown, after generating the target timestamp watermark data of the image data based on the watermark color mode and the initial timestamp watermark data, the method further includes at least the following steps: Step S810, determining the starting overlay position of the target timestamp watermark data in the image data according to the preset watermark display area, wherein the starting overlay position includes a first starting overlay position on the luminance component plane and a second starting overlay position on the chrominance component plane; Step S820, writing the luminance data in the target timestamp watermark data into the luminance component plane based on the first starting overlay position, and writing the chrominance data in the target timestamp watermark data into the chrominance component plane based on the second starting overlay position, thereby obtaining image data containing the timestamp watermark.
[0070] The starting overlay position refers to the coordinate point at which the target timestamp watermark data begins to be written into the image data.
[0071] In this embodiment, after determining the first starting overlay position on the luminance component plane, the system writes the corresponding luminance data from the target timestamp watermark data pixel by pixel into the luminance component plane of the image data, that is, the luminance information of the target timestamp watermark directly replaces the luminance information at the corresponding position in the image data. Similarly, after determining the second starting overlay position on the chrominance component plane, the system writes the corresponding chrominance data from the target timestamp watermark data pixel by pixel into the chrominance component plane of the image data.
[0072] In this way, determining the starting overlay position of the target timestamp watermark data in the image data based on the watermark display area can adapt to timestamp watermark overlay under various image resolutions. The overlay process of the target timestamp watermark data is refined into operating on the luminance component plane and chrominance component plane of the image data separately, and determining an independent starting overlay position for each plane. This can effectively ensure that the watermark is drawn only at the position where the time character needs to be displayed, which saves computing resources and significantly improves the overlay quality and readability of the watermark.
[0073] For example, the overlay process of timestamp watermarks is implemented through the platform's native code. In this way, the overlay rendering of timestamp watermarks does not rely on OpenGLES, reducing the dependence on third-party graphics libraries, significantly reducing system development complexity, reducing the amount of code, and improving code maintainability.
[0074] In one possible embodiment, after obtaining image data containing a timestamp watermark, the method further includes: encoding the image data containing the timestamp watermark to obtain a display image; rendering the display image frame by frame to the page for real-time display; and / or saving the display image frame by frame to generate a video file.
[0075] Please see Figure 9 , Figure 9 This is a flowchart illustrating an optional specific timestamp watermark overlay method, as shown in an exemplary embodiment of this application. Figure 9As shown, the specific timestamp watermark overlay method includes: constructing a character dataset; determining whether the camera is on; if not, ending the process; if yes, acquiring image data in a preset format, the image data carrying a target timestamp; determining the initial timestamp watermark data corresponding to the image data based on the target timestamp and the character dataset; determining whether the watermark color mode is a dynamic color mode; if yes, performing color sampling on the image data according to the preset watermark display area and the preset pixel sampling interval to obtain multiple color component sampling values, and determining the target color component value of the timestamp watermark based on the multiple color component sampling values, and then adjusting the initial timestamp watermark data according to the target color component value to obtain the target timestamp watermark. Data; if not, determine if the set color is the default color. If yes, determine the initial timestamp watermark data as the target timestamp watermark data. If not, adjust the initial timestamp watermark data according to the color component values corresponding to the custom color to obtain the target timestamp watermark data. Overlay the target timestamp watermark data onto the image data to obtain image data containing the timestamp watermark. Encode the image data containing the timestamp watermark to obtain the display image. Render the display image frame by frame to the page for real-time display and save the display image frame by frame to generate a video file. Determine if the camera is off. If yes, end; if not, continue to obtain image data in the preset format and overlay the timestamp watermark.
[0076] The above-described method for generating timestamp watermark data first acquires image data in a preset format, which carries a target timestamp to represent the acquisition time of the image data. Then, the target timestamp is decomposed to obtain multiple target time characters included in the target timestamp. The target character data corresponding to each target time character is determined from a pre-constructed character dataset. Initial timestamp watermark data for the image data is generated based on these multiple target character data. The character dataset includes multiple character data in a preset format, with each character data corresponding to a time character used to compose the timestamp. Finally, the target timestamp watermark data for the image data is generated based on the watermark color mode and the initial timestamp watermark data. The system generates initial timestamp watermark data by identifying multiple target character data corresponding to the target timestamp from a pre-built character dataset, and dynamically adjusts the watermark color based on the watermark color mode to generate target timestamp watermark data. It supports real-time generation of timestamp watermarks during image data capture, enabling real-time preview and real-time saving. It eliminates the need to perform bitmap conversion and overlay operations on the timestamp of each frame of data, reducing memory consumption and achieving efficient and real-time generation of timestamp watermarks. Furthermore, it has the ability to dynamically adjust the timestamp watermark color according to the watermark color mode, ensuring effective recognition of timestamp information in various scenarios. This solves the problem of poor readability of timestamp watermarks and improves the performance of timestamp watermark addition in the system.
[0077] Please see Figure 10 , Figure 10 This is a block diagram illustrating an optional timestamp watermark data generation apparatus according to an exemplary embodiment of this application. The apparatus can be applied to... Figure 1 The implementation environment shown is intended to illustrate an application of this device in other exemplary environments. This embodiment does not limit the application environment to which the device is applicable.
[0078] like Figure 10 As shown, in an exemplary embodiment, the timestamp watermark data generation device 1000 includes at least a data acquisition module 1010 and a generation module 1020, which are described in detail below: The acquisition module 1010 is used to acquire image data in a preset format. The image data carries a target timestamp, which is used to indicate the acquisition time of the image data. The generation module 1020 is used to decompose the target timestamp to obtain multiple target time characters included in the target timestamp, determine the target character data corresponding to each target time character from the pre-built character dataset, and generate the initial timestamp watermark data of the image data based on the multiple target character data. The character dataset includes multiple character data in a preset format, and each character data corresponds to a time character used to compose the timestamp. The generation module 1020 is also used to generate target timestamp watermark data for image data based on the watermark color mode and the initial timestamp watermark data.
[0079] It should be noted that the timestamp watermark data generation device and the timestamp watermark data generation method provided in the above embodiments belong to the same concept. The content of the operation performed by each module has been described in detail in the method embodiments, and will not be repeated here.
[0080] Please see Figure 11 , Figure 11 This is a schematic diagram illustrating the structure of an optional electronic device, as shown in an exemplary embodiment of this application. Figure 11 A schematic diagram of a computer system suitable for implementing the embodiments of this application is shown. It should be noted that... Figure 11 The computer system 1100 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0081] like Figure 11As shown, the computer system 1100 includes a Central Processing Unit (CPU) 1101, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 1102 or programs loaded from storage portion 1108 into Random Access Memory (RAM) 1103. The RAM 1103 also stores various programs and data required for system operation. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An Input / Output (I / O) interface 1105 is also connected to the bus 1104.
[0082] The following components are connected to I / O interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to I / O interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1110 as needed so that computer programs read from them can be installed into storage section 1108 as needed.
[0083] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by central processing unit (CPU) 1101, it performs various functions defined in the system of this application.
[0084] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer's processor, causes the computer to perform the timestamp watermark data generation method described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not deployed within that electronic device.
[0085] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0086] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method for generating timestamp watermark data, characterized in that, The method includes: Acquire image data in a preset format, wherein the image data carries a target timestamp, which is used to represent the acquisition time of the image data; The target timestamp is decomposed to obtain multiple target time characters included in the target timestamp, and the target character data corresponding to each target time character is determined from a pre-constructed character dataset. Initial timestamp watermark data of the image data is generated based on the multiple target character data. The character dataset includes multiple character data in a preset format, and each character data corresponds to a time character used to compose the timestamp. The target timestamp watermark data of the image data is generated based on the watermark color mode and the initial timestamp watermark data.
2. The method for generating timestamp watermark data according to claim 1, characterized in that, The character dataset is constructed in the following ways: The set of time characters used to compose the timestamp watermark is determined according to the preset timestamp format; Based on the preset image resolution and preset character display ratio, each time character in the time character set is converted into a bitmap image; For each time character, the bitmap image corresponding to the time character is converted into character data in a preset format; The character dataset is composed of data for each character.
3. The method for generating timestamp watermark data according to claim 1, characterized in that, The initial timestamp watermark data for generating the image data based on multiple target character data includes: Based on the target timestamp, determine the arrangement order of the plurality of target time characters; The initial timestamp watermark data is obtained by arranging multiple target character data according to the given order.
4. The method for generating timestamp watermark data according to claim 1, characterized in that, The process of generating the target timestamp watermark data for the image data based on the watermark color mode and the initial timestamp watermark data includes: In response to the watermark color mode being a dynamic color mode, the image data is color sampled according to the preset watermark display area and the preset pixel sampling interval to obtain multiple color component sampling values. Based on the multiple color component sampling values, determine the target values of the color components of the timestamp watermark; The initial timestamp watermark data is color-adjusted according to the target value of the color components to obtain the target timestamp watermark data.
5. The method for generating timestamp watermark data according to claim 4, characterized in that, Determining the target color component values of the timestamp watermark based on the multiple color component sampling values includes: Calculate the average value of the multiple color component samples; If the average value is greater than or equal to a preset threshold, then the preset dark color component value is determined as the target value of the color component. If the average value is less than the preset threshold, then the preset bright color component value is determined as the target value of the color component.
6. The method for generating timestamp watermark data according to claim 1, characterized in that, The method for generating the target timestamp watermark data of the image data based on the watermark color mode and the initial timestamp watermark data further includes: In response to the watermark color mode being static color mode and the set color being the default color, the initial timestamp watermark data is determined as the target timestamp watermark data, wherein the default color is the color of each character data in the character dataset; In response to the watermark color mode being static color mode and the set color being a custom color, the initial timestamp watermark data is color-adjusted according to the color component values corresponding to the custom color to obtain the target timestamp watermark data.
7. The method for generating timestamp watermark data according to any one of claims 1 to 6, characterized in that, After generating the target timestamp watermark data of the image data based on the watermark color mode and the initial timestamp watermark data, the method further includes: Based on the preset watermark display area, the starting overlay position of the target timestamp watermark data in the image data is determined, wherein the starting overlay position includes a first starting overlay position on the luminance component plane and a second starting overlay position on the chrominance component plane. Based on the first starting overlay position, the luminance data in the target timestamp watermark data is written into the luminance component plane, and based on the second starting overlay position, the chrominance data in the target timestamp watermark data is written into the chrominance component plane to obtain image data containing timestamp watermark.
8. A device for generating timestamp watermark data, characterized in that, The device includes: The acquisition module is used to acquire image data in a preset format. The image data carries a target timestamp, which is used to indicate the acquisition time of the image data. The generation module is used to decompose the target timestamp to obtain multiple target time characters included in the target timestamp, determine the target character data corresponding to each target time character from a pre-built character dataset, and generate initial timestamp watermark data of the image data based on the multiple target character data. The character dataset includes multiple character data in a preset format, and each character data corresponds to a time character used to compose the timestamp. The generation module is also used to generate target timestamp watermark data for the image data based on the watermark color mode and the initial timestamp watermark data.
9. An electronic device, characterized in that, include: processor; A storage device for storing a program that, when executed by the processor, causes the electronic device to implement the method for generating timestamp watermark data as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It stores a computer program that, when executed by the computer's processor, causes the computer to perform the method for generating timestamp watermark data as described in any one of claims 1 to 7.