CN112785713B - Method, device, equipment and readable storage medium for arranging light source - Google Patents
Method, device, equipment and readable storage medium for arranging light source Download PDFInfo
- Publication number
- CN112785713B CN112785713B CN202110127686.0A CN202110127686A CN112785713B CN 112785713 B CN112785713 B CN 112785713B CN 202110127686 A CN202110127686 A CN 202110127686A CN 112785713 B CN112785713 B CN 112785713B
- Authority
- CN
- China
- Prior art keywords
- cluster
- light source
- principal component
- component vector
- dimensional coordinates
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000005070 sampling Methods 0.000 claims abstract description 75
- 238000005286 illumination Methods 0.000 claims abstract description 41
- 238000000513 principal component analysis Methods 0.000 claims abstract description 12
- 238000004590 computer program Methods 0.000 claims description 8
- 238000003064 k means clustering Methods 0.000 claims description 6
- 238000009877 rendering Methods 0.000 abstract description 10
- 230000000007 visual effect Effects 0.000 abstract description 5
- 230000000694 effects Effects 0.000 description 9
- 238000010586 diagram Methods 0.000 description 7
- 239000000463 material Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 241001465382 Physalis alkekengi Species 0.000 description 1
- 239000002775 capsule Substances 0.000 description 1
- 239000012141 concentrate Substances 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 238000012800 visualization Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
- G06T17/20—Finite element generation, e.g. wire-frame surface description, tesselation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/213—Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
- G06F18/2134—Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods based on separation criteria, e.g. independent component analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/23—Clustering techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T19/00—Manipulating 3D models or images for computer graphics
- G06T19/20—Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2200/00—Indexing scheme for image data processing or generation, in general
- G06T2200/04—Indexing scheme for image data processing or generation, in general involving 3D image data
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Computation (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Computer Graphics (AREA)
- Software Systems (AREA)
- Architecture (AREA)
- Computer Hardware Design (AREA)
- Geometry (AREA)
- Image Generation (AREA)
Abstract
The invention discloses a method, a device, equipment and a readable storage medium for arranging light sources, wherein the method comprises the following steps: acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style; determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points; dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster; according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster are calculated by using a principal component analysis algorithm; arranging light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector; the invention can improve the illumination rendering fidelity and achieve better visual effect.
Description
Technical Field
The present invention relates to the field of building visualization technology, and in particular, to a method, an apparatus, a device, and a readable storage medium for arranging light sources.
Background
In a general visual scene of a building or a game with a realistic style, for lamps and lamp strips with different models, the deepened editing of the lighting effect usually needs to be manually participated, a general operation flow is that three-dimensional grid models of the lamps and the lamp strips are built by model staff firstly, then self-luminous materials are endowed to the three-dimensional grid models by scene building staff, and finally, a basic point light source and a rectangular light source are put at corresponding positions of the three-dimensional grid models to simulate the lighting effect; although some schemes for automatically rendering and illuminating exist in the prior art, at most, self-luminous materials can be automatically set according to a three-dimensional grid model, or point light sources are automatically arranged at the axial points of the three-dimensional grid model; however, if the self-luminous grid is only provided, the surrounding environment cannot be illuminated, and the lighting effect of the lamp and the lamp strip with special shapes cannot be completely simulated by arranging the point light sources at the axial points. In addition, if rely on the designer to put the light source by hand, not only can let the designer not concentrate on the design of lamps and lanterns, lamp area, can also increase very big work load for the designer.
Disclosure of Invention
The invention aims to provide a method, a device, equipment and a readable storage medium for arranging a light source, which are applied to real-time rendering of indoor illumination of a building, can improve the reality of the illumination rendering and achieve better visual effect.
According to one aspect of the present invention, there is provided a method of arranging light sources, the method comprising:
Acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
Determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points;
dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster are calculated by using a principal component analysis algorithm;
the light sources are arranged in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
Optionally, the step of determining uniformly distributed sampling points in the light band three-dimensional grid model and acquiring three-dimensional coordinates of the sampling points includes:
Analyzing triangular grid units forming the lamp strip three-dimensional grid model;
Acquiring three-dimensional coordinates of a first vertex, a second vertex and a third vertex in the triangular grid unit; wherein the first vertex and the second vertex are two endpoints of the longest side in the triangular mesh unit;
According to the three-dimensional coordinates of the first vertex and the second vertex, determining the three-dimensional coordinates of a plurality of first interpolation points on the longest edge according to a random step length and by utilizing a bilinear interpolation algorithm;
according to the three-dimensional coordinates of the third vertex and each first interpolation point, determining the three-dimensional coordinates of a plurality of second interpolation points on the connecting line of the third vertex and each first interpolation point according to a random step length and by utilizing a bilinear interpolation algorithm;
and setting all the determined second interpolation points as the sampling points.
Optionally, the step of dividing all sampling points into a plurality of clusters includes:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, calculating the number of required light sources according to the total length of the lamp strip of the linear lamp strip three-dimensional grid model and the irradiation length of a preset unit point light source; or when the lamp strip three-dimensional grid model is a surface type lamp strip three-dimensional grid model, calculating the number of required light sources according to the total area of the lamp strip of the surface type lamp strip three-dimensional grid model and the irradiation area of a preset unit area light source;
Setting the required light source quantity as a clustering quantity K, and dividing all sampling points into K clusters by using a K-means clustering algorithm according to the clustering quantity K.
Optionally, the step of setting the required number of light sources to the number of clusters K includes:
Judging whether the number of the required light sources is larger than a preset threshold value or not;
if yes, setting the preset threshold value as the clustering number K; if not, setting the required light source quantity as cluster quantity K.
Optionally, the step of arranging the light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector includes:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the radius of the light source according to the size of a second principal component vector;
drawing a strip point light source according to the length of the light source and the radius of the light source;
and taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the strip-shaped point light source, and arranging the strip-shaped point light source in the cluster according to the direction of the first principal component vector and the direction of the second principal component vector.
Optionally, the step of arranging the light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector includes:
when the lamp strip three-dimensional grid model is a surface lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the width of the light source according to the size of a second principal component vector;
drawing a rectangular light source according to the length of the light source and the width of the light source;
Acquiring the front and back marks of the three-dimensional grid model of the back-side lamp strip;
And taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the rectangular light source, and arranging the rectangular light source in the cluster according to the direction of the first principal component vector, the direction of the second principal component vector and the front and back marks.
Optionally, after the step of arranging the light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector, the method further comprises:
When the light belt three-dimensional grid model is a linear light belt three-dimensional grid model, respectively calculating the illumination intensity of the strip-shaped point light sources arranged in each cluster according to the light source length of the strip-shaped point light sources arranged in each cluster and the preset unit point light source illumination intensity; or alternatively
When the light strip three-dimensional grid model is a planar light strip three-dimensional grid model, calculating a light source area according to the light source length and the light source width of the rectangular light sources arranged in each cluster, and calculating the illumination intensity of the rectangular light sources arranged in each cluster according to the light source area of the rectangular light sources arranged in each cluster and the preset unit area light source illumination intensity.
In order to achieve the above object, the present invention also provides a device for arranging a light source, the device specifically comprising the following components:
the acquisition module is used for acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
the sampling module is used for determining uniformly distributed sampling points in the lamp strip three-dimensional grid model and acquiring three-dimensional coordinates of the sampling points;
The clustering module is used for dividing all the sampling points into a plurality of clusters and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
The analysis module is used for calculating a first principal component vector and a second principal component vector which are mutually orthogonal in each cluster by utilizing a principal component analysis algorithm according to the three-dimensional coordinates of the sampling points in each cluster;
an arrangement module for arranging the light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
In order to achieve the above object, the present invention further provides a computer device, which specifically includes: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of arranging light sources described above when the computer program is executed.
In order to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the above-described method of arranging light sources.
According to the method, the device, the equipment and the readable storage medium for arranging the light sources, the point light sources and the rectangular light sources can be automatically arranged according to the modeling of the lamp strip grid model, so that the illumination shape generated by superposition of the arranged light sources basically accords with the real photo shape of the lamp strip modeling, the illumination light sources can be arranged for the special-shaped lamp strip in an automatic mode under the condition of no manual participation, the illumination effect of the special-shaped lamp strip is approximated, the illumination rendering fidelity can be improved, and the better visual effect is achieved.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 is a schematic flow chart of an alternative method for arranging light sources according to the first embodiment;
FIG. 2 is a schematic diagram of a three-dimensional mesh model of a linear lamp strip in a first embodiment;
FIG. 3 is a schematic diagram of a three-dimensional mesh model of a surface-mounted light strip in accordance with a first embodiment;
FIG. 4 is a schematic view showing an alternative composition of a device for arranging light sources according to the second embodiment;
fig. 5 is a schematic diagram of an alternative hardware architecture of a computer device according to the third embodiment.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
The embodiment of the invention provides a method for arranging a light source, as shown in fig. 1, which specifically comprises the following steps:
step S101: and acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip patterns.
Wherein, the three-dimensional mesh model of lamp area includes: a linear light belt three-dimensional grid model and a surface light belt three-dimensional grid model, wherein the light belt three-dimensional grid model is composed of a plurality of triangular grid units; as shown in fig. 2, a schematic diagram of a three-dimensional mesh model of a linear lamp strip is shown, and as shown in fig. 3, a schematic diagram of a three-dimensional mesh model of a planar lamp strip is shown.
Specifically, after step S101, the method further includes:
Acquiring attribute information of the lamp strip three-dimensional grid model; wherein, when the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, the attribute information includes: the total length of the lamp strip; when the light strip three-dimensional grid model is a surface light strip three-dimensional grid model, the attribute information includes: the total area of the lamp strip and the front and back marks.
The attribute information is parameter information set when the lamp strip three-dimensional grid model is created; the front and back marks are used for marking the front and back of the three-dimensional grid model of the lamp strip.
Step S102: and determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points.
Specifically, step S102 includes:
Step A1: analyzing triangular grid units forming the lamp strip three-dimensional grid model;
In the schematic diagram of the linear lamp strip three-dimensional grid model shown in fig. 2, the linear lamp strip three-dimensional grid model is composed of a plurality of long triangular grid cells; in the schematic diagram of the surface light band three-dimensional mesh model shown in fig. 3, the surface light band three-dimensional mesh model is composed of a plurality of.
Step A2: acquiring three-dimensional coordinates of a first vertex, a second vertex and a third vertex in the triangular grid unit; wherein the first vertex and the second vertex are two endpoints of the longest side in the triangular mesh unit.
Step A3: according to the three-dimensional coordinates of the first vertex and the second vertex, determining the three-dimensional coordinates of a plurality of first interpolation points on the longest edge according to a random step length and by utilizing a bilinear interpolation algorithm;
Wherein the random step size is used for determining the distance between two adjacent first interpolation points.
Step A4: according to the three-dimensional coordinates of the third vertex and each first interpolation point, determining the three-dimensional coordinates of a plurality of second interpolation points on the connecting line of the third vertex and each first interpolation point according to a random step length and by utilizing a bilinear interpolation algorithm;
wherein the random step size is used for determining the distance between two adjacent second interpolation points.
Step A5: and setting all the determined second interpolation points as the sampling points.
In the embodiment, a bilinear interpolation algorithm is utilized to respectively determine sampling points in each triangular grid unit, so that the sampling points in the three-dimensional grid model of the lamp strip are obtained; in addition, in order to obtain uniformly distributed sampling points, interpolation step parameters in a bilinear interpolation algorithm are taken as random values between two steps, namely, step sizes are set as random values, so that a plurality of first interpolation points can be randomly determined on the longest side, and a plurality of second interpolation points can be randomly determined on the connecting line of the third vertex and each first interpolation point, so that the sampling points are uniformly distributed as much as possible. In addition, in order to avoid the occurrence of a situation in which the step length is longer than the shortest side length in the triangular mesh unit due to the triangular mesh unit being long when the light band three-dimensional mesh model is a linear light band three-dimensional mesh model, in the present embodiment, the interpolation order is adjusted, and the longest side in the triangular mesh unit is taken as the side of initial interpolation.
In practical application, besides the bilinear interpolation algorithm adopted in the embodiment, other algorithms or modes can be adopted to determine uniformly distributed sampling points in the three-dimensional grid model of the lamp strip, so the method is not particularly limited herein.
Step S103: dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster.
Specifically, the step of dividing all the sampling points into a plurality of clusters includes:
Step B1: when the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, calculating the number of required light sources according to the total length of the lamp strip of the linear lamp strip three-dimensional grid model and the irradiation length of a preset unit point light source; or when the lamp strip three-dimensional grid model is a surface type lamp strip three-dimensional grid model, calculating the number of required light sources according to the total area of the lamp strip of the surface type lamp strip three-dimensional grid model and the irradiation area of a preset unit area light source;
Preferably, the ratio of the total length of the lamp strip to the irradiation length of the preset unit point light source is used as the number of required light sources, and the ratio of the total area of the lamp strip to the irradiation area of the preset unit point light source is used as the number of required light sources; it should be noted that, in practical application, other formulas for representing the corresponding relation between the total length of the light band and the irradiation length of the preset unit point light source or formulas for representing the corresponding relation between the total area of the light band and the irradiation area of the preset unit point light source may be used to calculate the required number of light sources, so the method is not limited in detail herein.
In this embodiment, the number of light sources to be arranged on the light strip is determined according to the total length of the light strip or the total area of the light strip in the attribute information of the three-dimensional grid model of the light strip, and a preset unit light source irradiation length or unit area light source irradiation area. The operation has two benefits, namely, for the special-shaped lamp strip with small area, short length and high modeling complexity, the light source with a small number can still be used for approximate simulation, so that a large number of light sources can be prevented from being sampled in a small range; for example, a small area lamp strip with very many folding lines is approximated by 8 light sources, which saves a lot of resources compared with the arrangement of the light sources according to the number of the folding line segments; on the other hand, for a light strip with large area and low modeling complexity, more light sources can be used for approximately restoring the illumination effect, for example, a large rectangular light strip is disassembled into a plurality of small rectangles, and the light sources are arranged at the small rectangles to ensure better illumination effect.
Step B2: and setting the required light source number as a cluster number K, and dividing all sampling points into K clusters by using K-Means (K-Means Clustering Algorithm ) according to the cluster number K.
In practical application, besides the K-Means clustering algorithm adopted in the present embodiment, other algorithms or modes may be adopted to group and cluster the sampling points, so the method is not particularly limited herein.
Further, the step of setting the required number of light sources to the number of clusters K includes:
Judging whether the number of the required light sources is larger than a preset threshold value or not;
if yes, setting the preset threshold value as the clustering number K; if not, setting the required light source quantity as cluster quantity K.
It should be further noted that, when the total length of the light band is long or the total area of the light band is large, the calculated number of required light sources will be large, but since the time consumption of the K-Means clustering algorithm increases with the increase of the number of clusters K, in order to improve the efficiency of arranging the light sources, the operation complexity of the algorithm is reduced, and when the total length of the light band is long or the total area of the light band is large, the maximum number of clusters K needs to be limited; preferably, the maximum number of clusters K is set to 100, i.e. the preset threshold is set to 100. For example, when the total area of the light band is large, the number of clusters K is not increased any more, so that each light source irradiates an area larger on average.
Step S104: and according to the three-dimensional coordinates of the sampling points in each cluster, calculating a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster by using a principal component analysis algorithm.
In this embodiment, the three-dimensional coordinates of the sampling points in a cluster are transformed into a two-dimensional coordinate system using a principal component analysis (PCA, PRINCIPAL COMPONENTS ANALYSIS) algorithm such that a first large variance of the projection of the three-dimensional coordinates of all the sampling points is on a first principal component vector and a second large variance is on a second principal component vector. In this embodiment, the three-dimensional sampling points are reduced to the two-dimensional first principal component vector and the two-dimensional second principal component vector in each cluster by using a principal component analysis algorithm, so that the features of the sampling points in each cluster are represented by the first principal component vector and the second principal component vector in each cluster.
It should be noted that, since the principal component analysis algorithm is an existing dimension reduction algorithm for converting multiple indexes into a few comprehensive indexes, a detailed process of how to form the first principal component vector and the second principal component vector of a cluster according to the three-dimensional coordinates of the sampling points in the cluster is not described in detail.
Step S105: the light sources are arranged in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
Specifically, step S105 includes:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the radius of the light source according to the size of a second principal component vector;
drawing a strip point light source according to the length of the light source and the radius of the light source;
and taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the strip-shaped point light source, and arranging the strip-shaped point light source in the cluster according to the direction of the first principal component vector and the direction of the second principal component vector.
Further, step S105 further includes:
when the lamp strip three-dimensional grid model is a surface lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the width of the light source according to the size of a second principal component vector;
drawing a rectangular light source according to the length of the light source and the width of the light source;
Acquiring the front and back marks of the three-dimensional grid model of the back-side lamp strip;
And taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the rectangular light source, and arranging the rectangular light source in the cluster according to the direction of the first principal component vector, the direction of the second principal component vector and the front and back marks.
In this embodiment, the light sources are arranged in each cluster, the light sources are positioned by the three-dimensional coordinates of the central point of the cluster, and the shape, size and placement posture of the light sources are determined according to the first principal component vector and the second principal component vector of the cluster. In this embodiment, the light source includes: a rectangular point light source and a rectangular light source; the strip-shaped point light source is a strip-shaped capsule body, so that the length and the radius of the light source are required to be determined, the limitation of a three-dimensional grid model of the light belt is avoided, and the front and back marks of the three-dimensional grid model of the light belt are not required to be arranged on the strip-shaped point light source; and the front and back sides of the three-dimensional grid model of the lamp strip need to be considered when the rectangular light source is arranged, so that the front and back sides of the three-dimensional grid model of the lamp strip need to be marked when the rectangular light source is arranged.
Still further, after step S105, the method further includes:
When the light belt three-dimensional grid model is a linear light belt three-dimensional grid model, respectively calculating the illumination intensity of the strip-shaped point light sources arranged in each cluster according to the light source length of the strip-shaped point light sources arranged in each cluster and the preset unit point light source illumination intensity; or alternatively
When the light strip three-dimensional grid model is a planar light strip three-dimensional grid model, calculating a light source area according to the light source length and the light source width of the rectangular light sources arranged in each cluster, and calculating the illumination intensity of the rectangular light sources arranged in each cluster according to the light source area of the rectangular light sources arranged in each cluster and the preset unit area light source illumination intensity.
Preferably, the product of the length of the light source and the illumination intensity of the preset unit point light source is taken as illumination intensity, and the product of the area of the light source and the illumination intensity of the preset unit point light source is taken as illumination intensity; it should be noted that, in practical application, other formulas for representing the corresponding relation between the length of the light source and the illumination intensity of the preset unit point light source or formulas for representing the corresponding relation between the area of the light source and the illumination intensity of the preset unit point light source may be used to calculate the illumination intensity, so the present invention is not limited specifically.
In practical application, the position and posture information and illumination intensity information of all the light sources arranged on the light strip three-dimensional grid model are input into an existing illumination rendering engine, and the final illumination rendering effect of the light strip three-dimensional grid model can be obtained. It should be noted that, the linear light strip may be embedded into the wall in business, and if a normal illumination intensity attenuation mode is adopted, overexposure at the light source may be caused, so that an illumination area around the light source is too small; therefore, in order to solve the problem of inaccurate lighting rendering effect caused by embedding the linear light strip into the wall, when the existing lighting rendering engine is used, the square attenuation of the light source conforming to physics needs to be adjusted to be linear attenuation, and then the overall light source intensity is reduced, so that soft halation is generated.
Through the embodiment introduced above, the point light sources and the rectangular light sources can be automatically arranged according to the modeling of the light strip grid model, so that the illumination shape generated by overlapping the arranged light sources basically accords with the real photo shape of the modeling of the light strip, the illumination light sources can be automatically arranged for the special-shaped light strip without manual participation, the illumination effect of the special-shaped light strip is similar, the illumination rendering fidelity can be improved, and the better visual effect is achieved.
Example two
The embodiment of the invention provides a device for arranging a light source, as shown in fig. 4, which specifically comprises the following components:
An obtaining module 401, configured to obtain a preset lamp band three-dimensional grid model for characterizing a lamp band style;
the sampling module 402 is configured to determine uniformly distributed sampling points in the light band three-dimensional grid model, and obtain three-dimensional coordinates of the sampling points;
A clustering module 403, configured to divide all the sampling points into a plurality of clusters, and calculate the three-dimensional coordinates of the center point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
The analysis module 404 is configured to calculate, according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector orthogonal to each other in each cluster by using a principal component analysis algorithm;
An arrangement module 405 for arranging the light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
Specifically, the sampling module 402 is configured to:
Analyzing triangular grid units forming the lamp strip three-dimensional grid model;
Acquiring three-dimensional coordinates of a first vertex, a second vertex and a third vertex in the triangular grid unit; wherein the first vertex and the second vertex are two endpoints of the longest side in the triangular mesh unit.
According to the three-dimensional coordinates of the first vertex and the second vertex, determining the three-dimensional coordinates of a plurality of first interpolation points on the longest edge according to a random step length and by utilizing a bilinear interpolation algorithm;
according to the three-dimensional coordinates of the third vertex and each first interpolation point, determining the three-dimensional coordinates of a plurality of second interpolation points on the connecting line of the third vertex and each first interpolation point according to a random step length and by utilizing a bilinear interpolation algorithm;
and setting all the determined second interpolation points as the sampling points.
Specifically, the clustering module 403 includes:
The calculating unit is used for calculating the number of required light sources according to the total length of the lamp strip of the linear lamp strip three-dimensional grid model and the irradiation length of a preset unit point light source when the lamp strip three-dimensional grid model is the linear lamp strip three-dimensional grid model; or when the lamp strip three-dimensional grid model is a surface type lamp strip three-dimensional grid model, calculating the number of required light sources according to the total area of the lamp strip of the surface type lamp strip three-dimensional grid model and the irradiation area of a preset unit area light source;
And the clustering unit is used for setting the required light source quantity as a clustering quantity K and dividing all sampling points into K clusters by utilizing a K-means clustering algorithm according to the clustering quantity K.
Further, the clustering unit is specifically configured to:
Judging whether the number of the required light sources is larger than a preset threshold value or not;
if yes, setting the preset threshold value as the clustering number K; if not, setting the required light source quantity as cluster quantity K.
Specifically, the arrangement module 405 is configured to:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the radius of the light source according to the size of a second principal component vector;
drawing a strip point light source according to the length of the light source and the radius of the light source;
and taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the strip-shaped point light source, and arranging the strip-shaped point light source in the cluster according to the direction of the first principal component vector and the direction of the second principal component vector.
Further, the arrangement module 405 is further configured to:
when the lamp strip three-dimensional grid model is a surface lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the width of the light source according to the size of a second principal component vector;
drawing a rectangular light source according to the length of the light source and the width of the light source;
Acquiring the front and back marks of the three-dimensional grid model of the back-side lamp strip;
And taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the rectangular light source, and arranging the rectangular light source in the cluster according to the direction of the first principal component vector, the direction of the second principal component vector and the front and back marks.
Still further, the apparatus further comprises:
the intensity module is used for respectively calculating the illumination intensity of the strip-shaped point light sources arranged in each cluster according to the light source length of the strip-shaped point light sources arranged in each cluster and the illumination intensity of the preset unit point light sources when the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model; or when the light strip three-dimensional grid model is a surface light strip three-dimensional grid model, calculating the light source area according to the light source length and the light source width of the rectangular light sources arranged in each cluster, and respectively calculating the illumination intensity of the rectangular light sources arranged in each cluster according to the light source area of the rectangular light sources arranged in each cluster and the preset unit area light source illumination intensity.
Example III
The present embodiment also provides a computer device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack-mounted server, a blade server, a tower server, or a rack-mounted server (including an independent server or a server cluster formed by a plurality of servers) that can execute a program. As shown in fig. 5, the computer device 50 of the present embodiment includes at least, but is not limited to: a memory 501, and a processor 502 which may be communicatively coupled to each other via a system bus. It should be noted that FIG. 5 only shows computer device 50 having components 501-502, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead.
In this embodiment, the memory 501 (i.e., readable storage medium) includes flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 501 may be an internal storage unit of the computer device 50, such as a hard disk or memory of the computer device 50. In other embodiments, the memory 501 may also be an external storage device of the computer device 50, such as a plug-in hard disk provided on the computer device 50, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD), or the like. Of course, memory 501 may also include both internal storage units of computer device 50 and external storage devices. In this embodiment, the memory 501 is typically used to store an operating system and various types of application software installed on the computer device 50. Further, the memory 501 may be used to temporarily store various types of data that have been output or are to be output.
The processor 502 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 502 is generally used to control the overall operation of the computer device 50.
Specifically, in the present embodiment, the processor 502 is configured to execute a program of a method of arranging light sources stored in the memory 501, which when executed implements the steps of:
Acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
Determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points;
dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster are calculated by using a principal component analysis algorithm;
the light sources are arranged in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
The specific embodiment of the above method steps may refer to the first embodiment, and this embodiment is not repeated here.
Example IV
The present embodiment also provides a computer readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application store, etc., having stored thereon a computer program that when executed by a processor performs the following method steps:
Acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
Determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points;
dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster are calculated by using a principal component analysis algorithm;
the light sources are arranged in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector and the second principal component vector.
The specific embodiment of the above method steps may refer to the first embodiment, and this embodiment is not repeated here.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.
Claims (10)
1. A method of arranging light sources, the method comprising:
Acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
Determining uniformly distributed sampling points in the lamp strip three-dimensional grid model, and acquiring three-dimensional coordinates of the sampling points;
dividing all the sampling points into a plurality of clusters, and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
according to the three-dimensional coordinates of the sampling points in each cluster, a first principal component vector and a second principal component vector which are orthogonal to each other in each cluster are calculated by using a principal component analysis algorithm;
Arranging light sources in each cluster according to the three-dimensional coordinates of the center point, the first principal component vector, and the second principal component vector of each cluster, comprising: and positioning the light source through the three-dimensional coordinates of the central point of the cluster, and determining the shape, size and placement posture of the light source according to the first principal component vector and the second principal component vector of the cluster.
2. The method of arranging light sources according to claim 1, wherein the step of determining uniformly distributed sampling points in the lamp strip three-dimensional grid model and acquiring three-dimensional coordinates of the sampling points comprises:
Analyzing triangular grid units forming the lamp strip three-dimensional grid model;
Acquiring three-dimensional coordinates of a first vertex, a second vertex and a third vertex in the triangular grid unit; wherein the first vertex and the second vertex are two endpoints of the longest side in the triangular mesh unit;
According to the three-dimensional coordinates of the first vertex and the second vertex, determining the three-dimensional coordinates of a plurality of first interpolation points on the longest edge according to a random step length and by utilizing a bilinear interpolation algorithm;
according to the three-dimensional coordinates of the third vertex and each first interpolation point, determining the three-dimensional coordinates of a plurality of second interpolation points on the connecting line of the third vertex and each first interpolation point according to a random step length and by utilizing a bilinear interpolation algorithm;
and setting all the determined second interpolation points as the sampling points.
3. The method of arranging light sources of claim 1, wherein the step of dividing all sampling points into a plurality of clusters comprises:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, calculating the number of required light sources according to the total length of the lamp strip of the linear lamp strip three-dimensional grid model and the irradiation length of a preset unit point light source; or when the lamp strip three-dimensional grid model is a surface type lamp strip three-dimensional grid model, calculating the number of required light sources according to the total area of the lamp strip of the surface type lamp strip three-dimensional grid model and the irradiation area of a preset unit area light source;
Setting the required light source quantity as a clustering quantity K, and dividing all sampling points into K clusters by using a K-means clustering algorithm according to the clustering quantity K.
4. A method of arranging light sources according to claim 3, wherein the step of setting the required number of light sources to a number of clusters K comprises:
Judging whether the number of the required light sources is larger than a preset threshold value or not;
if yes, setting the preset threshold value as the clustering number K; if not, setting the required light source quantity as cluster quantity K.
5. The method of arranging light sources according to claim 1, wherein the step of arranging light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector, and the second principal component vector, comprises:
When the lamp strip three-dimensional grid model is a linear lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the radius of the light source according to the size of a second principal component vector;
drawing a strip point light source according to the length of the light source and the radius of the light source;
and taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the strip-shaped point light source, and arranging the strip-shaped point light source in the cluster according to the direction of the first principal component vector and the direction of the second principal component vector.
6. The method of arranging light sources of claim 5, wherein the step of arranging light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector, and the second principal component vector, comprises:
when the lamp strip three-dimensional grid model is a surface lamp strip three-dimensional grid model, determining the length of a light source according to the size of a first principal component vector of the cluster and determining the width of the light source according to the size of a second principal component vector;
drawing a rectangular light source according to the length of the light source and the width of the light source;
Acquiring the front and back marks of the three-dimensional grid model of the back-side lamp strip;
And taking the three-dimensional coordinates of the central point of the cluster as the three-dimensional coordinates of the central point of the rectangular light source, and arranging the rectangular light source in the cluster according to the direction of the first principal component vector, the direction of the second principal component vector and the front and back marks.
7. The method of arranging light sources of claim 6, wherein after the step of arranging light sources in each cluster according to the three-dimensional coordinates of the center point of each cluster, the first principal component vector, and the second principal component vector, the method further comprises:
When the light belt three-dimensional grid model is a linear light belt three-dimensional grid model, respectively calculating the illumination intensity of the strip-shaped point light sources arranged in each cluster according to the light source length of the strip-shaped point light sources arranged in each cluster and the preset unit point light source illumination intensity; or alternatively
When the light strip three-dimensional grid model is a planar light strip three-dimensional grid model, calculating a light source area according to the light source length and the light source width of the rectangular light sources arranged in each cluster, and calculating the illumination intensity of the rectangular light sources arranged in each cluster according to the light source area of the rectangular light sources arranged in each cluster and the preset unit area light source illumination intensity.
8. An apparatus for arranging light sources, the apparatus comprising:
the acquisition module is used for acquiring a preset lamp strip three-dimensional grid model for representing the lamp strip style;
the sampling module is used for determining uniformly distributed sampling points in the lamp strip three-dimensional grid model and acquiring three-dimensional coordinates of the sampling points;
The clustering module is used for dividing all the sampling points into a plurality of clusters and calculating the three-dimensional coordinates of the central point of each cluster according to the three-dimensional coordinates of the sampling points in each cluster;
The analysis module is used for calculating a first principal component vector and a second principal component vector which are mutually orthogonal in each cluster by utilizing a principal component analysis algorithm according to the three-dimensional coordinates of the sampling points in each cluster;
An arrangement module for arranging light sources in each cluster according to three-dimensional coordinates of a center point of each cluster, a first principal component vector, and a second principal component vector, comprising: and positioning the light source through the three-dimensional coordinates of the central point of the cluster, and determining the shape, size and placement posture of the light source according to the first principal component vector and the second principal component vector of the cluster.
9. A computer device, the computer device comprising: memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any one of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110127686.0A CN112785713B (en) | 2021-01-29 | 2021-01-29 | Method, device, equipment and readable storage medium for arranging light source |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110127686.0A CN112785713B (en) | 2021-01-29 | 2021-01-29 | Method, device, equipment and readable storage medium for arranging light source |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112785713A CN112785713A (en) | 2021-05-11 |
CN112785713B true CN112785713B (en) | 2024-06-14 |
Family
ID=75759901
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110127686.0A Active CN112785713B (en) | 2021-01-29 | 2021-01-29 | Method, device, equipment and readable storage medium for arranging light source |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112785713B (en) |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7167176B2 (en) * | 2003-08-15 | 2007-01-23 | Microsoft Corporation | Clustered principal components for precomputed radiance transfer |
JP2006350678A (en) * | 2005-06-16 | 2006-12-28 | Nippon Telegr & Teleph Corp <Ntt> | Ray information generation method, method for generating compressed data of ray information, ray information generation device, device for generating compressed data of ray information, program therefor, and recording medium with program recorded |
KR101520647B1 (en) * | 2008-01-21 | 2015-05-15 | 삼성전자 주식회사 | Method and system for compressing and decoding mesh data of 3-dimensional mesh model. |
CN102542599B (en) * | 2010-12-31 | 2016-03-09 | 赛恩倍吉科技顾问(深圳)有限公司 | Offline image programming photoenvironment simulation system and method |
US9674929B2 (en) * | 2014-03-10 | 2017-06-06 | Massachusetts Institute Of Technology | Methods and apparatus for illumination control |
CN117038018A (en) * | 2017-12-06 | 2023-11-10 | 文塔纳医疗系统公司 | Method for storing and retrieving digital pathology analysis results |
WO2020249502A1 (en) * | 2019-06-14 | 2020-12-17 | Signify Holding B.V. | A method for controlling a plurality of lighting units of a lighting system |
WO2020249543A1 (en) * | 2019-06-14 | 2020-12-17 | Signify Holding B.V. | A controller for downscaling a set of light settings and a method thereof |
-
2021
- 2021-01-29 CN CN202110127686.0A patent/CN112785713B/en active Active
Non-Patent Citations (1)
Title |
---|
基于空间自适应剖分的Lightcuts多光源聚类算法;袁昱纬;刘传辉;全吉成;王宏伟;吴晨;;海军航空工程学院学报(02);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN112785713A (en) | 2021-05-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR102319179B1 (en) | A rendering method for simulating lighting, and a terminal | |
US8705843B2 (en) | Method for texturizing virtual three-dimensional objects | |
US8175734B2 (en) | Methods and system for enabling printing three-dimensional object models | |
CN112596713B (en) | Processing method and device based on illusion engine, electronic equipment and storage medium | |
Peng et al. | Exploring quadrangulations | |
CN110992466B (en) | Illumination probe generation method and device, storage medium and computer equipment | |
CN113724401B (en) | Three-dimensional model cutting method and device, computer equipment and storage medium | |
WO2019050580A1 (en) | Method and device for infrastructure design using 3d reality data | |
CN109462926A (en) | Rendering method, device, equipment and the storage medium of smart allocation light | |
CN114139250A (en) | Automatic light distribution method, device, equipment and storage medium based on illusion engine | |
CN112785713B (en) | Method, device, equipment and readable storage medium for arranging light source | |
CN115738246A (en) | Method and device for constructing insert piece combination model and electronic equipment | |
JP6249508B2 (en) | Change detection support device, change detection support method, and program | |
CN111882677A (en) | Method and device for editing three-dimensional plant model, electronic equipment and storage medium | |
CN111931746B (en) | Vehicle loss judgment method and device, computer equipment and readable storage medium | |
CN114241116A (en) | Method and device for previewing illumination effect in real time, electronic equipment and medium | |
CN114139249A (en) | Automatic light distribution method and device based on illusion engine and electronic equipment | |
CN111462343B (en) | Data processing method and device, electronic equipment and storage medium | |
CN109885783B (en) | Loading method and device of three-dimensional building model | |
CN113593036A (en) | Imaging system, method, device and program with reference to grid parameterized model | |
CN112884899A (en) | Three-dimensional member generation method and device, computer device and storage medium | |
CN117333624B (en) | Method, device, equipment and readable storage medium for reconstructing top layer of three-dimensional model | |
CN117115383B (en) | Lighting lamp arrangement method, computer device and readable storage medium | |
CN110362942A (en) | A kind of generation method on PCB track side generates system and relevant apparatus | |
CN115830286B (en) | Baking method for keeping consistent amount of three-dimensional scene texture definition |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |