Animation image processing method and embedded display device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- QINGYANG RUNCAI (GUANGZHOU) TECHNOLOGY CO LTD
- Filing Date
- 2026-05-07
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]现有技术中,动画显示通常采用原始逐帧位图或者GIF、APNG等通用动画格式,或者采用索引色图像加调色板的压缩方式, 或者采用AI图像生成技术用于动画素材制作,但原始逐帧位图数据量大,占用存储空间高;通用动画格式解码过程较复杂,对运行内存和处理能力要求较高,不利于在ESP32等资源有限的平台上流畅运行;索引色压缩方式在多帧动画场景下又容易出现颜色失真、细节丢失和显示效果不稳定;AI 图像生成方式存在背景不统一、边缘过渡不稳定、相邻帧细微抖动等情况,会增加处理负担,影响最终显示质量
上述的动画图像处理方法中,通过获取若干组初始动画数据,基于预设提取条件,对各初始动画数据进行图像提取,得到多个第一图像;对各第一图像进行背景色统一处理,得到各第二图像和各对应第二图像的背景色;对各第二图像进行颜色量化处理,得到各第三图像,并对各第三图像分别配置相应的调色板;基于各背景色,对各第三图像的调色板进行颜色索引,得到各背景色索引;对各第三图像、各调色板和各背景色索引建立映射关系,得到映射后数据,并对映射后数据进行缓存,以基于映射后数据进行图像渲染,实现在较低存储和算力消耗下,提高动画的显示效果。
Smart Images

Figure CN122526673A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of embedded display device technology, and in particular to an animation image processing method and an embedded display device. Background Technology
[0002] With the development of embedded display devices and desktop interactive electronic products, more and more application scenarios need to display character animations, facial animations, or short-term looping dynamic images on resource-constrained hardware platforms.
[0003] For example, in devices based on microcontrollers such as ESP32, it is often necessary to play pet images or interactive animations on small-sized displays to enhance the product's visual appeal and interactive experience.
[0004] In existing technologies, animation display typically uses raw frame-by-frame bitmaps or common animation formats such as GIF and APNG, or compression methods using indexed color images with a color palette, or AI image generation technology for animation material production. However, raw frame-by-frame bitmaps have large data volumes and occupy a lot of storage space; the decoding process of common animation formats is relatively complex, requiring high memory and processing power, which is not conducive to smooth operation on resource-limited platforms such as ESP32; indexed color compression methods are prone to color distortion, loss of detail, and unstable display effects in multi-frame animation scenarios; AI image generation methods have issues such as inconsistent backgrounds, unstable edge transitions, and slight jitter between adjacent frames, which increase the processing burden and affect the final display quality. Summary of the Invention
[0005] Based on this, and addressing the technical problems existing in the aforementioned resource-constrained embedded display platforms, an animation image processing method and embedded display device are provided that can achieve better animation display effects with lower storage and computing power consumption.
[0006] In a first aspect, this application provides an animation image processing method applied to a resource-constrained embedded display device, the method comprising: Several sets of initial animation data are acquired, and images are extracted from each set of initial animation data based on preset extraction conditions to obtain multiple first images; The background color of each first image is uniformly processed to obtain each second image and the background color of each corresponding second image; Each second image is subjected to color quantization processing to obtain a third image, and a corresponding color palette is configured for each third image. Based on each background color, the color palette of each third image is indexed to obtain the background color index; A mapping relationship is established for each third image, each color palette, and each background color index to obtain the mapped data. The mapped data is then cached for image rendering.
[0007] In one embodiment, the step of extracting images from each initial animation data based on preset extraction conditions to obtain multiple first images includes: Based on a preset frame rate, each initial animation data is sampled to obtain sampled animation data, and the sampled animation data is converted to RGB format to obtain converted animation data; Based on the sharpening scaling algorithm, the converted animation data is scaled to a size that fits the screen resolution of the embedded display device to obtain each first image; the preset frame rate is between 4 and 30 fps, and the sharpening scaling algorithm uses the Lanczos resampling filter with the filter window parameter a set to 3.
[0008] In one embodiment, the step of performing background color unification processing on each first image to obtain each second image includes: Obtain at least one corner pixel of the corresponding first image, and obtain the background color of the corresponding first image based on each corner pixel; Perform Euclidean distance processing on each pixel of the first image and the corresponding background color of the first image to obtain the first distance value of each corresponding pixel; The pixels in the corresponding first image whose first distance is less than the preset tolerance value are replaced with the background color to obtain each second image; the preset tolerance value is a Euclidean distance unit between 50 and 200.
[0009] In one embodiment, the step of obtaining at least one corner pixel of the corresponding first image and obtaining the background color of the corresponding first image based on each corner pixel includes: Obtain the four corner pixels of the corresponding first image, perform average processing on the values of the four corner pixels to obtain the pixel mean, and determine the pixel mean as the background color of the corresponding first image.
[0010] In one embodiment, the step of performing color quantization processing on each second image to obtain each third image includes: Based on the median cutting algorithm, color quantization is performed on each second image to obtain each third image; the output color quantization has 256 colors, the color palette configured for each third image occupies 768 bytes, and the pixel index bit depth of the third image is 8 bits.
[0011] In one embodiment, the step of color indexing the palette of each third image based on each background color to obtain each background color index includes: Iterate through the RGB values of each color in the palette of each third image, calculate the Euclidean distance between each color's RGB value and the corresponding background color, and determine the index of the color with the smallest distance as the background color index of the corresponding third image; After caching the mapped data, the following steps are included: Based on the mapped data, retrieve the color palette and background color index of the corresponding third image; Image rendering is performed based on the color palette and background color index of the corresponding third image.
[0012] In one embodiment, the step of rendering the image based on the color palette of the corresponding third image and the background color index of the corresponding third image includes: During image rendering, if the current pixel matches the background color index, the current pixel is skipped; in several sets of initial animation data, the proportion of background color pixels is not less than 80%, corresponding to a pixel skipping rate of not less than 80% during image rendering.
[0013] In one embodiment, the step of caching the mapped data includes: Obtain the frame sequence number feature information of each third image; Each third image is converted to binary to obtain binary image data, and the binary image data is cached in the frames.bin preset binary file; Configure a palette index for the palette of the corresponding third image, and cache the palette index, background color index, and frame sequence number feature information in the index.json preset animation index file; each frame in the preset binary file occupies 40,000 to 41,000 bytes, the palette field does not exceed 768 bytes, and the pixel index field is 40,000 bytes.
[0014] In one embodiment, after the step of rendering the image based on the mapped data, the following steps are included: The program acquires the rendered image and displays it centered on the screen. The screen size is larger than the rendered image size. The screen includes a status bar and a subtitle bar, positioned adjacent to the corresponding side of the rendered image. The screen size is no less than 240×240 pixels, the rendered image size is 200×200 pixels, and an A8-format rounded corner mask is set at the bottom of the screen. The radius of the rounded corner mask does not exceed 50 pixels, and the A8-format rounded corner mask occupies no more than 5 KB of memory.
[0015] In one embodiment, all animations in several sets of initial animation data share the same global first frame; the third image and color palette corresponding to the global first frame in the mapped data are cached only once; the starting frame index of each set of animations is recorded in the form of an offset in a preset animation index file, and the offset points to the starting position of the unique frame sequence of each set of animations; when the number of several sets of initial animation data is N, the mapped data saves (N-1)×(W×H+256×3) bytes of storage space compared with the independent caching scheme; where N is 10 and W=H=200, the storage space saved is about 358KB.
[0016] In one embodiment, the step of rendering an image based on the mapped data further includes: maintaining a single buffer pool in the memory of the embedded display device, the single buffer pool consisting of several pre-allocated frame buffers, each frame buffer having four states: idle, decoding, ready, and in use, and configuring an 8-bit reference count; when rendering is requested, retrieving the ready buffer corresponding to the third image frame number from the single buffer pool and incrementing its reference count; if it does not exist, retrieving the idle buffer for decoding; after rendering is completed, decrementing the reference count of the ready buffer; when the reference count reaches zero and exceeds a preset retention time, the ready buffer is reclaimed to the idle state.
[0017] In one embodiment, the method further includes: setting a preset emotion bucket mapping table, which maps several semantic emotion categories of external input to three emotion buckets; the number of semantic emotion categories of external input is not less than 21; each of the three emotion buckets is associated with an animation composed of two third images; when receiving external emotion input, the emotion bucket is determined according to the preset emotion bucket mapping table, and a selection is made based on the two animations associated with the emotion bucket.
[0018] In one embodiment, the method further includes: maintaining a probability weight table between the device state and several groups of animations, and randomly selecting animations based on the current device state; maintaining a recently played history window with a history window length of 10; skipping animations already existing in the history window when selecting a non-main animation; adopting a ping-pong strategy for playing the selected animation: reversing the playback direction when reaching the endpoint; and randomly selecting a period length from 12 to 16 frames in each playback cycle.
[0019] Secondly, this application also provides an embedded display device, including a processing module and a display module, wherein the processing module is connected to the display module and is used to perform the steps of any of the above-described animation image processing methods.
[0020] One of the above technical solutions has the following advantages and beneficial effects: In the above-described animation image processing method, several sets of initial animation data are acquired, and image extraction is performed on each initial animation data based on preset extraction conditions to obtain multiple first images; background color unification processing is performed on each first image to obtain each second image and the background color of each corresponding second image; color quantization processing is performed on each second image to obtain each third image, and a corresponding color palette is configured for each third image; based on each background color, color indexing is performed on the color palette of each third image to obtain each background color index; a mapping relationship is established between each third image, each color palette, and each background color index to obtain mapped data, and the mapped data is cached for image rendering based on the mapped data, thereby improving the display effect of the animation with lower storage and computing power consumption.
[0021] This application optimizes the initial animation data by extracting images and quantizing colors, thereby storing more frames in a limited space. By unifying the background color of the first image and configuring an independent color palette for the corresponding third image, the color quality of the main character is ensured, maximizing the color performance of the animation within a limited palette capacity. Image rendering is performed through corresponding mapping relationships, resulting in low memory usage and ensuring display quality. Attached Figure Description
[0022] Figure 1 This is a schematic diagram illustrating the application environment of the animation image processing method in the embodiments of this application; Figure 2 This is a flowchart illustrating the animation image processing method in an embodiment of this application; Figure 3 This is a flowchart illustrating the image extraction steps in an embodiment of this application; Figure 4 This is a flowchart illustrating the background color processing steps in an embodiment of this application. Figure 5 This is a flowchart illustrating the image rendering steps in an embodiment of this application; Figure 6 This is a flowchart illustrating the data caching steps in an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments.
[0024] Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0026] It should be understood that the data used in this way can be interchanged where appropriate, so as to the embodiments of this application described herein.
[0027] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.
[0028] In addition, the term "multiple" should mean two or more.
[0029] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0030] The present application will now be described in detail with reference to the accompanying drawings and embodiments.
[0031] The animation image processing method provided in this application can be applied to, for example... Figure 1 The application environment shown.
[0032] Among them, embedded display devices can be embedded voice display devices, such as resource-constrained embedded display devices based on models such as ESP32, or embedded display devices adapted to small-sized display devices such as TFT and LCD. Embedded display devices can be used to display character animations, facial animations, or short-term looping dynamic images.
[0033] The embedded display device includes a processing module 10 and a display module 20. The processing module 10 is connected to the display module 20, which is used to display pet images or interactive animations to enhance the product's visual appeal and interactive experience.
[0034] For example, the display module 20 can be a small-sized display device such as TFT, LCD, OLED, or IPS.
[0035] The processing module 10 may include a processor 102 and a memory 104. The processor 102 is connected to the memory 104, which is used to store background color index, color palette, third image and mapped data, etc.
[0036] The processor 102 is used to acquire several sets of initial animation data, extract images from each initial animation data based on preset extraction conditions, and obtain multiple first images; perform background color unification processing on each first image to obtain each second image and the background color of each corresponding second image; perform color quantization processing on each second image to obtain each third image, and configure a corresponding color palette for each third image; perform color indexing on the color palette of each third image based on each background color to obtain each background color index; establish a mapping relationship between each third image, each color palette, and each background color index to obtain mapped data, and cache the mapped data for image rendering based on the mapped data.
[0037] The animation image processing method provided in this application achieves high-quality animation display under low storage conditions through lightweight processing such as extraction, optimization, quantization, indexing, and caching.
[0038] In one embodiment, such as Figure 2 As shown, an animation image processing method is also provided, including: Step S210: Obtain several sets of initial animation data, and extract images from each set of initial animation data based on preset extraction conditions to obtain multiple first images.
[0039] The initial animation data can be, but is not limited to, an MP4 format animated video.
[0040] Preset extraction conditions may include extraction conditions for the corresponding extraction frame frequency and extraction scaling ratio.
[0041] The size of the first image is compatible with the physical resolution of the embedded display device's screen.
[0042] For example, 11 sets of initial animation data are obtained, and images are extracted from each set of initial animation data based on preset extraction conditions, thereby outputting 99 first images to compress the animation data and reduce the space occupied by the animation data.
[0043] Step S220: Perform background color unification processing on each first image to obtain each second image and the background color of each corresponding second image.
[0044] By unifying the background color of the corresponding first image, the background of the corresponding first communication is unified to the corresponding solid color. In subsequent quantization steps, only one color in the color palette is used, and the remaining 255 colors are all allocated to the main character and other effective content, thereby maximizing the effective color allocation. In addition, it eliminates the subtle color differences and noise in the background area of the image, avoids the appearance of color spots, color blocks and other artifacts in the background after quantization, and ensures that the background is clean and uniform. The pure background color makes the background color index detection in subsequent steps more accurate, so that the background pixels can be accurately skipped during image rendering, and the character can be seamlessly superimposed on any base image.
[0045] Step S230: Perform color quantization processing on each second image to obtain each third image, and configure the corresponding color palette for each third image.
[0046] The initial animation data of each group has a large difference in color distribution (for example, the "happy" animation is warm-colored, while the "sleeping" animation is cool-colored).
[0047] If all frames share a single 256-color palette, each animation group can only actually receive about 23 colors, resulting in a significant drop in image quality.
[0048] By performing color quantization on each second image and configuring corresponding color palettes for the third images obtained from the corresponding color quantization, each frame of the image can use all 256 colors to express the corresponding colors, thereby improving image quality.
[0049] For example, images are extracted from 11 sets of initial 280×240 animation data to obtain 99 frames of 200×200 first images. By quantizing the colors of the corresponding second images and configuring an independent 256-color palette for each frame, the 99 frames of images are compressed from 19.0 MB to 2.5 MB (total compression ratio of 13.1%), saving 86.9% of storage space, thereby storing more frames of images in a limited storage space.
[0050] Step S240: Based on each background color, perform color indexing on the color palette of each third image to obtain each background color index.
[0051] By indexing the color palette of each third image, the color index closest to the detected background color is found, and thus the background color index is obtained. When rendering the image, pixels with the corresponding background color index are skipped, so that the character animation can be superimposed on any background image and the background color area can automatically reveal the underlying background.
[0052] Step S250: Establish a mapping relationship between each third image, each color palette and each background color index to obtain the mapped data, and cache the mapped data for image rendering based on the mapped data.
[0053] By establishing mapping relationships between each third image, each color palette, and each background color index, and caching the mapped data, frame data can be directly read from the mapped data during image rendering. Decoding only requires a table lookup operation, with a memory usage of only about 80 KB, achieving zero-copy rendering.
[0054] In the above embodiments, by acquiring several sets of initial animation data, and based on preset extraction conditions, image extraction is performed on each initial animation data to obtain multiple first images; background color unification processing is performed on each first image to obtain each second image and the background color of each corresponding second image; color quantization processing is performed on each second image to obtain each third image, and a corresponding color palette is configured for each third image; based on each background color, color indexing is performed on the color palette of each third image to obtain each background color index; a mapping relationship is established between each third image, each color palette, and each background color index to obtain mapped data, and the mapped data is cached for image rendering based on the mapped data, thereby improving the display effect of the animation with lower storage and computing power consumption.
[0055] This application optimizes the initial animation data by extracting images and quantizing colors, thereby storing more frames in a limited space. By unifying the background color of the first image and configuring an independent color palette for the corresponding third image, the color quality of the main character is ensured, maximizing the color performance of the animation within a limited palette capacity. Image rendering is performed through corresponding mapping relationships, resulting in low memory usage and ensuring display quality.
[0056] In one embodiment, such as Figure 3 As shown, the steps for extracting images from each initial animation data based on preset extraction conditions to obtain multiple first images include: Step S310: Based on the preset frame rate, sample each initial animation data to obtain sampled animation data, and convert the sampled animation data to RGB format to obtain converted animation data.
[0057] The preset frame rate can be obtained from the system preset. For example, the original initial animation data is about 24fps, and it is sampled at 4fps, that is, 1 frame is taken every 6 frames.
[0058] By sampling each initial animation data according to a preset frame rate, the sampled animation data is obtained.
[0059] Furthermore, the sampled animation data can be converted to RGB format to obtain animation data.
[0060] Step S320: Based on the sharpening scaling algorithm, the converted animation data is scaled to a size that adapts to the screen resolution of the embedded display device to obtain each first image.
[0061] The preset frame rate is between 4 and 30 fps, and the sharpening and scaling algorithm uses a Lanczos resampling filter with a filter window parameter 'a' set to 3. The sharpening and scaling algorithm refers to the Lanczos algorithm.
[0062] For example, if the size of the sampled animation data is 280×240, based on the Lanczos algorithm, the corresponding 280×240 sampled animation data is scaled to a first image of size 200×200 that is adapted to the screen resolution of the embedded display device, so as to compress the animation data and reduce the space occupied by the animation data.
[0063] In one embodiment, such as Figure 4 As shown, the steps for unifying the background color of each first image to obtain each second image include: Step S410: Obtain at least one corner pixel of the corresponding first image, and obtain the background color of the corresponding first image based on each corner pixel.
[0064] The first image is rectangular in shape and has four corners. Corner pixels refer to the pixels closest to the corresponding corner point.
[0065] For example, a corner pixel of the corresponding first image is obtained, and then the color of the corresponding corner pixel is determined as the background color of the corresponding first image.
[0066] For example, two or more corner pixels of the corresponding first image are obtained, and the average value of each corner pixel is processed. Then, the color of the average pixel is determined as the background color of the corresponding first image.
[0067] Step S420: Perform Euclidean distance processing on each pixel of the first image and the corresponding background color of the first image to obtain the first distance value of each corresponding pixel.
[0068] For example, if the pixel colors of the first image are set to (Ri, Gi, Bi) and the background color is set to (R0, G0, B0), then the formula for calculating the Euclidean distance is: .
[0069] The first distance value of each corresponding pixel is obtained by inputting the color value of each pixel of the first image and the color value of the corresponding background color of the first image into the Euclidean distance calculation formula.
[0070] Step S430: Replace the pixels in the corresponding first image whose first distance is less than the preset tolerance value with the background color to obtain each second image.
[0071] The preset tolerance value is obtained based on the system preset.
[0072] For example, the preset tolerance value is between 50 and 200 in European distance units.
[0073] By comparing the first distance of the corresponding pixel with a preset tolerance value, and based on the comparison result, when the first distance of the corresponding pixel is less than the preset tolerance value, the corresponding pixel is replaced with the background color. Then, the first image after the background color is uniformly processed is confirmed as the corresponding second image. After the background area of the corresponding image is uniformly processed, it only occupies 1 slot in the color palette during quantization, and the remaining 255 colors are all allocated to the main character and other effective content, which improves the image detail and color transition quality, ensures that the background of the image is clean and uniform, and improves the background purity.
[0074] In one embodiment, the step of obtaining at least one corner pixel of a corresponding first image and obtaining the background color of the corresponding first image based on each corner pixel includes: Obtain the four corner pixels of the corresponding first image, perform average processing on the values of the four corner pixels to obtain the pixel mean, and determine the pixel mean as the background color of the corresponding first image.
[0075] For example, the first image has four corners. By searching for the corner pixels, the four pixel corners of the corresponding first image are obtained. The four corner pixels are averaged, and the color of the averaged pixel is determined as the background color of the corresponding first image, thus realizing the background color detection of the corresponding first image. Then, the Euclidean distance between each pixel in the first image and the corresponding background color is calculated. Pixels with Euclidean distances less than a preset tolerance value are replaced with the background color to obtain the second images, ensuring that the background is pure and uniform, and eliminating subtle color differences and noise.
[0076] In one embodiment, the step of performing color quantization processing on each second image to obtain each third image includes: Based on the median cropping algorithm, color quantization is performed on each second image to obtain each third image.
[0077] Among them, the Median Cut algorithm is used to extract a representative few colors from a large number of colors.
[0078] For example, the output color quantization has 256 colors, each third image's color palette occupies 768 bytes, and the pixel index depth of the third image is 8 bits.
[0079] For example, based on the median cropping algorithm, color quantization is performed independently on the second image of each frame, reducing the number of colors from approximately 16 million (RGB888) to 256, thereby achieving image compression optimization.
[0080] It should be noted that each frame of the image requires an additional 768 bytes of color palette storage (256 colors x 3 bytes RGB888).
[0081] However, compared to pixel data (40,000 bytes), the palette overhead accounts for only 1.9%, ensuring the color quality of the main character and maximizing the color performance of the animation within the limited palette capacity.
[0082] In one embodiment, the step of indexing the color palette of each third image based on each background color to obtain each background color index includes: traversing the RGB values of each color in the color palette of each third image, calculating the Euclidean distance between each RGB value and the corresponding background color, and determining the color index with the smallest distance as the background color index of the corresponding third image.
[0083] By traversing the RGB values of each color in the color palette, calculating its Euclidean distance from the corresponding background color, and determining the index of the color with the smallest distance as the background color index for that frame, we can provide support for the pseudo-transparent effect during subsequent rendering.
[0084] In one embodiment, such as Figure 5 As shown, after the step of caching the mapped data, the following steps are included: Step S510: Based on the mapped data, retrieve the color palette and background color index of the corresponding third image.
[0085] The mapped data can be cached in the corresponding folder. When image rendering is required, the corresponding file is queried to obtain the color palette and background color index of the corresponding third image.
[0086] For example, each third image is converted into binary image data and cached in the frames.bin preset binary file; a unique color palette index is configured for each color palette, and the color palette index, background color index, and frame sequence number feature information of the third image are cached in the index.json preset animation index file; when rendering images based on the mapped data later, the color palette and background color index of the corresponding frame can be quickly retrieved through the index file.
[0087] Step S520: Render the image according to the color palette of the corresponding third image and the background color index of the corresponding third image.
[0088] Image rendering is performed using the color palette and background color index corresponding to the third image, which improves the display effect of the animation, consumes little memory, and ensures display quality.
[0089] In one embodiment, the step of rendering an image based on the color palette of the corresponding third image and the background color index of the corresponding third image includes: during image rendering, if the current pixel matches the background color index, the current pixel is skipped; in several sets of initial animation data, the proportion of background color pixels is not less than 80%, and the pixel skipping rate during image rendering is not less than 80%.
[0090] By skipping the current pixel with the corresponding background color index during image rendering, pseudo-transparency is achieved. This allows character animations to be overlaid on any background image, with the background color area automatically revealing the underlying background.
[0091] In the above embodiments, lightweight rendering is achieved by skipping pixels that match the background color index during rendering, thus enabling the overlay of the character with any background image.
[0092] In one embodiment, such as Figure 6 As shown, the steps for caching the mapped data include: Step S610: Obtain the frame sequence number feature information of each third image.
[0093] The feature information may include the frame number of the corresponding third image, etc.
[0094] Step S620: Perform binary conversion on each third image to obtain binary image data, and cache the binary image data in the frames.bin preset binary file.
[0095] The frames.bin default binary file can be a frames.bin binary file.
[0096] By performing binary conversion on each third image, binary image data is obtained, and then the binary image data is written to the frames.bin binary file.
[0097] Step S630: Configure the color palette index for the corresponding third image, and cache the color palette index, background color index, and frame sequence number feature information in the index.json preset animation index file.
[0098] In the preset binary file, each frame occupies 40,000 to 41,000 bytes, the palette field does not exceed 768 bytes, and the pixel index field is 40,000 bytes.
[0099] The index.json preset animation index file can be the index.json animation index file.
[0100] By configuring a palette index for the corresponding third image's palette, the palette of the corresponding third image can be quickly retrieved; by writing the palette index, background color index, and feature information into a preset animation index file, the image of the corresponding frame can be quickly and accurately retrieved during animation playback, thereby improving the animation's display effect.
[0101] In one embodiment, after the step of rendering the image based on the mapped data, the following steps are included: The program acquires the rendered image and displays it centered on the screen. The screen size is larger than the rendered image size. The screen includes a status bar and a subtitle bar, positioned adjacent to the corresponding side of the rendered image. The screen size is no less than 240×240 pixels, the rendered image size is 200×200 pixels, and an A8-format rounded corner mask is set at the bottom of the screen. The radius of the rounded corner mask does not exceed 50 pixels, and the A8-format rounded corner mask occupies no more than 5 KB of memory.
[0102] For example, the display screen has a size of 280×240, and the rendered image has a size of 200×200. The rendered image is centered on the display screen, and the space above and below the display screen is reused for the status bar and subtitle bar. The rounded corner mask at the bottom of the display screen and the three-section bottom bar design create the visual effect of the character jumping out of the screen, which only increases the memory consumption by 3.1 KB and enhances the screen visual effect.
[0103] In one embodiment, all animations in several sets of initial animation data share the same global first frame; the third image and color palette corresponding to the global first frame in the mapped data are cached only once; the starting frame index of each set of animations is recorded in the form of an offset in a preset animation index file, and the offset points to the starting position of the unique frame sequence of each set of animations; when the number of several sets of initial animation data is N, the mapped data saves (N-1)×(W×H+256×3) bytes of storage space compared with the independent caching scheme; where N is 10 and W=H=200, the storage space saved is about 358KB.
[0104] In one embodiment, the step of rendering an image based on the mapped data further includes: maintaining a single buffer pool in the memory of the embedded display device, the single buffer pool consisting of several pre-allocated frame buffers, each frame buffer having four states: idle, decoding, ready, and in use, and configuring an 8-bit reference count; when rendering is requested, retrieving the ready buffer corresponding to the third image frame number from the single buffer pool and incrementing its reference count; if it does not exist, retrieving the idle buffer for decoding; after rendering is completed, decrementing the reference count of the ready buffer; when the reference count reaches zero and exceeds a preset retention time, the ready buffer is reclaimed to the idle state.
[0105] In one embodiment, the animation image processing method further includes: setting a preset emotion bucket mapping table, which maps several semantic emotion categories of external input to three emotion buckets; the number of semantic emotion categories of external input is not less than 21; each of the three emotion buckets is associated with an animation composed of two third images; when receiving external emotion input, the emotion bucket is determined according to the preset emotion bucket mapping table, and a selection is made based on the two animations associated with the emotion bucket.
[0106] In one embodiment, the animation image processing method further includes: maintaining a probability weight table between the device state and several groups of animations, and randomly selecting animations based on the current device state; maintaining a recently played history window with a history window length of 10; skipping animations already existing in the history window when selecting a non-main animation; adopting a ping-pong strategy for playing the selected animation: reversing the playback direction when reaching the endpoint; and randomly selecting a period length from 12 to 16 frames in each playback cycle.
[0107] It should be understood that, although Figures 2 to 6 The steps in the flowchart are shown sequentially according to the arrows, but these steps are not necessarily executed in the order indicated by the arrows.
[0108] Unless otherwise specified in this document, there is no strict order in which these steps are performed, and they may be performed in any other order.
[0109] and, Figures 2 to 6 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0110] In one embodiment, an animation image processing apparatus is also provided, comprising: The image extraction unit is used to acquire several sets of initial animation data, and extract images from each set of initial animation data based on preset extraction conditions to obtain multiple first images.
[0111] The background color processing unit is used to perform background color unification processing on each first image to obtain the background color of each second image and the corresponding background color of each second image.
[0112] The color quantization unit is used to perform color quantization processing on each second image to obtain each third image, and to configure a corresponding color palette for each third image.
[0113] The color indexing unit is used to index the color palette of each third image based on each background color, so as to obtain each background color index.
[0114] The mapping processing unit is used to establish mapping relationships between each third image, each color palette, and each background color index, obtain mapped data, and cache the mapped data for image rendering based on the mapped data.
[0115] For specific limitations on animation image processing devices, please refer to the limitations on animation image processing methods mentioned above, which will not be repeated here.
[0116] Each module in the aforementioned animation image processing device can be implemented entirely or partially through software, hardware, or a combination thereof.
[0117] The above modules can be embedded in the processor of the embedded display device in hardware form or independent of it, or they can be stored in the memory of the embedded display device in software form, so that the processor can call and execute the corresponding operations of the above modules.
[0118] In one embodiment, an embedded display device is also provided, including a processing module and a display module, the processing module being connected to the display module, and the processing module being used to perform the steps of any of the above-described animation image processing methods.
[0119] For example, the processing module is used to perform the following steps of the animated image processing method: The processing module acquires several sets of initial animation data, extracts images from each set of initial animation data based on preset extraction conditions, and obtains multiple first images. It then performs background color unification processing on each first image to obtain each second image and its corresponding background color. Next, it performs color quantization processing on each second image to obtain each third image, and configures a corresponding color palette for each third image. Based on each background color, it performs color indexing on the color palette of each third image to obtain each background color index. Finally, it establishes a mapping relationship between each third image, each color palette, and each background color index to obtain mapped data, and caches the mapped data for image rendering. This improves the animation display effect with lower storage and computing power consumption.
[0120] In the above embodiments, image extraction and color quantization of the initial animation data are performed to compress and optimize the initial animation data, thereby storing more frames in a limited storage space; background color unification processing of the first image and configuration of an independent color palette for the corresponding third image ensure the color quality of the main character, thereby maximizing the color performance of the animation within a limited color palette capacity; image rendering is performed through corresponding mapping relationships, which consumes little memory and ensures display quality.
[0121] In one embodiment, a computer storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps of any of the above-described animation image processing methods.
[0122] For example, when a computer program is executed by a processor, it performs the following steps: Several sets of initial animation data are acquired. Based on preset extraction conditions, image extraction is performed on each set of initial animation data to obtain multiple first images. The background color of each first image is uniformly processed to obtain each second image and its corresponding background color. The color quantization of each second image is performed to obtain each third image, and a corresponding color palette is configured for each third image. Based on each background color, the color palette of each third image is color-indexed to obtain each background color index. A mapping relationship is established between each third image, each color palette, and each background color index to obtain mapped data. The mapped data is cached for image rendering based on the mapped data, thereby improving the display effect of the animation with lower storage and computing power consumption.
[0123] 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 computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the division operation methods described above.
[0124] Any references to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory.
[0125] Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
[0126] Volatile memory may include random access memory (RAM) or external cache memory.
[0127] By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), direct memory bus RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0128] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0129] The above-described embodiments are merely examples of several implementation methods of this application. They are described in a relatively specific and detailed manner, but should not be construed as limiting the scope of the patent application.
[0130] It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of this application, and these all fall within the scope of protection of this application.
[0131] Therefore, the scope of protection of this patent application shall be determined by the appended claims.
Claims
1. An animation image processing method, characterized in that, The method, applied to resource-constrained embedded display devices, includes: Several sets of initial animation data are acquired, and image extraction is performed on each set of initial animation data based on preset extraction conditions to obtain multiple first images; The background color of each of the first images is uniformly processed to obtain each of the second images and the background color of each corresponding second image; Each of the second images is subjected to color quantization processing to obtain each of the third images, and a corresponding color palette is configured for each of the third images; Based on each of the background colors, the color palettes of each of the third images are indexed to obtain each background color index; A mapping relationship is established for each of the third images, each of the color palettes, and each of the background color indices to obtain mapped data, and the mapped data is cached for image rendering based on the mapped data.
2. The animation image processing method according to claim 1, characterized in that, The step of extracting images from each of the initial animation data based on preset extraction conditions to obtain multiple first images includes: Based on a preset frame rate, the initial animation data is sampled to obtain sampled animation data, and the sampled animation data is converted to RGB format to obtain converted animation data. Based on the sharpening scaling algorithm, the converted animation data is scaled to a size that adapts to the screen resolution of the embedded display device to obtain each of the first images; the preset frame rate is between 4 and 30 fps, and the sharpening scaling algorithm uses a Lanczos resampling filter with a filter window parameter a of 3.
3. The animation image processing method according to claim 1, characterized in that, The step of performing background color unification processing on each of the first images to obtain each of the second images includes: Obtain at least one corner pixel of the corresponding first image, and obtain the background color of the corresponding first image based on each corner pixel; Perform Euclidean distance processing on each pixel of the first image and the corresponding background color of the first image to obtain the first distance value of each pixel; The pixels in the corresponding first image whose first distance is less than a preset tolerance value are replaced with the background color to obtain each second image; the preset tolerance value is a Euclidean distance unit between 50 and 200.
4. The animation image processing method according to claim 1, characterized in that, The step of indexing the color palette of each of the third images based on each of the background colors to obtain each background color index includes: Traverse the RGB values of each color in the color palette of each third image, calculate the Euclidean distance between each color's RGB value and the corresponding background color, and determine the color index with the smallest distance as the background color index of the corresponding third image; After the step of caching the mapped data, the following steps are included: Based on the mapped data, retrieve the color palette corresponding to the third image and the background color index corresponding to the third image; Image rendering is performed based on the color palette corresponding to the third image and the background color index corresponding to the third image.
5. The animation image processing method according to claim 1, characterized in that, The step of caching the mapped data includes: Obtain the frame sequence number feature information of each of the third images; Each of the third images is converted to binary to obtain binary image data, and the binary image data is cached in the frames.bin preset binary file; Configure a palette index for the palette of the corresponding third image, and cache the palette index, the background color index, and the frame sequence number feature information in the index.json preset animation index file; each frame in the preset binary file occupies 40,000 to 41,000 bytes, the palette field does not exceed 768 bytes, and the pixel index field is 40,000 bytes.
6. The animation image processing method according to any one of claims 1 to 5, characterized in that, Following the step of rendering the image based on the mapped data, the following steps are included: The rendered image is acquired and displayed centered on a display screen. The size of the display screen is larger than the size of the rendered image. The display screen has a status bar and a subtitle bar, which are located adjacent to the corresponding sides of the rendered image. The size of the display screen is not less than 240×240 pixels, the size of the rendered image is 200×200 pixels, and an A8-format rounded corner mask is set at the bottom of the display screen. The radius of the rounded corner mask does not exceed 50 pixels, and the A8-format rounded corner mask occupies no more than 5 KB of memory.
7. The animation image processing method according to claim 1, characterized in that, All animations in the aforementioned initial animation data share the same global first frame; the third image and color palette corresponding to the global first frame in the mapped data are cached only once; the starting frame index of each animation group is recorded in the form of an offset in a preset animation index file, and the offset points to the starting position of the unique frame sequence of each animation group; when the number of the aforementioned initial animation data groups is N, the mapped data saves (N-1)×(W×H+256×3) bytes of storage space compared to the independent caching scheme; where N is 10 and W=H=200, the storage space saved is approximately 358KB.
8. The animation image processing method according to claim 1, characterized in that, The step of rendering the image based on the mapped data further includes: maintaining a single buffer pool in the memory of the embedded display device, the single buffer pool consisting of several pre-allocated frame buffers, each frame buffer having four states: idle, decoding, ready, and in use, and configuring an 8-bit reference count; when rendering is requested, retrieving the ready buffer corresponding to the third image frame number from the single buffer pool and incrementing its reference count; if it does not exist, retrieving the idle buffer for decoding; after rendering is completed, decrementing the reference count of the ready buffer; when the reference count reaches zero and exceeds a preset retention time, the ready buffer is reclaimed to the idle state.
9. The animation image processing method according to claim 1, characterized in that, The method further includes: setting a preset emotion bucket mapping table, wherein the preset emotion bucket mapping table maps several semantic emotion categories of external input to three emotion buckets; the number of semantic emotion categories of external input is not less than 21; each of the three emotion buckets is associated with an animation composed of two of the third images; when receiving external emotion input, the emotion bucket is determined according to the preset emotion bucket mapping table, and selection is made based on the two animations associated with the emotion bucket.
10. An embedded display device, characterized in that, It includes a processing module and a display module, the processing module being connected to the display module, and the processing module being used to perform the steps of the animation image processing method as described in any one of claims 1 to 9.