US-12620140-B2 - Buffering a graphical overlay to be applied to an image
Abstract
A device and a method for buffering a graphical overlay to be applied to an image is disclosed. A graphical overlay description specifying content, size, and position in the image of a graphical element of the graphical overlay is obtained, and the graphical overlay is divided into a plurality of sequential line fragments. For each line fragment it is determined, using the graphical overlay description, whether the line fragment overlaps a part of the graphical element. On condition that the line fragment overlaps a part of the graphical element, information representing the part of the graphical element is buffered in a buffer memory for the line fragment. On condition that the line fragment does not overlap any part of the graphical element, a run-length coding representing identical pixels is buffered in the buffer memory for the line fragment.
Inventors
- Johan FÖRBERG
- Johan Nyström
- Ludvig HASSBRING
Assignees
- AXIS AB
Dates
- Publication Date
- 20260505
- Application Date
- 20240308
- Priority Date
- 20230418
Claims (15)
- 1 . A method for buffering a graphical overlay to be applied to an image, wherein the graphical overlay comprises a plurality of horizontal lines of pixels, the method comprising: obtaining a graphical overlay description specifying content, size, and position in the image of a graphical element of the graphical overlay; dividing each horizontal line of pixels of the plurality of horizontal lines of pixels of the graphical overlay into a plurality of sequential line fragments, wherein all of the sequential line fragments have a same size; and for each line fragment of the plurality of sequential line fragments: determining, using the graphical overlay description, whether the line fragment overlaps a part of the graphical element, on condition that the line fragment overlaps a part of the graphical element, buffering in a buffer memory, for the line fragment, information representing the part of the graphical element, and on condition that the line fragment does not overlap any part of the graphical element, buffering in the buffer memory, for the line fragment, a run-length coding representing identical pixels.
- 2 . The method according to claim 1 , wherein the information representing the part of the graphical element is pixel data representing the part of the graphical element.
- 3 . The method according to claim 2 , wherein the pixel data representing the part of the graphical element are obtained from a memory storing pixel data representing the graphical element.
- 4 . The method according to claim 2 , further comprising: for each line fragment of the plurality of sequential line fragments, on condition that the line fragment overlaps a part of the graphical element, buffering in the buffer memory, for the line fragment, a respective run-length coding representing identical pixels before and after the part of the graphical element in the line fragment.
- 5 . The method according to claim 1 , wherein the information representing the part of the graphical element is a run-length coding representing identical pixels for the part of the graphical element.
- 6 . The method according to claim 1 , wherein the obtained graphical overlay description further specifies content, size, and position in the image of a further graphical element of the graphical overlay, the method further comprising: for each line fragment of the plurality of sequential line fragments: on condition that the line fragment overlaps a part of the further graphical element, buffering in the buffer memory, for the line fragment, information representing the part of the further graphical element, and on condition that the line fragment overlaps both a part of graphical element and a part of the further graphical element, buffering in the buffer memory, for the line fragment, information representing both the part of the graphical element and the part of the further graphical element.
- 7 . The method according to claim 6 , wherein the information representing both the part of the graphical element and the part of the further graphical element is pixel data representing a combination of the part of the graphical element and the part of the further graphical element.
- 8 . A non-transitory computer-readable storage medium having stored thereon instructions for implementing the method according to claim 1 when executed in a device having a processor and a buffer memory.
- 9 . A device for buffering a graphical overlay to be applied to an image, the graphical overlay comprising a plurality of horizontal lines of pixels, the device comprising: a buffer memory; and circuitry configured to execute: an obtaining function configured to obtain a graphical overlay description specifying content, size, and position in the image of a graphical element of the graphical overlay; a dividing function configured to divide each horizontal line of pixels of the plurality of horizontal lines of pixels of the graphical overlay into a plurality of sequential line fragments, wherein all of the sequential line fragments have a same size; a determining function configured to, for each line fragment of the plurality of sequential line fragments, determine, using the graphical overlay description, whether the line fragment overlaps a part of the graphical element; and a buffering function configured to, for each line fragment of the plurality of sequential line fragments: on condition that the line fragment overlaps a part of the graphical element, buffer in the buffer memory, for the line fragment, information representing the part of the graphical element, and on condition that the line fragment does not overlap any part of the graphical element, buffer in the buffer memory, for the line fragment, a run-length coding representing identical pixels.
- 10 . The device according to claim 9 , wherein the information representing the part of the graphical element is pixel data representing the part of the graphical element.
- 11 . The device according to claim 10 , wherein the pixel data representing the part of the graphical element are obtained from a memory storing pixel data representing the graphical element.
- 12 . The device according to claim 10 , wherein the buffering function is further configured to, for each line fragment of the plurality of sequential line fragments: on condition that the line fragment overlaps a part of the graphical element, buffering in the buffer memory, for the line fragment, a respective run-length coding representing identical pixels before and after the part of the graphical element in the line fragment.
- 13 . The device according to claim 9 , wherein the information representing the part of the graphical element is a run-length coding representing identical pixels for the part of the graphical element.
- 14 . The device according to claim 9 , wherein the obtained graphical overlay description further specifies content, size, and position in the image of a further graphical element of the graphical overlay, and wherein the buffering function is further configured to, for each line fragment of the plurality of sequential line fragments: on condition that the line fragment overlaps a part of the further graphical element, buffer in a buffer memory, for the line fragment, information representing the part of the further graphical element, and on condition that the line fragment overlaps both a part of graphical element and a part of the further graphical element, buffer in a buffer memory, for the line fragment, information representing both the part of the graphical element and the part of the further graphical element.
- 15 . The device according to claim 14 , wherein the information representing both the part of the graphical element and the part of the further graphical element is pixel data representing a combination of the part of the graphical element and the part of the further graphical element.
Description
CROSS-REFERENCE TO RELATED APPLICATION This application claims priority to European Patent Application No. 23168392.1 filed on Apr. 18, 2023, the entire disclosure of which is incorporated by reference herein. TECHNICAL FIELD The present invention relates to graphical overlays to be applied to an image, and specifically to buffering graphical overlays to be applied to an image. BACKGROUND In video applications, such as videos from a monitoring or surveillance camera, a graphical overlay is sometimes added to image frames of the video before encoding. Such an overlay may comprise elements, e.g. in the form of text, numbers, and symbols. The elements may for example be static tags (such as an indication of what the camera is showing, e.g. Entrance, Building X etc), time stamps, information text, a company name and/or logotype. When the overlay is to be added to an image frame of a video, the overlay is typically stored in a buffer memory, e.g. as a bitmap. Data describing the overlay is then read out from the buffer memory and combined with data relating to the image frame to which the overlay should be added. This will require a rather large buffer memory. For example, if the overlay is stored as a bitmap and should be able to include elements in all of the image frame, the buffer memory will have to be large enough to store a bitmap of a size corresponding to the size of the image. In order to reduce the size of the buffer memory for buffering the overlay, the possibility to include the overlay may be restricted to certain one or a few portions of the image frame. SUMMARY OF THE INVENTION To overcome or at least mitigate the above identified drawbacks in prior art, the present disclosure provides an improved method of buffering a graphical overlay to be applied to an image, a corresponding device, and a non-transitory computer-readable storage medium as defined in the accompanying independent claims. The invention makes use of the realization that graphical overlays typically comprise a large portion of transparent pixels since the graphical overlay in most cases is intended to add information whilst not obscuring a large portion of the image frame. However, even the transparent pixels take up space in a buffer memory that the graphical overlay is stored in before being added to an image. It is thus desirable to provide a method for buffering the graphical overlay that reduces the required size of the buffer memory in which the overlay is buffered. According to a first aspect, a method for buffering a graphical overlay to be applied to an image is provided. A graphical overlay description specifying content, size, and position in the image of a graphical element of the graphical overlay is obtained, and the graphical overlay is divided into a plurality of sequential line fragments. For each line fragment it is determined, using the graphical overlay description, whether the line fragment overlaps a part of the graphical element. On condition that the line fragment overlaps a part of the graphical element, information representing the part of the graphical element is buffered in a buffer memory for the line fragment. On condition that the line fragment does not overlap a part of the graphical element, a run-length coding representing identical pixels is buffered in the buffer memory for the line fragment. By dividing the graphical overlay into a plurality of sequential line fragments and buffering run-length coding for line fragments that do not overlap a part of the graphical element, the buffer space needed to buffer the pixels is reduced and hence the size of the buffer for buffering the graphical overlay may be reduced as compared to if information regarding each individual pixels, such as a bitmap representation the complete overlay including also portions that do not overlap a part of the graphical element, were to be buffered. Furthermore, the run-length coding representing identical pixels for the line fragments not overlapping a portion of the graphical element can be efficiently read out from the buffer memory. For example, run-length coding for a line fragment that does not overlap a part of the graphical element will require a lower bandwidth to be read out from the buffer memory as compared to reading out pixel data for each pixel for such a line fragment. By identical pixels is meant e.g. that the pixels all have the same color and level of transparency, or are all completely transparent pixels. The information representing the part of the graphical element may be pixel data representing the part of the graphical element. The pixel data representing the part of the graphical element may be obtained from a memory storing pixel data representing the graphical element. The method may then further comprise buffering in the buffer memory, for the line fragment, a respective run-length coding representing identical pixels for pixels before and after the part of the graphical element in the line fragm