Image Rendering Method and Apparatus, Electronic Device, and Storage Medium

By creating an element to draw an index array and filling it in a specific order, the problem of excessive consumption of central processor resources during fisheye image correction is solved, and the one-time rendering and rendering performance of the entire image is improved.

CN117011178BActive Publication Date: 2025-06-10BEIJING YINWO AUTOMOBILE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310995311.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-08
Publication Date
2025-06-10
Estimated Expiration
2043-08-08

AI Technical Summary

Technical Problem

During the process of fisheye image correction, the prior art requires reordering the points of each strip, and each strip drawing requires calling the drawing function in OpenGLES, resulting in excessive consumption of central processor resources.

Method used

By creating an element to draw an index array, including the point numbers corresponding to multiple strips in sequence, and filling them in as up and down, avoiding the reordering of each strip point and realizing one-time rendering of the entire image.

Benefits of technology

Reduces consumption of central processor resources, avoids the possible absence of triangle problems when continuous drawing between adjacent strips, and improves rendering performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117011178B_ABST
    Figure CN117011178B_ABST
Patent Text Reader

Abstract

The present disclosure provides an image rendering method, which relates to the technical field of image processing. The method includes: determining a plurality of points on the image to be rendered and the respective numbers of the plurality of points, the plurality of points being arranged in an array, and the plurality of points dividing the image to be rendered into a plurality of strips; creating a primitive drawing index array based on the respective numbers of the plurality of points, the primitive drawing index array sequentially including the numbers of the points corresponding to the plurality of strips respectively, and the heads and tails of adjacent strips being opposite, the numbers of the points corresponding to each strip being filled in sequence from the head to the tail in a way of crossing up and down, after the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in sequence from the head to the tail in the way of crossing up and down; and sequentially drawing the plurality of points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered. In this way, the consumption of central processing unit resources can be reduced and the rendering performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] A fisheye lens is a camera lens with a short focal length and a large field of view. Compared with conventional lenses, fisheye lenses are widely used in various fields due to their own advantages. However, the images captured by fisheye lenses have very serious distortion, making people's visual perception unnatural. Therefore, it is necessary to correct the distorted images captured by fisheye lenses into images acceptable to human vision, that is, fisheye image correction.

[0003] In the related art, the entire fisheye image is divided into multiple strips according to the parameter information of distortion correction, and each strip is drawn one by one using OpenGLES. Finally, the fisheye image is rendered into an image acceptable to human vision. However, during the rendering process, the data of the fisheye image needs to be reordered and processed according to the drawing rules, and each time a strip is drawn, the drawing function in OpenGLES needs to be called once. Therefore, the resource consumption of the central processing unit (CPU) is too large. Summary of the Invention

[0004] In view of this, the present disclosure provides an image rendering method, an apparatus, an electronic device, and a storage medium to reduce the resource overhead of the central processing unit.

[0005] In a first aspect, an image rendering method is provided, including: determining a plurality of points on the image to be rendered and the respective numbers of the plurality of points, the plurality of points being arranged in an array, and the plurality of points dividing the image to be rendered into a plurality of strips; creating a primitive drawing index array based on the respective numbers of the plurality of points, the primitive drawing index array sequentially including the numbers of the points corresponding to the respective strips, and the heads and tails of adjacent strips being opposite, and the numbers of the points corresponding to each strip being filled in order from the head to the tail in a way of crossing up and down. After the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in order from the head to the tail in a way of crossing up and down; and sequentially drawing the plurality of points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered.

[0006] In some embodiments, creating a primitive drawing index array based on the respective numbers of the plurality of points includes: obtaining an empty initial index array; and sequentially filling the numbers of the points corresponding to the respective strips into the initial index array according to the adjacency relationship between the plurality of strips to obtain the primitive drawing index array.

[0007] In some embodiments, sequentially filling the numbers of the points corresponding to the respective strips into the initial index array includes: for each strip, starting from the head of the strip, filling the numbers of the points corresponding to the strip into the initial index array in order from the head to the tail in a way of crossing up and down.

[0008] In some embodiments, based on the primitive drawing index array, multiple points are drawn in sequence to obtain the rendered image corresponding to the image to be rendered, including: according to the order of the numbers of the points included in the primitive drawing index array, straight lines connecting the multiple points are drawn in sequence to form multiple triangular primitives, so as to obtain the rendered image corresponding to the image to be rendered.

[0009] In some embodiments, according to the order of the numbers of the points included in the primitive drawing index array, straight lines connecting the multiple points are drawn in sequence to form multiple triangular primitives, including: for each point, determining whether the position n of the number of the point in the primitive drawing index array is odd or even; if n is odd, straight lines are sequentially connected to the three points corresponding to the numbers at the (n - 2)th, (n - 1)th, and nth positions in the primitive drawing index array to form a triangular primitive; if n is even, straight lines are sequentially connected to the three points corresponding to the numbers at the (n - 1)th, (n - 2)th, and nth positions in the primitive drawing index array to form a triangular primitive.

[0010] In some embodiments, the image rendering method further includes: determining at least one index buffer for caching the primitive drawing index array; and determining at least one vertex buffer for caching multiple points.

[0011] In some embodiments, based on the primitive drawing index array, multiple points are drawn in sequence to obtain the rendered image corresponding to the image to be rendered, including: using an image drawing model, based on the primitive drawing index array in the index buffer, performing one-time rendering on the multiple points in the vertex buffer to obtain the rendered image corresponding to the image to be rendered.

[0012] In a second aspect, there is provided an image rendering apparatus, including: a determination module configured to determine multiple points on the image to be rendered and the respective numbers of the multiple points, the multiple points being arranged in an array, and the multiple points dividing the image to be rendered into multiple strips; a sorting module configured to create a primitive drawing index array based on the respective numbers of the multiple points, the primitive drawing index array sequentially including the numbers of the points corresponding to the respective strips, and the heads and tails of adjacent strips being opposite, the numbers of the points corresponding to each strip are filled in sequence from the head to the tail in a way of crossing up and down, and after the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in sequence from the head to the tail in a way of crossing up and down; a rendering module configured to draw the multiple points in sequence based on the primitive drawing index array to obtain the rendered image corresponding to the image to be rendered.

[0013] In a third aspect, there is provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the method of the first aspect via executing the executable instructions.

[0014] Fourthly, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect is implemented.

[0015] In the image rendering method provided by the embodiments of the present disclosure, the order of each point is determined by the primitive drawing index array. Therefore, during the drawing process, it is not necessary to reorder the points of each strip, reducing the consumption of central processing unit resources. At the same time, when drawing in the order of the primitive drawing index array, the problem that a non-existent triangle will be drawn during continuous drawing between adjacent strips in the related art can be avoided. Therefore, it is possible to achieve one-time rendering of the entire image, further reducing the consumption of central processing unit resources and improving the rendering performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figures 1a to 1d The figure shows a schematic flow chart of an image rendering method in the related art.

[0017] Figure 2 The figure shows a schematic flow chart of an image rendering method provided by the embodiments of the present disclosure.

[0018] Figure 3 The figure shows a schematic diagram of a numbering method for multiple points provided by the embodiments of the present disclosure.

[0019] Figure 4 The figure shows a schematic flow chart of a method for creating a primitive drawing index array provided by the embodiments of the present disclosure.

[0020] Figures 5a to 5c The figure shows a schematic diagram of three types of triangle primitive provided by the embodiments of the present disclosure.

[0021] Figure 6 The figure shows a schematic flow chart of a method for sequentially drawing straight lines connecting multiple points to form multiple triangle primitives provided by the embodiments of the present disclosure.

[0022] Figure 7 The figure shows a schematic diagram of a connection method for multiple points provided by the embodiments of the present disclosure.

[0023] Figure 8 The figure shows a schematic structural diagram of an image rendering device provided by the embodiments of the present disclosure.

[0024] Figure 9 The figure shows a schematic structural diagram of an electronic device provided by the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0026] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus repeated descriptions thereof will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0027] As described above, when performing fisheye image correction in the related art, the fisheye image is divided into multiple strips according to the parameter information of distortion correction. During the division process, the multiple strips are determined by multiple points. As Figure 1a shown, 20 points are arranged in sequence, and the original image is divided into 4 strips. The connection line of points 1 to 4 is used as the upper side of the first strip, and the connection line of points 5 to 8 is used as the lower side of the first strip; at the same time, the connection line of points 5 to 8 is also used as the upper side of the second strip, and so on, dividing the original image into multiple strips.

[0028] As Figure 1b shown, after determining the multiple strips, the glDrawArrays function of OpenGLES is used to draw the multiple points in the first strip into multiple triangles in sequence according to the triangle strip drawing rule, and the multiple triangles are jointly spliced into the first strip. Then, as Figure 1c shown, the glDrawArrays function is called again to draw the multiple points in the second strip into multiple triangles, and the multiple triangles are jointly spliced into the second strip.

[0029] During the drawing process, it is necessary to reorder the points of each strip according to the drawing rule. At the same time, the drawing function needs to be called once for each strip, resulting in excessive consumption of the central processing unit resources.

[0030] As Figure 1d shown, if two strips are drawn at one time, then according to the characteristics of the drawing function, points 4 and 8 in the first strip will be sequentially connected to point 9 in the second strip, drawing a non-existent triangle, thereby affecting the rendering of the entire image.

[0031] In view of this, the present disclosure provides an image rendering method, including: determining a plurality of points on an image to be rendered and the respective numbers of the plurality of points, where the plurality of points are arranged in an array, and the plurality of points divide the image to be rendered into a plurality of strips; creating a primitive drawing index array based on the respective numbers of the plurality of points, where the primitive drawing index array sequentially includes the numbers of the points corresponding to the respective strips, and the heads and tails of adjacent strips are opposite, and the numbers of the points corresponding to each strip are filled in sequentially from the head to the tail in a way of crossing up and down. After filling in the number of the last point at the tail of each strip, the numbers of the points corresponding to the next strip continue to be filled in sequentially from the head to the tail in a way of crossing up and down; based on the primitive drawing index array, sequentially draw the plurality of points to obtain a rendered image corresponding to the image to be rendered. In this way, it is possible to achieve one-time rendering of the entire image, reduce the consumption of central processing unit resources, and improve the rendering performance.

[0032] It can be understood that the method of the present disclosure is not only applicable to fisheye image correction, but also equally applicable to a variety of image rendering application scenarios. Among them, according to different application scenarios, the distribution of points in the image can be determined based on a variety of algorithms.

[0033] The following will describe this exemplary embodiment in detail with reference to the drawings and embodiments.

[0034] Figure 2 The flowchart showing an image rendering method in an embodiment of the present disclosure is as Figure 2 shown. The image rendering method provided in the embodiment of the present disclosure includes the following steps.

[0035] S210, determining a plurality of points on the image to be rendered and the respective numbers of the plurality of points.

[0036] Specifically, the plurality of points are arranged in an array; after determining the plurality of points, number the plurality of points according to a predetermined rule. Exemplarily, continue to refer to Figure 1a , 20 points are arranged in an array, and the points in one row are numbered sequentially from small to large. After all the points in one row are numbered, then number the points in the next row sequentially from small to large until all the points are numbered.

[0037] Each point can also be associated with some additional attributes of the image to be rendered, such as information about the color, texture coordinates, geometric normal, etc. of the point.

[0038] It can be understood that the distribution of points in the figure is only illustrative, and the distribution of points such as the width of each strip and the interval between points should be determined according to the actual situation of the image to be rendered (for example, the distortion situation of the fisheye image). The present disclosure does not make specific limitations on this.

[0039] S220, creating a primitive drawing index array based on the respective numbers of the plurality of points.

[0040] After determining the numbers of each of the multiple points, the numbers are rearranged according to a specific method to obtain a primitive drawing index array. In the primitive drawing index array, the numbers of multiple points in each strip are arranged concentratedly, and according to the adjacency relationship between the strips, they are successively adjacent in the primitive drawing index array. Moreover, the numbers of multiple points in each strip are filled into the primitive drawing index array in order from the head to the tail of the strip. After filling in the number of the last point at the tail of each strip, the numbers of the corresponding points of the next strip continue to be filled in order from the head to the tail. And, the head and tail of adjacent strips are opposite.

[0041] Exemplarily, continue to refer to Figure 1a , the image to be rendered includes 4 strips, and the head and tail of adjacent strips are opposite. Exemplarily, the first strip has the left end of the strip as the head and the right end as the tail; the second strip has the right end of the strip as the head and the left end as the tail; the third strip has the left end of the strip as the head and the right end as the tail; the fourth strip has the right end of the strip as the head and the left end as the tail. Starting from the first strip, the numbers of multiple points in this strip are filled into the primitive drawing index array in order; since the first strip has the left end as the head, this strip should start filling from point 1 from left to right, and the upper and lower points in the same column are crossed; specifically, the order of points 1 to 8 in the first strip in the primitive drawing index array is {1, 5, 2, 6, 3, 7, 4, 8}.

[0042] Then, according to the adjacency relationship between the strips, the numbers of multiple points in the second strip should be filled in continuously. The second strip has the right end of the strip as the head, and the starting point corresponds to the end position of the first strip. Therefore, it should start filling from point 12 in the lower right of the second strip from right to left, and the upper and lower points in the same column are crossed; specifically, the order of points 5 to 12 in the second strip in the primitive drawing index array is

[0043] {12, 8, 11, 7, 10, 6, 9, 5}. And so on, fill in the numbers of multiple points in the third strip and the fourth strip in turn, and finally Figure 1a the primitive drawing index array of the image to be rendered shown is

[0044] {1, 5, 2, 6, 3, 7, 4, 8, 12, 8, 11, 7, 10, 6, 9, 5, 9, 13, 10, 14, 11, 15, 12, 16, 20, 16, 19, 15, 18, 14, 17, 13}.

[0045] It can be understood that the number of a point corresponds uniquely to each point, and is only intended to distinguish different points. The numbering method of multiple points does not affect the construction method of the primitive drawing index array in the embodiments of the present disclosure, and the order of the actual points implied by the primitive drawing index array does not change with the change of the point numbering method.

[0046] Figure 3 The following shows a numbering method for multiple points provided by an embodiment of the present disclosure, which is different from Figure 1a . According to this numbering method, the primitive drawing index array in the embodiment of the present disclosure is {1, 2, 3, 4, 5, 6, 7, 8, 12, 8, 11, 6, 10, 4, 9, 2, 9, 13, 10, 14, 11, 15, 12, 16, 20, 16, 19, 15, 18, 14, 17, 13}. It can be observed that Figure 3 and Figure 1a are only different in the numbering method of multiple points. However Figure 3 and Figure 1a in the primitive drawing index arrays, although the specific numbers of the numbers in the same positions are different, they all point to the same point.

[0047] S230. Based on the primitive drawing index array, draw multiple points in sequence to obtain the rendered image corresponding to the image to be rendered.

[0048] After determining the primitive drawing index array, draw multiple points in sequence based on the order of the numbers in the primitive drawing index array, and finally obtain the rendered image corresponding to the image to be rendered.

[0049] Exemplarily, the glDrawElements function in OpenGLES can be used to draw multiple points in sequence with the primitive drawing index array as the index to obtain the rendered image.

[0050] In the embodiment of the present disclosure, the order of each point is determined by the primitive drawing index array. Therefore, during the drawing process, it is not necessary to reorder the points of each strip, reducing the consumption of central processing unit resources. At the same time, when drawing in the order of the primitive drawing index array, the problem that a non-existent triangle will be drawn during continuous drawing between adjacent strips in the related art can be avoided. Therefore, it is possible to achieve one-time rendering of the entire image, further reducing the consumption of central processing unit resources and improving the rendering performance.

[0051] Next, an implementation method for creating the primitive drawing index array will be introduced. As Figure 4 shown, creating the primitive drawing index array based on the numbers of multiple points provided by the embodiment of the present disclosure includes the following steps.

[0052] S221. Obtain an empty initial index array.

[0053] This initial index array is used to hold the numbers of multiple points, and its length changes with subsequent filling operations.

[0054] S222. According to the adjacency relationship between multiple strips, fill the numbers of the corresponding points of each of the multiple strips into the initial index array in sequence to obtain the primitive drawing index array.

[0055] After obtaining the initial index array, according to the adjacency relationship between multiple strips, fill the point numbers included in each of the multiple strips into the initial index array in the order from the head to the tail, where the head and tail of adjacent strips are opposite. Specifically, first fill the point numbers included in the first strip into the initial index array, then fill the point numbers included in the second strip into the initial index array, and so on, until the point numbers included in the last strip are filled into the initial index array, thereby obtaining the primitive drawing index array.

[0056] When the previous strip is filled to the last point at the tail, it should continue to be filled into the initial index array starting from the head of the next strip. However, in the above embodiments, one end of the strip is taken as the head. It can be observed that there are two points, upper and lower, in a column at one end of the strip. Therefore, it is necessary to determine one of these two points as the initial point for filling. In the embodiments of the present disclosure, the point at the corresponding position of the next strip to the last point of the previous strip is used as the initial point for filling. Here, the correspondence between the two points means that the point at the tail of the previous strip far from the next strip corresponds to the point at the head of the next strip adjacent to the previous strip; the point at the tail of the previous strip adjacent to the next strip corresponds to the point at the head of the next strip far from the previous strip.

[0057] It can be understood that adjacent strips share a common edge, that is, the points included in adjacent strips are partially the same.

[0058] In the embodiments of the present disclosure, the multiple points included in each strip are sorted in advance, and the order of the points is fixed through the initial index array. Therefore, it is possible to avoid re-sorting the points of each strip according to the drawing rules during subsequent primitive drawing. At the same time, since the left ends of each strip are connected to each other and the right ends are connected to each other. Therefore, it is possible to avoid the problem that a non-existent triangle will be drawn when multiple strips are continuously drawn, thereby realizing the one-time rendering of the entire image.

[0059] In some embodiments, filling the numbers of the corresponding points of each of the multiple strips into the initial index array in sequence specifically includes: for each strip, starting from the head of the strip, fill the numbers of the corresponding points of the strip into the initial index array in the order from the head to the tail in a way of alternating up and down.

[0060] After determining the head end of the strip and the initial point included in the head end, fill the numbers of the multiple points in the strip into the initial index array in a way of alternating up and down.

[0061] Specifically, a strip is determined by multiple points above and multiple points below. Therefore, when filling the upper and lower points in the same column, the problem of the upper and lower order will be faced. In the embodiments of the present disclosure, the filling of the point numbers included in a strip starts from the initial point, and then fills the numbers of the points in the same column as the initial point. Then, it fills the number of the second point in the same row as the initial point, and then fills the numbers of the points in the same column as the second point, and so on. Exemplarily, continuing to refer to Figure 1a , the filling order of the point numbers included in the first strip is {1, 5, 2, 6, 3, 7, 4, 8}.

[0062] The order of the multiple points determined in this way can meet the drawing rules of the primitive, so in the subsequent primitive drawing, there is no need to reorder the points of each strip, reducing the consumption of central processing unit resources and improving the rendering performance.

[0063] The following introduces an implementation method of primitive drawing. The rendering image corresponding to the image to be rendered is obtained by sequentially drawing multiple points based on the primitive drawing index array provided by the embodiments of the present disclosure, which specifically includes: sequentially drawing straight lines connecting multiple points according to the order of the point numbers included in the primitive drawing index array to form multiple triangle primitives, and obtaining the rendering image corresponding to the image to be rendered.

[0064] Specifically, in the image rendering process, simple graphics are used to form complex graphics. Among them, the simple graphics include points, lines, triangles, etc. Primitives (or graphic elements) are these simple graphics. A primitive is the smallest graphic unit that can be edited in the rendering process and is the most basic material for operating and organizing the picture. Among various rendering methods, programs, and software, the triangle primitive is a commonly applicable one. At the same time, the triangle primitive type is divided into individual triangles ( Figure 5a ), triangle strips ( Figure 5b ), and triangle fans ( Figure 5c ) three types. It is easy to observe that, combined with the strip division method of the embodiments of the present disclosure, the triangle strip is the most suitable type for the present disclosure. Therefore, the sorting method of multiple points in the present disclosure is set to conform to the drawing rules of the triangle strip.

[0065] Multiple points are connected according to the triangle strip drawing rules to form multiple triangle primitives. Then, corresponding rendering operations are performed according to the information such as the colors and textures corresponding to the multiple points to obtain the final rendering image.

[0066] The following specifically introduces an implementation method of the above triangle strip drawing rules. As Figure 6 shown, sequentially drawing straight lines connecting multiple points according to the order of the point numbers included in the primitive drawing index array to form multiple triangle primitives includes the following steps.

[0067] S610: For each point, determine whether the position n of the point number in the primitive drawing index array is odd or even.

[0068] As described above, the numbers of multiple points vary with different numbering methods. However, the numbers at the same position in the primitive drawing index array, even if the specific numbers are different, point to the same point. Therefore, when determining the connection order of the current point, it should be determined based on the position of the current point number in the primitive drawing index array, rather than based on the number itself.

[0069] S620: If n is odd, sequentially connect the three points corresponding to the numbers at the (n - 2)-th, (n - 1)-th, and n-th positions in the primitive drawing index array by straight lines to form a triangular primitive.

[0070] S630: If n is even, sequentially connect the three points corresponding to the numbers at the (n - 1)-th, (n - 2)-th, and n-th positions in the primitive drawing index array by straight lines to form a triangular primitive.

[0071] Figure 7 Shown is a schematic diagram of a connection method for multiple points provided by an embodiment of the present disclosure. As Figure 7 shown, according to the method of the above embodiment, Figure 7 the primitive drawing index array corresponding to the multiple points shown is {1, 5, 2, 6, 3, 7, 4, 8, 12, 8, 11, 7, 10, 6, 9, 5, 9, 13, 10, 14, 11, 15, 12, 16, 20, 16, 19, 15, 18, 14, 17, 13}. Exemplarily, point 2 is located at the 3rd position in the primitive drawing index array. Therefore, the three points corresponding to the numbers at the 1st, 2nd, and 3rd positions should be connected, that is, connect point 1, point 5, and point 2 to form a triangular primitive; point 6 is located at the 4th position in the primitive drawing index array. Therefore, the three points corresponding to the numbers at the 1st, 2nd, and 3rd positions should be connected, that is, connect point 2, point 5, and point 6 to form a triangular primitive. At the junction of the first strip and the second strip, that is, the fragment {7, 4, 8 / / 12, 8, 11} of the array, where the three numbers before / / are the three numbers at the end of the first strip, and the three numbers after / / are the three numbers at the beginning of the second strip. Point 12 is located at the 9th position in the whole array. Therefore, the three points corresponding to the numbers at the 7th, 8th, and 9th positions should be connected, that is, connect point 4, point 8, and point 12; it can be observed that the drawn figure is equivalent to a straight line and will not affect the rendering of the entire image. A schematic diagram of multiple points connected according to the above rules is as Figure 7 shown, the triangular primitives obtained by the method of the embodiment of the present disclosure are Figure 1b and Figure 1c slightly different from the triangular primitives obtained by the methods in the related art shown, but both can be spliced into a complete image.

[0072] In some embodiments, the image rendering method of the present disclosure further includes: determining at least one index buffer for caching a primitive drawing index array; and determining at least one vertex buffer for caching a plurality of points.

[0073] It can be observed that adjacent strips share some points. Therefore, during the drawing process, the data of the shared points will be repeatedly loaded from memory into the Graphics Processing Unit (GPU), resulting in data redundancy and increasing the bus load.

[0074] In this embodiment, by determining the vertex buffer, all the data of the points required for drawing can be cached from memory to the GPU at one time, avoiding frequent interaction between memory and the graphics card, and significantly reducing the bus load when drawing complex models. At the same time, for similar reasons, in this embodiment, by determining the index buffer, all the indexes required for drawing (i.e., the primitive drawing index array) are cached to the GPU at one time, further reducing the bus load and improving the rendering performance.

[0075] In some embodiments, based on the primitive drawing index array, a plurality of points are sequentially drawn to obtain a rendering image corresponding to the image to be rendered, which specifically includes: using an image drawing model, based on the primitive drawing index array in the index buffer, rendering the plurality of points in the vertex buffer at one time to obtain a rendering image corresponding to the image to be rendered.

[0076] Among them, the image drawing model is a model capable of realizing image rendering. During the rendering process, first, the primitive drawing index array is loaded into the index buffer, and the data of all the points on the image to be rendered is loaded into the vertex buffer; then, based on the order of the points indicated by the primitive drawing index array in the index buffer, the image drawing model renders the plurality of points in the vertex buffer at one time to obtain a rendering image.

[0077] Exemplarily, the image drawing model can be OpenGLES. More specifically, it can be the glDrawElements function in OpenGLES. During the rendering process, first, the glBindBuffer function and the glBufferData function in OpenGLES are called to load the data of all the points on the image to be rendered into the vertex buffer at one time, and the primitive drawing index array is loaded into the index buffer at one time; then, the glDrawElements function is called to draw the entire image, and the entire rendering image can be rendered at one time.

[0078] Combined with the method in the embodiments of the present disclosure, all the data and indexes of the points required for drawing can be cached in the GPU at one time; and the primitive drawing index array determined based on the method of the present disclosure can realize the one-time drawing of all the points, without separately drawing each strip. Therefore, the method of the present disclosure can greatly reduce the consumption of central processing unit resources, reduce the bus load, and improve the rendering performance.

[0079] Based on the same inventive concept, an image rendering apparatus is also provided in the embodiments of the present disclosure, as described in the following embodiments. Since the principle of solving problems in this apparatus embodiment is similar to that of the above method embodiment, the implementation of this apparatus embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be described again.

[0080] Figure 8 The structural schematic diagram of an image rendering apparatus in the embodiments of the present disclosure is shown. As Figure 8 shown, the image rendering apparatus 800 includes: a determination module 810, a sorting module 820, and a rendering module 830.

[0081] Specifically, the determination module 801 is configured to determine a plurality of points on the image to be rendered and the respective numbers of the plurality of points. The plurality of points are arranged in an array, and the plurality of points divide the image to be rendered into a plurality of strips; the sorting module 820 is configured to create a primitive drawing index array based on the respective numbers of the plurality of points. The primitive drawing index array sequentially includes the numbers of the points corresponding to the respective strips, and the heads and tails of adjacent strips are opposite. The numbers of the points corresponding to each strip are filled in order from the head to the tail in a way of crossing up and down. After the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in order from the head to the tail in a way of crossing up and down; the rendering module 830 is configured to sequentially draw a plurality of points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered.

[0082] In some embodiments, the sorting module 820 is further configured to obtain an empty initial index array; and fill the numbers of the points corresponding to the respective strips into the initial index array in sequence according to the adjacency relationship between the plurality of strips to obtain the primitive drawing index array.

[0083] In some embodiments, the sorting module 820 is further configured to, for each strip, starting from the head of the strip, fill the numbers of the points corresponding to the strip into the initial index array in order from the head to the tail in a way of crossing up and down.

[0084] In some embodiments, the rendering module 830 is further configured to, according to the order of the numbers of the points included in the primitive drawing index array, sequentially draw straight lines connecting the plurality of points to form a plurality of triangular primitives, and obtain a rendered image corresponding to the image to be rendered.

[0085] In some embodiments, the rendering module 830 is further configured to, for each point, determine whether the position n of the point number in the primitive drawing index array is odd or even; if n is odd, sequentially connect the three points corresponding to the numbers at the (n-2)th, (n-1)th, and nth positions in the primitive drawing index array with straight lines to form a triangular primitive; if n is even, sequentially connect the three points corresponding to the numbers at the (n-1)th, (n-2)th, and nth positions in the primitive drawing index array with straight lines to form a triangular primitive.

[0086] In some embodiments, the determination module 810 is further configured to determine at least one index buffer for caching the primitive drawing index array; and determine at least one vertex buffer for caching a plurality of points.

[0087] In some embodiments, the rendering module 830 is further configured to use an image drawing model to perform a one-time rendering on the plurality of points in the vertex buffer based on the primitive drawing index array in the index buffer to obtain a rendered image corresponding to the image to be rendered.

[0088] It should be noted that when the above-described image rendering apparatus is used for image rendering, only the above-described division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above.

[0089] Those skilled in the art to which the present disclosure pertains can understand that various aspects of the present disclosure can be implemented as a system, a method, or a program product. Therefore, various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation manner, a complete software implementation manner (including firmware, microcode, etc.), or an implementation manner combining hardware and software aspects, which can be collectively referred to as "circuitry", "module", or "system" here.

[0090] Next, reference is made to Figure 9 to describe the electronic device 900 according to this embodiment of the present disclosure. Figure 9 The illustrated electronic device 900 is only an example and should not impose any limitation on the functions and applicable scope of the embodiments of the present disclosure.

[0091] As Figure 9 shown, the electronic device 900 is presented in the form of a general-purpose computing device. The components of the electronic device 900 may include, but are not limited to: the above-mentioned at least one processing unit 910, the above-mentioned at least one storage unit 920, and a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910).

[0092] Among them, the storage unit stores program codes, which can be executed by the processing unit 910, so that the processing unit 910 executes the steps according to various exemplary embodiments of the present disclosure described in the foregoing embodiments of this specification.

[0093] In some embodiments, the processing unit 910 may execute the following steps of the foregoing method embodiment: determining a plurality of points on the image to be rendered and the respective numbers of the plurality of points, the plurality of points being arranged in an array, and the plurality of points dividing the image to be rendered into a plurality of strips; creating a primitive drawing index array based on the respective numbers of the plurality of points, the primitive drawing index array sequentially including the numbers of the points corresponding to the plurality of strips respectively, and the head and tail of adjacent strips being opposite, and the numbers of the points corresponding to each strip being filled in sequence from the head to the tail in a way of up-and-down crossing, and after the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in sequence from the head to the tail in a way of up-and-down crossing; and sequentially drawing a plurality of points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered.

[0094] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 9201 and / or a cache storage unit 9202, and may further include a read-only storage unit (ROM) 9203.

[0095] The storage unit 920 may further include a program / utilities 9204 having a set (at least one) of program modules 9205. Such program modules 9205 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment.

[0096] The bus 930 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0097] The electronic device 900 can also communicate with one or more external devices 940 (such as a keyboard, a pointing device, a Bluetooth device, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 950. Moreover, the electronic device 900 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 960. As shown in the figure, the network adapter 960 communicates with other modules of the electronic device 900 through the bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0098] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software, or can be implemented by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0099] In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium, which can be a readable signal medium or a readable storage medium. A program product capable of implementing the above method of the present disclosure is stored thereon. In some possible implementation manners, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present disclosure described in the method embodiment part of this specification.

[0100] More specific examples of the computer-readable storage medium in the present disclosure may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0101] In the present disclosure, a computer-readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a readable program code is carried. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable signal medium may also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0102] Optionally, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0103] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., by connecting through the Internet using an Internet service provider).

[0104] It should be noted that although several modules or units of a device for action execution are mentioned in the above detailed description, such a division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more of the above-described modules or units may be embodied in one module or unit. Conversely, the features and functions of one module or unit described above may be further divided and embodied by multiple modules or units.

[0105] In addition, although the steps of the methods in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in that specific order, or that all of the steps shown must be performed to achieve the desired result. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.

[0106] From the description of the above embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on the network, including several instructions to enable a computing device (such as a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0107] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present disclosure. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed by the present disclosure. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the appended claims.

Claims

1. An image rendering method, characterized in that, comprising: determining a plurality of points on the image to be rendered and the respective numbers of the plurality of points, the plurality of points being arranged in an array, and the plurality of points dividing the image to be rendered into a plurality of strips; creating a primitive drawing index array based on the respective numbers of the plurality of points, the primitive drawing index array sequentially including the numbers of the points corresponding to the plurality of strips respectively, and the heads and tails of adjacent strips being opposite, and the numbers of the points corresponding to each strip are filled in order from the head to the tail in a way of crossing up and down, and after the number of the last point at the tail of each strip is filled in, the numbers of the points corresponding to the next strip continue to be filled in order from the head to the tail in a way of crossing up and down; rendering the plurality of points in sequence based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered; wherein, the rendering the plurality of points in sequence based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered includes: drawing straight lines connecting the plurality of points in sequence according to the order of the numbers of the points included in the primitive drawing index array to form a plurality of triangular primitives, thereby obtaining a rendered image corresponding to the image to be rendered; the drawing straight lines connecting the plurality of points in sequence according to the order of the numbers of the points included in the primitive drawing index array to form a plurality of triangular primitives includes: for each of the points, determining whether the position n of the number of the point in the primitive drawing index array is odd or even; if n is odd, sequentially connecting the three points corresponding to the numbers at the n-2, n-1, and n positions in the primitive drawing index array with straight lines to form the triangular primitive; if n is even, sequentially connecting the three points corresponding to the numbers at the n-1, n-2, and n positions in the primitive drawing index array with straight lines to form the triangular primitive.

2. The method according to claim 1, characterized in that, the creating a primitive drawing index array based on the respective numbers of the plurality of points includes: obtaining an empty initial index array; filling the numbers of the points corresponding to the plurality of strips into the initial index array in sequence according to the adjacency relationship between the plurality of strips to obtain the primitive drawing index array.

3. The method according to claim 2, characterized in that, the filling the numbers of the points corresponding to the plurality of strips into the initial index array in sequence includes: for each of the strips, starting from the head of the strip, filling the numbers of the points corresponding to the strip into the initial index array in order from the head to the tail in a way of crossing up and down.

4. The method according to claim 1, characterized in that, further comprising: determining at least one index buffer for caching the primitive drawing index array; and determining at least one vertex buffer for caching the plurality of points.

5. The method according to claim 4, characterized in that, the rendering the plurality of points in sequence based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered includes: Using an image rendering model, draw an index array of primitives based on the primitives in the index buffer, and perform one-time rendering on the multiple points in the vertex buffer to obtain a rendered image corresponding to the image to be rendered.

6. An image rendering device, characterized in that, it includes: a determination module, configured to determine multiple points on the image to be rendered and the respective numbers of the multiple points, the multiple points are arranged in an array, and the multiple points divide the image to be rendered into multiple strips; a sorting module, configured to create a primitive drawing index array based on the respective numbers of the multiple points, the primitive drawing index array sequentially includes the numbers of the points corresponding to the multiple strips, and the heads and tails of adjacent strips are opposite, and the numbers of the points corresponding to each strip are filled in sequentially from the head to the tail in a way of crossing up and down. After filling in the number of the last point at the tail of each strip, the numbers of the points corresponding to the next strip continue to be filled in sequentially from the head to the tail in a way of crossing up and down; a rendering module, configured to sequentially draw the multiple points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered; wherein, the sequentially drawing the multiple points based on the primitive drawing index array to obtain a rendered image corresponding to the image to be rendered includes: sequentially drawing straight lines connecting the multiple points according to the order of the numbers of the points included in the primitive drawing index array to form multiple triangular primitives, so as to obtain a rendered image corresponding to the image to be rendered; the sequentially drawing straight lines connecting the multiple points according to the order of the numbers of the points included in the primitive drawing index array to form multiple triangular primitives includes: for each of the points, determining whether the position n of the number of the point in the primitive drawing index array is odd or even; if n is odd, sequentially connect the three points corresponding to the numbers at the n-2, n-1, and n positions in the primitive drawing index array with straight lines to form the triangular primitive; if n is even, sequentially connect the three points corresponding to the numbers at the n-1, n-2, and n positions in the primitive drawing index array with straight lines to form the triangular primitive.

7. An electronic device, characterized in that, it includes: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the image rendering method according to any one of claims 1 to 5 by executing the executable instructions.

8. A computer-readable storage medium, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, it implements the image rendering method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Equipment point location screening method and device, electronic equipment and storage medium

    CN111383265A

  • Image processing method and device, electronic equipment and storage medium

    CN112488977A