A position determination method, apparatus, electronic device, and readable storage medium
By acquiring top-down views of the virtual scene and the model to be placed, filtering candidate pixels, and determining the target position, the problem of high manpower cost and low efficiency in model placement in 3D virtual scenes is solved, achieving efficient and intelligent model placement and shooting effects that meet user expectations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING QIYI CENTURY SCI & TECH CO LTD
- Filing Date
- 2022-09-29
- Publication Date
- 2026-05-19
AI Technical Summary
Randomly placing object models in a 3D virtual scene is both labor-intensive and inefficient.
By acquiring a top-down view of the virtual scene and the model to be placed, the distance and radius of each pixel are determined, candidate pixels are filtered, and the target position of the model is determined based on the target pixels. Taking into account the shooting effect and the occlusion ratio, the placement position of the model is intelligently determined.
It enables efficient and intelligent determination of model positions in virtual scenes, saving labor costs, improving placement efficiency, and ensuring that the shooting results meet user expectations.
Smart Images

Figure CN115578450B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtual reality technology, and in particular to a position determination method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] In the construction of 3D virtual scenes, there is often a significant workload for model placement and a high requirement for model randomness for 3D virtual scenes containing a lot of detail. For example, the appearance positions of prop models such as "treasure chests" and "toolboxes" in game simulation scenes should be random to make the game simulation scene as natural and highly realistic as possible. The traditional method of achieving random model placement mainly relies on manually determining the position of the random model in the 3D virtual scene and then manually placing the model in that position. However, since there are often a large number of randomly placed item models in a virtual scene, manually determining the random placement position is labor-intensive and inefficient. Summary of the Invention
[0003] To address the technical problems of high labor costs and low efficiency in achieving random placement of items through manual operation, this application provides a location determination method, apparatus, electronic device, and readable storage medium.
[0004] Firstly, a method for determining a location is provided, the method comprising:
[0005] Obtain a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed.
[0006] Determine the distance corresponding to each second pixel, and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel that is closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view;
[0007] Among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length are determined as candidate pixels;
[0008] A target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be determined based on the target pixel.
[0009] In one possible implementation, determining the target pixel among the candidate pixels includes:
[0010] For each candidate pixel, a virtual shooting position is determined according to a preset horizontal shooting angle and shooting distance. The candidate pixel and the pixel where the virtual shooting position is located are connected to obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel.
[0011] If the corresponding virtual shooting optical path passes through any of the first pixels, the candidate pixel is determined as a pixel to be confirmed, and the target pixel is determined among the pixels to be confirmed.
[0012] If the corresponding virtual shooting optical path does not pass through all the first pixels, the candidate pixel is determined as the target pixel.
[0013] In one possible implementation, determining the target pixel among the pixels to be confirmed includes:
[0014] Determine the first dimension of the model to be placed;
[0015] For each pixel to be confirmed, the shooting range corresponding to the pixel to be confirmed is determined, and the first pixel through which the virtual shooting light path passes is determined as the obstacle pixel corresponding to the pixel to be confirmed, and the second size of the placed model corresponding to the obstacle pixel is determined;
[0016] Based on the first size, the second size, and the shooting range, the shooting effect corresponding to the pixel to be confirmed is determined. The shooting effect is used to characterize the occlusion ratio of the model to be placed when the model to be placed is photographed.
[0017] If the occlusion ratio is less than a preset threshold, the pixel to be confirmed is determined as the target pixel.
[0018] In one possible implementation, determining the distance corresponding to each of the second pixels includes:
[0019] The first top view is binarized to obtain the corresponding grayscale image;
[0020] A signed distance field corresponding to the grayscale image is created using a fast traversal algorithm, wherein the signed distance field marks the distance between each second pixel and the first pixel that is closest to the second pixel among all the first pixels.
[0021] In one possible implementation, the position of the model already placed in the first top view is determined by the following steps:
[0022] Obtain the first transformation relationship from the virtual scene to the first top view;
[0023] For each placed model corresponding to the virtual scene, determine the position of the first bounding box corresponding to the placed model in the virtual scene;
[0024] Based on the first transformation relationship, the position of the first bounding box is transformed to obtain the position of the first bounding box in the first top view;
[0025] The position of the first bounding box in the first top view is determined as the position of the placed model.
[0026] In one possible implementation, the second top view corresponding to the model to be placed is obtained through the following steps;
[0027] Determine the second bounding box corresponding to the model to be placed;
[0028] The second bounding box is transformed based on the first transformation relationship to obtain the second top view.
[0029] In one possible implementation, determining the target location in the virtual scene where the model to be placed can be placed based on the target pixel includes:
[0030] By aligning the target pixel with the center point of the second top view, the second top view is placed within the first top view to obtain the corresponding initial position;
[0031] The initial position is transformed based on the second transformation relationship corresponding to the first transformation relationship to obtain the target position.
[0032] Secondly, a location determining device is provided, the device comprising:
[0033] The acquisition module is used to acquire a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed. The first top view is marked with all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed.
[0034] The first determining module is used to determine the distance corresponding to each second pixel and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view;
[0035] The second determining module is used to determine, among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length as candidate pixels;
[0036] The third determining module is used to determine the target pixel among the candidate pixels, and to determine the target position in the virtual scene where the model to be placed can be placed based on the target pixel.
[0037] In one possible implementation, the third determining module is specifically used for:
[0038] For each candidate pixel, a virtual shooting position is determined according to a preset horizontal shooting angle and shooting distance. The candidate pixel and the pixel where the virtual shooting position is located are connected to obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel.
[0039] If the corresponding virtual shooting optical path passes through any of the first pixels, the candidate pixel is determined as a pixel to be confirmed, and the target pixel is determined among the pixels to be confirmed.
[0040] If the corresponding virtual shooting optical path does not pass through all the first pixels, the candidate pixel is determined as the target pixel.
[0041] In one possible implementation, the third determining module is further configured to:
[0042] Determine the first dimension of the model to be placed;
[0043] For each pixel to be confirmed, the shooting range corresponding to the pixel to be confirmed is determined, and the first pixel through which the virtual shooting light path passes is determined as the obstacle pixel corresponding to the pixel to be confirmed, and the second size of the placed model corresponding to the obstacle pixel is determined;
[0044] Based on the first size, the second size, and the shooting range, the shooting effect corresponding to the pixel to be confirmed is determined. The shooting effect is used to characterize the occlusion ratio of the model to be placed when the model to be placed is photographed.
[0045] If the occlusion ratio is less than a preset threshold, the pixel to be confirmed is determined as the target pixel.
[0046] In one possible implementation, the first determining module is specifically used for:
[0047] The first top view is binarized to obtain the corresponding grayscale image;
[0048] A signed distance field corresponding to the grayscale image is created using a fast traversal algorithm, wherein the signed distance field marks the distance between each second pixel and the first pixel that is closest to the second pixel among all the first pixels.
[0049] In one possible implementation, the apparatus further includes a fourth determining module, configured to:
[0050] Obtain the first transformation relationship from the virtual scene to the first top view;
[0051] For each placed model corresponding to the virtual scene, determine the position of the first bounding box corresponding to the placed model in the virtual scene;
[0052] Based on the first transformation relationship, the position of the first bounding box is transformed to obtain the position of the first bounding box in the first top view;
[0053] The position of the first bounding box in the first top view is determined as the position of the placed model.
[0054] In one possible implementation, the acquisition module is specifically used for;
[0055] Determine the second bounding box corresponding to the model to be placed;
[0056] The second bounding box is transformed based on the first transformation relationship to obtain the second top view.
[0057] In one possible implementation, the third determining module is further configured to:
[0058] By aligning the target pixel with the center point of the second top view, the second top view is placed within the first top view to obtain the corresponding initial position;
[0059] The initial position is transformed based on the second transformation relationship corresponding to the first transformation relationship to obtain the target position.
[0060] Thirdly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0061] Memory, used to store computer programs;
[0062] When a processor executes a program stored in memory, it implements any of the steps described in the first aspect.
[0063] Fourthly, a computer-readable storage medium is provided, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the methods described in the first aspect.
[0064] Fifthly, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to execute any of the aforementioned location determination methods.
[0065] Beneficial effects of the embodiments in this application:
[0066] This application provides a location determination method, apparatus, electronic device, and readable storage medium. The method involves first obtaining a first top view of a virtual scene and a second top view of the model to be placed. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed. Then, the distance corresponding to each second pixel and the radius of the second top view are determined. The distance is the distance between the nearest first pixel and the second pixel among all the first pixels, and the radius is half the length of the longest diagonal of the second top view. Next, among all the second pixels, those whose distance is greater than or equal to the radius are identified as candidate pixels. Finally, a target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be located is determined based on the target pixel. This achieves intelligent determination of the target position in the virtual scene where the model to be placed can be located based on the top view of the virtual scene and the top view of the model to be placed, thus saving manpower costs and improving the efficiency of location determination.
[0067] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description
[0068] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0069] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0070] Figure 1 A flowchart illustrating a location determination method provided in an embodiment of this application;
[0071] Figure 2 This is a schematic diagram of a first top view;
[0072] Figure 3 This is a schematic diagram of the first top view after marking.
[0073] Figure 4 This is a schematic diagram of the grayscale image corresponding to the first top view;
[0074] Figure 5 This is a schematic diagram illustrating the use of a signed distance field to mark the distance corresponding to the second pixel.
[0075] Figure 6 This is an example schematic diagram of placing a second top view within a first top view;
[0076] Figure 7 A flowchart illustrating another location determination method provided in this application embodiment;
[0077] Figure 8 A schematic diagram of connecting the virtual shooting optical path in the first top view;
[0078] Figure 9 This is a schematic diagram of the structure of a position determination device provided in an embodiment of this application;
[0079] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0080] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0081] The following will describe in detail a location determination method provided in the embodiments of this application, with reference to specific implementation methods. Figure 1 As shown, the specific steps are as follows:
[0082] S101, obtain the first top view corresponding to the virtual scene and the second top view corresponding to the model to be placed, wherein the first top view marks all first pixels corresponding to the positions of the placed models and all second pixels corresponding to the positions of the unplaced models.
[0083] In this embodiment of the invention, the Unity virtual camera can be used to simulate the parallel light shooting principle of an orthogonal camera to capture virtual scenes, obtaining results such as... Figure 2The first top view is shown. Based on the pixel dimensions of the first top view and the actual dimensions of the virtual scene, a first transformation relationship is calculated to transform the virtual scene into the first top view (i.e., the transformation relationship from the world coordinate system of the virtual scene to the pixel coordinate system of the first top view). Furthermore, based on this first transformation relationship, the positions of the placed models in the virtual scene corresponding to their positions in the first top view can be determined. Therefore, all first pixels corresponding to the positions of the placed models and all second pixels corresponding to the positions of the unplaced models are marked in the first top view.
[0084] As one possible implementation, the position of the placed model in the first top view can be determined by the following steps: obtaining a first transformation relationship from the virtual scene to the first top view; for each placed model corresponding to the virtual scene, determining the position of the first bounding box corresponding to the placed model in the virtual scene; transforming the position of the first bounding box based on the first transformation relationship to obtain the position of the first bounding box in the first top view; and determining the position of the first bounding box in the first top view as the position of the placed model.
[0085] In this implementation, the size and pose of the model already placed in the virtual scene are known. The first bounding box and its position in the virtual scene can be obtained from the size and pose of the model already placed. Then, according to the first transformation relationship between the virtual scene world coordinate system and the top view pixel coordinate system, the position is transformed to obtain the position of the first bounding box in the first top view, and it is determined as the position of the model already placed in the first top view.
[0086] Based on this, all pixels corresponding to this position can be recorded as the first pixel, and other pixels can be recorded as the second pixel, resulting in the following: Figure 3 The diagram shown indicates that the pixels within the dashed box are the first pixels, and the pixels outside the dashed box are the second pixels.
[0087] Additionally, the second top view corresponding to the model to be placed can be determined based on this coordinate transformation relationship. Specifically, the second top view corresponding to the model to be placed can be obtained through the following steps: determine the second bounding box corresponding to the model to be placed, transform the second bounding box based on the first transformation relationship, and obtain the second top view.
[0088] Given the dimensions of the model to be placed, the corresponding second bounding box can be obtained from these dimensions.
[0089] S102, determine the distance corresponding to each second pixel, and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view.
[0090] The distance mentioned above is the distance between the first pixel that is closest to the second pixel among all first pixels and the second pixel.
[0091] The aforementioned radius length is half the length of the longest diagonal in the second top view. Taking the second top view as a rectangular diagram as an example, its two diagonals are of the same length, and the radius length is half the length of either diagonal.
[0092] In one embodiment, the specific implementation of determining the distance corresponding to each second pixel may include: binarizing the first top view to obtain a corresponding grayscale image, and using the Fast Marching Method (FMM) to create a signed distance field (SDF) corresponding to the grayscale image, wherein the signed distance field marks the distance between each second pixel and the first pixel that is closest to the second pixel among all the first pixels.
[0093] In practical applications, during the binarization process of the first top view, the pixel values of all first pixels can be set to 0, and the pixel values of all second pixels can be set to 1, resulting in the following: Figure 4 The grayscale image shown.
[0094] Based on this, the process of creating the signed distance field corresponding to the grayscale image using the fast traversal algorithm is as follows: For each pixel with a value of 1 in the grayscale image (i.e., the second pixel), the following steps are performed iteratively: Draw a circle with the pixel as the center and n pixels as the radius to obtain a circular region. Determine whether there is a pixel with a value of 0 (i.e., the first pixel) in the circular region. Here, the value of n is the number of iterations, i.e., n is 1 in the first iteration, n is 2 in the second iteration, and so on, n is i in the i-th iteration. If there is no pixel with a value of 0, continue the loop. If there is a pixel with a value of 0 in the circular region, stop the loop. Determine the radius of the previous iteration (i-1th iteration) corresponding to the time when the loop stops (i-th iteration) as the distance corresponding to the pixel, that is, the distance between the pixel and the nearest pixel with a value of 0.
[0095] like Figure 5 As shown, the solid circle represents a pixel with a value of 1, and the radius of the corresponding dashed circle is 64. Therefore, the distance between the solid circle and the nearest pixel with a value of 0 is 64.
[0096] S103, among all the second pixels, the second pixel whose corresponding distance is greater than or equal to the radius length is determined as a candidate pixel.
[0097] In this embodiment of the invention, after determining the distance of each second pixel and the radius length corresponding to the second top view, the radius length and the distance of each second pixel can be compared. If the distance of the second pixel is greater than or equal to the radius length, it means that placing the model to be placed at the position corresponding to the second pixel will not result in clipping, overlapping, or collision with the models already placed in the virtual scene. If the distance of the second pixel is less than the radius length, it means that placing the model to be placed at the position corresponding to the second pixel may result in clipping, overlapping, or collision with the models already placed in the virtual scene.
[0098] Therefore, in this embodiment, second pixels with a distance less than the radius are excluded, and only second pixels with a distance greater than or equal to the radius are identified as candidate pixels. In this way, based on the positions determined by the candidate pixels, clipping, overlapping, or collisions will not occur when placing the model to be placed.
[0099] S104, determine the target pixel among the candidate pixels, and determine the target position in the virtual scene where the model to be placed can be placed based on the target pixel.
[0100] In practical applications, in order to achieve the desired rendering effect, when determining the target position in the virtual scene where the model to be placed can be located, it is also necessary to consider the shooting effect of the virtual camera on the model to be placed at the target position (such as whether it is occluded during shooting). In this way, the target pixel can be further determined from the candidate pixels based on the shooting parameters set by the user (such as shooting position and shooting angle), and the target position in the virtual scene where the model to be placed can be determined based on the target pixel.
[0101] In one embodiment, the specific implementation of determining the target position in the virtual scene where the model to be placed can be based on the target pixel may include: placing the second top view in the first top view with the target pixel coinciding with the center point of the second top view to obtain the corresponding initial position, and transforming the initial position based on the second transformation relationship corresponding to the first transformation relationship to obtain the target position.
[0102] The second transformation relationship is the coordinate transformation relationship from the pixel coordinate system back to the world coordinate system, which is the opposite of the first transformation relationship.
[0103] Figure 6The image shows an example of placing the second top view (the rectangle within the dashed circle in the image) on top of the first top view. It can be seen that the center point of the second top view coincides with the target pixel (the solid circle in the image). It is understandable that regardless of the angle at which the second top view is placed (e.g., rotating it 90 degrees clockwise), it will not coincide with any of the first pixels.
[0104] The specific method for determining the target pixel from the candidate pixels will be explained in detail in later embodiments, and will not be elaborated here.
[0105] In this embodiment, firstly, a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed are obtained. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed. Then, the distance corresponding to each second pixel and the radius length corresponding to the second top view are determined. The distance is the distance between the nearest first pixel and the second pixel among all the first pixels, and the radius length is half the length of the longest diagonal of the second top view. Next, among all the second pixels, those with a distance greater than or equal to the radius length are determined as candidate pixels. Finally, a target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be located is determined based on the target pixel. Thus, the target position in the virtual scene where the model to be placed can be intelligently determined based on the top view of the virtual scene and the top view of the model to be placed, saving manpower costs and improving the efficiency of position determination.
[0106] See Figure 7 This is a flowchart illustrating another embodiment of a position determination method provided by the present invention. Figure 7 The process shown above Figure 1 Based on the illustrated process, this section describes how to determine the target pixel from the candidate pixels. For example... Figure 7 As shown, the process may include the following steps:
[0107] S701, for each candidate pixel, determine the virtual shooting position corresponding to the candidate pixel according to the preset horizontal shooting angle and shooting distance, connect the candidate pixel and the pixel where the virtual shooting position is located, and obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel.
[0108] S702, when the corresponding virtual shooting light path passes through any of the first pixels, the candidate pixel is determined as a pixel to be confirmed, and the target pixel is determined among the pixels to be confirmed.
[0109] S703, if the corresponding virtual shooting optical path does not pass through all the first pixels, determine the candidate pixel as the target pixel.
[0110] The following provides a unified explanation of S701-S703:
[0111] In practical applications, to ensure the rendering effect matches the user's preset shooting parameters, the horizontal shooting angle and shooting distance of the virtual camera are typically set first. The horizontal shooting angle, when expressed in Euler angles, refers to the yaw angle; it can also be adjusted directly using the camera's lookat vector. The shooting distance refers to the relative distance between the virtual camera and the desired shooting location.
[0112] In this embodiment of the invention, for each candidate pixel, the virtual shooting position corresponding to the candidate pixel is determined according to a preset horizontal shooting angle and shooting distance, and the candidate pixel and the pixel where the virtual shooting position is located are connected to obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel.
[0113] In the case where the corresponding virtual shooting light path does not pass through all first pixels (such as...) Figure 8 The two virtual shooting positions marked with a checkmark do not pass through the black area where the first pixel is located. This means that when shooting the model placed on the candidate pixel through the virtual shooting light path, it will not be blocked by the already placed model. Therefore, the candidate pixel can be directly identified as the target pixel.
[0114] When the corresponding virtual shooting light path passes through any first pixel (e.g.) Figure 8 The two virtual shooting positions marked with an X pass through the black area where the first pixel is located. This means that when shooting the model placed on the candidate pixel through the virtual shooting light path, it will be occluded by the already placed model. It is necessary to further determine the occlusion situation based on the height of the already placed model. Therefore, the candidate pixel is determined to be a pixel to be confirmed, and it is further determined whether the pixel to be confirmed can be used as the target pixel.
[0115] As one possible implementation, determining the target pixel among the pixels to be confirmed may include:
[0116] A first size of the model to be placed is determined; for each pixel to be confirmed, the shooting range corresponding to the pixel to be confirmed is determined, and the first pixel through which the corresponding virtual shooting light path passes is determined as the obstacle pixel corresponding to the pixel to be confirmed, and a second size of the placed model corresponding to the obstacle pixel is determined; based on the first size, the second size and the shooting range, the shooting effect corresponding to the pixel to be confirmed is determined, and the shooting effect is used to characterize the occlusion ratio of the model to be placed when shooting the model to be placed; if the occlusion ratio is less than a preset threshold, the pixel to be confirmed is determined as the target pixel.
[0117] In practical applications, to ensure the rendering effect matches the user's preset shooting parameters, the stereo shooting angle and field of view parameters of the virtual camera are usually set. The stereo shooting angle includes pitch and roll angles; when expressed in Euler angles, these refer to pitch and roll. The stereo shooting angle can also be adjusted using the camera's lookat and up vectors together. The field of view parameters include the horizontal field of view (HFOV) and the vertical field of view (VFOV).
[0118] Specifically, determining the shooting range corresponding to the pixel to be confirmed may include: using the pixel to be confirmed as the initial placement position of the virtual camera; obtaining a vector from the initial placement position to the target placement position of the virtual camera based on the aforementioned horizontal shooting angle and shooting distance; translating the virtual camera to the target placement position according to the vector based on the initial placement position; then reversing the vector and adjusting it according to preset stereo shooting angle and field of view parameters to obtain the shooting range. It can be understood that this shooting range is the field of view range under unobstructed conditions.
[0119] For any pixel to be confirmed where the virtual shooting light path passes through any first pixel, its shooting range will be blocked by the placed model through which the virtual shooting light path passes. Therefore, the shooting range blocked by the placed model can be determined based on the shooting range and the second size of the placed model. Then, based on the shooting range and the first size of the model to be placed, the part of the model to be placed that falls within the shooting range (i.e., the unblocked part) can be determined. Thus, the shooting effect (i.e., the occlusion ratio) corresponding to the pixel to be confirmed can be determined. Finally, if the occlusion ratio is less than a preset threshold, the shooting effect is considered to meet the user's expectations, and the pixel to be confirmed is determined as the target pixel.
[0120] In this embodiment of the invention, target pixels whose shooting effect meets the user's expectations can be further determined from candidate pixels based on pre-set shooting parameters, namely, horizontal shooting angle, shooting distance, stereo shooting angle, and field of view. Thus, when the model to be placed is subsequently placed at the target position determined based on the target pixels, it can be ensured that the shooting effect of the virtual camera meets the user's expectations, thereby achieving a rendering effect that satisfies the user.
[0121] Based on the same technical concept, embodiments of this application also provide a location determining device, such as... Figure 9 As shown, the device includes:
[0122] The acquisition module 901 is used to acquire a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed, wherein the first top view marks all first pixels corresponding to the position of the placed model and all second pixels corresponding to the position of the unplaced model.
[0123] The first determining module 902 is used to determine the distance corresponding to each second pixel and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view;
[0124] The second determining module 903 is used to determine, among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length as candidate pixels;
[0125] The third determining module 904 is used to determine the target pixel among the candidate pixels and determine the target position in the virtual scene where the model to be placed can be placed based on the target pixel.
[0126] In one possible implementation, the third determining module is specifically used for:
[0127] For each candidate pixel, a virtual shooting position is determined according to a preset horizontal shooting angle and shooting distance. The candidate pixel and the pixel where the virtual shooting position is located are connected to obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel.
[0128] If the corresponding virtual shooting optical path passes through any of the first pixels, the candidate pixel is determined as a pixel to be confirmed, and the target pixel is determined among the pixels to be confirmed.
[0129] If the corresponding virtual shooting optical path does not pass through all the first pixels, the candidate pixel is determined as the target pixel.
[0130] In one possible implementation, the third determining module is further configured to:
[0131] Determine the first dimension of the model to be placed;
[0132] For each pixel to be confirmed, the shooting range corresponding to the pixel to be confirmed is determined, and the first pixel through which the virtual shooting light path passes is determined as the obstacle pixel corresponding to the pixel to be confirmed, and the second size of the placed model corresponding to the obstacle pixel is determined;
[0133] Based on the first size, the second size, and the shooting range, the shooting effect corresponding to the pixel to be confirmed is determined. The shooting effect is used to characterize the occlusion ratio of the model to be placed when the model to be placed is photographed.
[0134] If the occlusion ratio is less than a preset threshold, the pixel to be confirmed is determined as the target pixel.
[0135] In one possible implementation, the first determining module is specifically used for:
[0136] The first top view is binarized to obtain the corresponding grayscale image;
[0137] A signed distance field corresponding to the grayscale image is created using a fast traversal algorithm, wherein the signed distance field marks the distance between each second pixel and the first pixel that is closest to the second pixel among all the first pixels.
[0138] In one possible implementation, the apparatus further includes a fourth determining module, configured to:
[0139] Obtain the first transformation relationship from the virtual scene to the first top view;
[0140] For each placed model corresponding to the virtual scene, determine the position of the first bounding box corresponding to the placed model in the virtual scene;
[0141] Based on the first transformation relationship, the position of the first bounding box is transformed to obtain the position of the first bounding box in the first top view;
[0142] The position of the first bounding box in the first top view is determined as the position of the placed model.
[0143] In one possible implementation, the acquisition module is specifically used for;
[0144] Determine the second bounding box corresponding to the model to be placed;
[0145] The second bounding box is transformed based on the first transformation relationship to obtain the second top view.
[0146] In one possible implementation, the third determining module is further configured to:
[0147] By aligning the target pixel with the center point of the second top view, the second top view is placed within the first top view to obtain the corresponding initial position;
[0148] The initial position is transformed based on the second transformation relationship corresponding to the first transformation relationship to obtain the target position.
[0149] In this embodiment, firstly, a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed are obtained. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed. Then, the distance corresponding to each second pixel and the radius length corresponding to the second top view are determined. The distance is the distance between the nearest first pixel and the second pixel among all the first pixels, and the radius length is half the length of the longest diagonal of the second top view. Next, among all the second pixels, those with a distance greater than or equal to the radius length are determined as candidate pixels. Finally, a target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be located is determined based on the target pixel. Thus, the target position in the virtual scene where the model to be placed can be intelligently determined based on the top view of the virtual scene and the top view of the model to be placed, saving manpower costs and improving the efficiency of position determination.
[0150] Based on the same technical concept, embodiments of this application also provide an electronic device, such as... Figure 10 As shown, it includes a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0151] Memory 113 is used to store computer programs;
[0152] When processor 111 executes a program stored in memory 113, it performs the following steps:
[0153] Obtain a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed.
[0154] Determine the distance corresponding to each second pixel, and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel that is closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view;
[0155] Among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length are determined as candidate pixels;
[0156] A target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be determined based on the target pixel.
[0157] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0158] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0159] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0160] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0161] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the above-described location determination methods.
[0162] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the location determination methods described above.
[0163] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0164] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0165] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for determining a location, characterized in that, The method includes: Obtain a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed. The first top view marks all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed. Determine the distance corresponding to each second pixel, and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel that is closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view; Among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length are determined as candidate pixels; A target pixel is determined from the candidate pixels, and a target position in the virtual scene where the model to be placed can be determined based on the target pixel; The location of the model already placed in the first top view is determined through the following steps: Obtain the first transformation relationship from the virtual scene to the first top view; For each placed model corresponding to the virtual scene, determine the position of the first bounding box corresponding to the placed model in the virtual scene; Based on the first transformation relationship, the position of the first bounding box is transformed to obtain the position of the first bounding box in the first top view; The position of the first bounding box in the first top view is determined as the position of the placed model.
2. The method according to claim 1, characterized in that, Determining the target pixel among the candidate pixels includes: For each candidate pixel, a virtual shooting position is determined according to a preset horizontal shooting angle and shooting distance. The candidate pixel and the pixel where the virtual shooting position is located are connected to obtain the virtual shooting optical path in the horizontal direction corresponding to the candidate pixel. If the corresponding virtual shooting optical path passes through any of the first pixels, the candidate pixel is determined as a pixel to be confirmed, and the target pixel is determined among the pixels to be confirmed. If the corresponding virtual shooting optical path does not pass through all the first pixels, the candidate pixel is determined as the target pixel.
3. The method according to claim 2, characterized in that, Determining the target pixel among the pixels to be confirmed includes: Determine the first dimension of the model to be placed; For each pixel to be confirmed, the shooting range corresponding to the pixel to be confirmed is determined, and the first pixel through which the virtual shooting light path passes is determined as the obstacle pixel corresponding to the pixel to be confirmed, and the second size of the placed model corresponding to the obstacle pixel is determined; Based on the first size, the second size, the preset stereo shooting angle and field of view, the shooting effect corresponding to the pixel to be confirmed is determined. The shooting effect is used to characterize the occlusion ratio of the model to be placed when shooting the model to be placed. If the occlusion ratio is less than a preset threshold, the pixel to be confirmed is determined as the target pixel.
4. The method according to claim 1, characterized in that, Determining the distance corresponding to each second pixel includes: The first top view is binarized to obtain the corresponding grayscale image; A signed distance field corresponding to the grayscale image is created using a fast traversal algorithm, wherein the signed distance field marks the distance between each second pixel and the first pixel that is closest to the second pixel among all the first pixels.
5. The method according to claim 1, characterized in that, Obtain the second top view corresponding to the model to be placed by following these steps; Determine the second bounding box corresponding to the model to be placed; The second bounding box is transformed based on the first transformation relationship to obtain the second top view.
6. The method according to claim 1, characterized in that, Determining the target location in the virtual scene where the model to be placed can be placed based on the target pixel includes: By aligning the target pixel with the center point of the second top view, the second top view is placed within the first top view to obtain the corresponding initial position; The initial position is transformed based on the second transformation relationship corresponding to the first transformation relationship to obtain the target position.
7. A position determining device, characterized in that, The device includes: The acquisition module is used to acquire a first top view corresponding to the virtual scene and a second top view corresponding to the model to be placed. The first top view is marked with all first pixels corresponding to the positions where the model has been placed and all second pixels corresponding to the positions where the model has not been placed. The first determining module is used to determine the distance corresponding to each second pixel and the radius length corresponding to the second top view, wherein the distance is the distance between the first pixel closest to the second pixel among all the first pixels and the second pixel, and the radius length is half the length of the longest diagonal of the second top view; The second determining module is used to determine, among all the second pixels, the second pixels whose corresponding distance is greater than or equal to the radius length as candidate pixels; The third determining module is used to determine the target pixel among the candidate pixels, and to determine the target position in the virtual scene where the model to be placed can be placed based on the target pixel; The device further includes a fourth determining module, used for: Obtain the first transformation relationship from the virtual scene to the first top view; For each placed model corresponding to the virtual scene, determine the position of the first bounding box corresponding to the placed model in the virtual scene; Based on the first transformation relationship, the position of the first bounding box is transformed to obtain the position of the first bounding box in the first top view; The position of the first bounding box in the first top view is determined as the position of the placed model.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-6.