Method, device and equipment for mapping three-dimensional space to two-dimensional plane and storage medium
Patent Information
- Application Number
- CN202211242283.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2042-10-11
AI Technical Summary
[0004]然而,手动摆放的方式误差较大,无法将三维场景中的物品准确映射到二维平面上
[0075] This application provides a method, apparatus, device, and storage medium for mapping from three-dimensional space to a two-dimensional plane. The method includes: mapping the three-dimensional coordinates of a target object in a three-dimensional scene to screen space by converting a scale and coordinate deviation values to obtain the two-dimensional screen coordinates of the target object; and then displaying the target object on a planar image based on these two-dimensional screen coordinates. Compared to manually placing objects, this method improves mapping accuracy, is convenient to operate, and automatically corrects for errors based on the conversion scale and coordinate deviation values without requiring attention to the size of the three-dimensional scene and the plane, making it highly applicable.
Smart Images

Figure CN115546012B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, device, and storage medium for mapping from three-dimensional space to a two-dimensional plane. Background Technology
[0002] With the development of the times, there are more and more 3D products, and there is a greater need to depict grand scenes. For example, 3D scenes of transportation stations can be combined to display vehicles within the transportation station.
[0003] Since a good presentation effect cannot be achieved by a three-dimensional scene alone, it is necessary to combine a three-dimensional scene with a corresponding two-dimensional plane for comprehensive display. Currently, it is common to combine a three-dimensional scene with manually placing items from the three-dimensional scene on a two-dimensional plane to obtain the two-dimensional plane corresponding to the three-dimensional scene.
[0004] However, the manual placement method has a large margin of error and cannot accurately map objects in a 3D scene onto a 2D plane. Summary of the Invention
[0005] In view of this, embodiments of this application provide a method, apparatus, device, and storage medium for mapping from three-dimensional space to a two-dimensional plane, so as to improve the accuracy of mapping from three-dimensional space to a two-dimensional plane.
[0006] In a first aspect, embodiments of this application provide a method for mapping from three-dimensional space to a two-dimensional plane, including:
[0007] Obtain the 3D coordinates of the target object in the 3D scene;
[0008] Based on a preset conversion scale and coordinate deviation value, the three-dimensional coordinates of the target item are mapped to a preset screen space to obtain the two-dimensional screen coordinates corresponding to the target item. The conversion scale is the conversion scale between the three-dimensional scene and the preset screen space, and the coordinate deviation value is the coordinate deviation between the coordinate reference point of the three-dimensional scene and the coordinate reference point of the preset screen space.
[0009] The target item is displayed on a plan view based on its corresponding two-dimensional screen coordinates.
[0010] In an optional implementation, the step of mapping the three-dimensional coordinates of the target item to a preset screen space according to a preset conversion scale and coordinate deviation value to obtain the two-dimensional screen coordinates corresponding to the target item includes:
[0011] The three-dimensional coordinates of the target item are projected onto the two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target item on the two-dimensional plane;
[0012] Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled proportionally to obtain the scaled coordinates of the target item.
[0013] Based on the coordinate deviation value, the scaled coordinates corresponding to the target item are adjusted to obtain the two-dimensional screen coordinates corresponding to the target item.
[0014] In an optional implementation, the conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0015] The step of scaling the coordinates of the target item on the two-dimensional plane according to the conversion scale to obtain the scaled coordinates of the target item includes:
[0016] Based on the horizontal conversion scale, the horizontal coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled horizontal coordinate of the target item.
[0017] Based on the vertical conversion scale, the vertical coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled vertical coordinate of the target item.
[0018] In an optional implementation, the coordinate deviation value includes: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value of the vertical coordinate axis;
[0019] The step of adjusting the scaled coordinates of the target item based on the coordinate deviation value to obtain the two-dimensional screen coordinates of the target item includes:
[0020] Based on the horizontal coordinate deviation value, the scaled horizontal coordinate corresponding to the target item is adjusted to obtain the two-dimensional screen horizontal coordinate corresponding to the target item;
[0021] Based on the vertical coordinate deviation value, the scaled vertical coordinate of the target item is adjusted to obtain the two-dimensional screen vertical coordinate of the target item.
[0022] In an optional implementation, before mapping the three-dimensional coordinates of the target item to a preset screen space according to a preset conversion scale and coordinate deviation value to obtain the two-dimensional screen coordinates corresponding to the target item, the method further includes:
[0023] Obtain the 3D coordinates of at least two preset marker points in the 3D scene and the 2D screen coordinates in the preset screen space;
[0024] The conversion scale is calculated based on the three-dimensional coordinates of the at least two preset marker points and the two-dimensional screen coordinates of the at least two preset marker points;
[0025] The coordinate deviation value is calculated based on the three-dimensional coordinates of the at least two preset marker points, the two-dimensional screen coordinates of the at least two preset marker points, and the conversion scale.
[0026] In an optional implementation, the at least two preset marker points include two marker points, and the conversion scale includes a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0027] The step of calculating the conversion scale based on the three-dimensional coordinates of the at least two preset marker points and the two-dimensional screen coordinates of the at least two preset marker points includes:
[0028] Calculate the first coordinate difference between the x-coordinates of the two marker points in their three-dimensional coordinates;
[0029] Calculate the second coordinate difference between the two marker points on the two-dimensional screen horizontal coordinates;
[0030] The ratio of the first coordinate difference to the second coordinate difference is used as the horizontal transformation scale.
[0031] Calculate the difference in the third coordinate between the ordinates of the two marker points in their three-dimensional coordinates;
[0032] Calculate the fourth coordinate difference between the two two-dimensional screen ordinates of the marked points;
[0033] The ratio of the third coordinate difference to the fourth coordinate difference is used as the vertical transformation scale.
[0034] In an optional implementation, the coordinate deviation value includes: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value;
[0035] The step of calculating the coordinate deviation value based on the three-dimensional coordinates of the at least two preset marker points, the two-dimensional screen coordinates of the at least two preset marker points, and the conversion scale includes:
[0036] Calculate the ratio of the x-coordinate of any one of the two preset marker points to the horizontal conversion scale in the three-dimensional coordinates;
[0037] The horizontal coordinate deviation value is calculated based on the ratio of the horizontal coordinate of any given marker point in the three-dimensional coordinates to the horizontal conversion scale, and the difference between the horizontal coordinate of any given marker point in the two-dimensional screen.
[0038] Calculate the ratio of the ordinate of any given marker point in its three-dimensional coordinates to the vertical transformation scale;
[0039] The vertical coordinate deviation value is calculated based on the ratio of the vertical coordinate of any given marker point in its three-dimensional coordinates to the vertical conversion scale, and the difference between the vertical coordinate of any given marker point in its two-dimensional screen coordinates.
[0040] Secondly, embodiments of this application also provide a mapping device from three-dimensional space to a two-dimensional plane, comprising:
[0041] The acquisition module is used to respond to the selection operation of a target object in a three-dimensional scene and acquire the three-dimensional coordinates of each vertex on the target object;
[0042] The mapping module is used to map the three-dimensional coordinates of each vertex to a preset screen space according to a preset conversion scale and coordinate deviation value, so as to obtain the two-dimensional screen coordinates corresponding to each vertex on the target item. The conversion scale is the conversion scale between the three-dimensional scene and the preset screen space, and the coordinate deviation value is the coordinate deviation value between the coordinate reference point of the three-dimensional scene and the coordinate reference point of the preset screen space.
[0043] The display module is used to display the target item on a planar map based on the two-dimensional screen coordinates corresponding to each vertex.
[0044] In an optional implementation, the mapping module is specifically used for:
[0045] The three-dimensional coordinates of the target item are projected onto the two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target item on the two-dimensional plane;
[0046] Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled proportionally to obtain the scaled coordinates of the target item.
[0047] Based on the coordinate deviation value, the scaled coordinates corresponding to the target item are adjusted to obtain the two-dimensional screen coordinates corresponding to the target item.
[0048] In an optional implementation, the conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0049] The mapping module is specifically used for:
[0050] Based on the horizontal conversion scale, the horizontal coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled horizontal coordinate of the target item.
[0051] Based on the vertical conversion scale, the vertical coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled vertical coordinate of the target item.
[0052] In an optional implementation, the coordinate deviation value includes: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value of the vertical coordinate axis;
[0053] The mapping module is specifically used for:
[0054] Based on the horizontal coordinate deviation value, the scaled horizontal coordinate corresponding to the target item is adjusted to obtain the two-dimensional screen horizontal coordinate corresponding to the target item;
[0055] Based on the vertical coordinate deviation value, the scaled vertical coordinate of the target item is adjusted to obtain the two-dimensional screen vertical coordinate of the target item.
[0056] In an optional implementation, the acquisition module is further configured to:
[0057] Obtain the 3D coordinates of at least two preset marker points in the 3D scene and the 2D screen coordinates in the preset screen space;
[0058] The calculation module is used to calculate the conversion scale based on the three-dimensional coordinates of the at least two preset marker points and the two-dimensional screen coordinates of the at least two preset marker points; and to calculate the coordinate deviation value based on the three-dimensional coordinates of the at least two preset marker points, the two-dimensional screen coordinates of the at least two preset marker points, and the conversion scale.
[0059] In an optional implementation, the at least two preset marker points include two marker points, and the conversion scale includes a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0060] The computing module is specifically used for:
[0061] Calculate the first coordinate difference between the x-coordinates of the two marker points in their three-dimensional coordinates;
[0062] Calculate the second coordinate difference between the two marker points on the two-dimensional screen horizontal coordinates;
[0063] The ratio of the first coordinate difference to the second coordinate difference is used as the horizontal transformation scale.
[0064] Calculate the difference in the third coordinate between the ordinates of the two marker points in their three-dimensional coordinates;
[0065] Calculate the fourth coordinate difference between the two two-dimensional screen ordinates of the marked points;
[0066] The ratio of the third coordinate difference to the fourth coordinate difference is used as the vertical transformation scale.
[0067] In an optional implementation, the coordinate deviation value includes: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value;
[0068] The computing module is specifically used for:
[0069] Calculate the ratio of the x-coordinate of any one of the two preset marker points to the horizontal conversion scale in the three-dimensional coordinates;
[0070] The horizontal coordinate deviation value is calculated based on the ratio of the horizontal coordinate of any given marker point in the three-dimensional coordinates to the horizontal conversion scale, and the difference between the horizontal coordinate of any given marker point in the two-dimensional screen.
[0071] Calculate the ratio of the ordinate of any given marker point in its three-dimensional coordinates to the vertical transformation scale;
[0072] The vertical coordinate deviation value is calculated based on the ratio of the vertical coordinate of any given marker point in its three-dimensional coordinates to the vertical conversion scale, and the difference between the vertical coordinate of any given marker point in its two-dimensional screen coordinates.
[0073] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the mapping method from three-dimensional space to a two-dimensional plane as described in any of the first aspects.
[0074] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the mapping method from three-dimensional space to a two-dimensional plane as described in any of the first aspects.
[0075] This application provides a method, apparatus, device, and storage medium for mapping from three-dimensional space to a two-dimensional plane. The method includes: mapping the three-dimensional coordinates of a target object in a three-dimensional scene to screen space by converting a scale and coordinate deviation values to obtain the two-dimensional screen coordinates of the target object; and then displaying the target object on a planar image based on these two-dimensional screen coordinates. Compared to manually placing objects, this method improves mapping accuracy, is convenient to operate, and automatically corrects for errors based on the conversion scale and coordinate deviation values without requiring attention to the size of the three-dimensional scene and the plane, making it highly applicable.
[0076] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0077] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0078] Figure 1 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 1 ;
[0079] Figure 2 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 2 ;
[0080] Figure 3 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 3 ;
[0081] Figure 4 A flowchart illustrating a method for mapping from three-dimensional space to a two-dimensional plane, as provided in this application embodiment. Figure 4 ;
[0082] Figure 5 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 5 ;
[0083] Figure 6 A schematic diagram of the structure of the mapping device from three-dimensional space to a two-dimensional plane provided in the embodiments of this application;
[0084] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0085] 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, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0086] Currently, items in a 3D scene are manually placed onto the screen space to obtain their 2D screen coordinates, which are then displayed on a plane. However, manual placement cannot accurately map items onto the plane. Therefore, this application provides a method for mapping from 3D space to a 2D plane. By converting the scale and coordinate deviation, the 3D coordinates of a target item in the 3D scene are mapped to the screen space, obtaining the target item's 2D screen coordinates. Based on these coordinates, the target item is then displayed on a 2D plane. Compared to manual placement, this method improves mapping accuracy, is convenient to operate, and automatically corrects for size based on the conversion scale and coordinate deviation without requiring attention to the size of the 3D scene and the plane, making it highly applicable.
[0087] The mapping method from three-dimensional space to two-dimensional plane provided in this application will be described below with reference to several specific embodiments.
[0088] Figure 1 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 1 In this embodiment, the executing entity can be an electronic device, such as a terminal device or a server.
[0089] like Figure 1 As shown, the method may include:
[0090] S101. Obtain the 3D coordinates of the target object in the 3D scene.
[0091] The 3D scene can be a 3D station scene, which includes multiple items, such as vehicles. The target item can be a vehicle in the 3D station scene that needs to be mapped onto a plane.
[0092] To map a target object in a 3D scene to a 2D plane, the 3D coordinates of the target object in the 3D scene can be obtained. The target object can be equipped with a position sensor to collect the 3D coordinates of the target object and transmit the 3D coordinates to an electronic device. Accordingly, the electronic device can obtain the 3D coordinates of the target object in the 3D scene.
[0093] The three-dimensional coordinates of the target item can include the three-dimensional coordinates of each point on the target item.
[0094] S102. Based on the preset conversion scale and coordinate deviation value, map the three-dimensional coordinates of the target item to the preset screen space to obtain the two-dimensional screen coordinates corresponding to the target item.
[0095] The conversion scale is the conversion scale between the 3D scene and the preset screen space. The conversion scale between the 3D scene and the preset screen space is used to indicate the scaling ratio between the 3D scene and the preset screen space.
[0096] The coordinate deviation value is the coordinate deviation between the coordinate reference point of the 3D scene and the coordinate reference point of the preset screen space.
[0097] The coordinate reference point of the 3D scene can be the origin of the 3D scene coordinates. The preset screen space is the 2D screen space where the display screen is located. The coordinate reference point of the preset screen space can be the origin of the 2D screen space coordinates. Since the coordinate reference point of the 3D scene and the coordinate reference point of the preset screen space are different, when mapping the target object in the 3D scene to the 2D plane, it is necessary to consider the coordinate deviation value between the coordinate reference point of the 3D scene and the coordinate reference point of the preset screen space. This coordinate deviation value can be the coordinate difference between the coordinate reference point of the 3D scene and the coordinate reference point of the preset screen space.
[0098] In this step, the conversion scale and coordinate deviation are taken into account to map the three-dimensional coordinates of the target item to the preset screen space, thereby obtaining the two-dimensional screen coordinates of the target item. Since the preset screen space is a two-dimensional screen space, the depth coordinate (i.e., the Z-axis coordinate) in the three-dimensional coordinates of the target item can be removed when mapping the three-dimensional coordinates of the target item to the preset screen space. Then, based on the conversion scale and coordinate deviation, the horizontal coordinate (i.e., the X-axis coordinate) and vertical coordinate (i.e., the Y-axis coordinate) of the target item are scaled and deviated to obtain the two-dimensional screen coordinates of the target item.
[0099] S103. Display the target item on the plan view according to the two-dimensional screen coordinates corresponding to the target item.
[0100] After determining the two-dimensional screen coordinates of the target item within the preset screen space, the target item can be displayed on the plan view corresponding to the preset screen space based on its two-dimensional screen coordinates.
[0101] In some embodiments, the two-dimensional screen coordinates of each point on the target item can be determined, and then the target item can be displayed on a plan view based on the two-dimensional screen coordinates of each point on the target item.
[0102] It should be noted that since the 3D coordinates of the target item may be very large, and the coordinate reference point of the 3D scene is different from the coordinate reference point of the preset screen space, if the coordinate deviation is not considered and the corresponding 2D screen coordinates of the target item are obtained directly according to the conversion scale, the target item may be located outside the planar view, and therefore the target item cannot be displayed on the planar view.
[0103] In the mapping method from three-dimensional space to a two-dimensional plane in this embodiment, the three-dimensional coordinates of a target object in a three-dimensional scene are mapped to screen space by converting the scale and coordinate deviation value, thus obtaining the two-dimensional screen coordinates of the target object. Then, based on these two-dimensional screen coordinates, the target object is displayed on a planar image. Compared to manually placing objects, this method improves mapping accuracy, is convenient to operate, and automatically corrects for errors based on the conversion scale and coordinate deviation value without requiring attention to the size of the three-dimensional scene and the plane, making it highly applicable.
[0104] The following is combined with Figure 2 The embodiment describes one method for implementing the two-dimensional screen coordinates corresponding to the target item.
[0105] Figure 2 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 2 ,like Figure 2 As shown, based on a preset transformation scale and coordinate deviation value, the three-dimensional coordinates of the target item are mapped to a preset screen space to obtain the corresponding two-dimensional screen coordinates of the target item, which may include:
[0106] S201. Project the three-dimensional coordinates of the target item onto the two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target item on the two-dimensional plane.
[0107] The three-dimensional coordinates of the target item are projected onto a two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target item in the two-dimensional plane. This means that the depth coordinate (i.e., the Z-axis coordinate) in the three-dimensional coordinates of the target item is removed. The coordinates of the target item in the two-dimensional plane include the horizontal coordinate (i.e., the X-axis coordinate) and the vertical coordinate (i.e., the Y-axis coordinate).
[0108] S202. Based on the conversion scale, scale the coordinates of the target item on the two-dimensional plane to obtain the scaled coordinates of the target item.
[0109] Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled to obtain the scaled coordinates of the target item. One method is to divide the coordinates of the target item on the two-dimensional plane by the conversion scale to obtain the scaled coordinates of the target item.
[0110] S203. Based on the coordinate deviation value, adjust the scaled coordinates of the target item to obtain the two-dimensional screen coordinates of the target item.
[0111] The scaled coordinates of the target item are adjusted based on the coordinate deviation value to offset the scaled coordinates of the target item, thus obtaining the two-dimensional screen coordinates of the target item. Alternatively, the scaled coordinates of the target item can be subtracted from the coordinate deviation value to obtain the two-dimensional screen coordinates of the target item.
[0112] In some embodiments, the conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0113] The following is combined with Figure 3 The example illustrates one method for implementing the scaled coordinates of a target object.
[0114] Figure 3 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 3 ,like Figure 3 As shown, based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled to obtain the scaled coordinates of the target item, including:
[0115] S301. Based on the horizontal conversion scale, scale the horizontal coordinate of the target item on the two-dimensional plane to obtain the scaled horizontal coordinate of the target item.
[0116] S302. Based on the vertical conversion scale, scale the vertical coordinate of the target item on the two-dimensional plane to obtain the scaled vertical coordinate of the target item.
[0117] The coordinates of the target item on the two-dimensional plane include: the x-coordinate of the target item on the horizontal coordinate axis (i.e., the X-axis) and the y-coordinate on the vertical coordinate axis (i.e., the Y-axis) of the two-dimensional plane. The scaled coordinates of the target item include: the scaled x-coordinate and the scaled y-coordinate of the target item.
[0118] Based on the horizontal transformation scale, the horizontal coordinate of the target object on the two-dimensional plane can be scaled to obtain the scaled horizontal coordinate of the target object. This can be achieved by dividing the horizontal coordinate X of the target object on the two-dimensional plane by the horizontal transformation scale C. X Get the scaled x-coordinate of the target item.
[0119] Similarly, based on the vertical transformation scale, the vertical coordinate of the target item on the two-dimensional plane can be scaled to obtain the scaled vertical coordinate of the target item. This can be achieved by dividing the horizontal coordinate Y of the target item on the two-dimensional plane by the horizontal transformation scale C. Y This yields the scaled ordinate of the target item, i.e.
[0120] In some embodiments, the coordinate deviation values include: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value of the vertical coordinate axis.
[0121] The following is combined with Figure 4 The embodiment describes one method for implementing the two-dimensional screen coordinates corresponding to the target item.
[0122] Figure 4 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 4 ,like Figure 4 As shown, based on the coordinate deviation value, the scaled coordinates corresponding to the target item are adjusted to obtain the two-dimensional screen coordinates corresponding to the target item, including:
[0123] S401. Based on the horizontal coordinate deviation value, adjust the scaled horizontal coordinate of the target item to obtain the two-dimensional screen horizontal coordinate of the target item.
[0124] S402. Based on the vertical coordinate deviation value, adjust the scaled vertical coordinate of the target item to obtain the two-dimensional screen vertical coordinate of the target item.
[0125] The two-dimensional screen coordinates corresponding to the target item include: the two-dimensional screen horizontal coordinate and the two-dimensional screen vertical coordinate of the target item. The two-dimensional screen horizontal coordinate of the target item is the horizontal coordinate of the target item in the two-dimensional plane, and the two-dimensional screen vertical coordinate of the target item is the vertical coordinate of the target item in the two-dimensional plane.
[0126] The horizontal coordinate deviation value is the coordinate deviation between the horizontal reference in the 3D scene and the horizontal reference in the preset screen space; the vertical coordinate deviation value is the coordinate deviation between the vertical reference in the 3D scene and the vertical reference in the preset screen space. The horizontal reference is the x-coordinate of the origin of the coordinate system, and the vertical reference is the y-coordinate of the origin of the coordinate system.
[0127] Based on the horizontal coordinate deviation value, the scaled horizontal coordinate of the target item can be adjusted to obtain the two-dimensional screen horizontal coordinate of the target item. The scaled horizontal coordinate of the target item can be used as an example. Subtract the horizontal coordinate deviation value O X The horizontal coordinate of the target item on the screen can be obtained as follows:
[0128] Similarly, based on the vertical coordinate deviation value, the scaled vertical coordinate of the target item can be adjusted to obtain the two-dimensional screen vertical coordinate of the target item. The scaled vertical coordinate of the target item can be used as an example. Subtract the horizontal coordinate deviation value O Y The horizontal coordinate of the target item on the screen can be obtained as follows:
[0129] The following is combined with Figure 5 This paper describes one method for converting scale and coordinate deviation values.
[0130] Figure 5 A flowchart illustrating the mapping method from three-dimensional space to a two-dimensional plane provided in the embodiments of this application. Figure 5 ,like Figure 5 As shown, before mapping the three-dimensional coordinates of the target item to a preset screen space according to a preset conversion scale and coordinate deviation value to obtain the corresponding two-dimensional screen coordinates of the target item, the method may further include:
[0131] S501. Obtain the 3D coordinates of at least two preset marker points in the 3D scene and the 2D screen coordinates in the preset screen space.
[0132] Among them, at least two preset marker points can be key points with preset features, such as the location of a sign. The three-dimensional coordinates of at least two preset marker points in the three-dimensional scene are obtained, and the two-dimensional screen coordinates of at least two preset marker points in the preset screen space are determined, that is, the two-dimensional coordinates of at least two preset marker points on the two-dimensional plane corresponding to the preset screen space.
[0133] S502. Calculate the conversion scale based on the three-dimensional coordinates of at least two preset marker points and the two-dimensional screen coordinates of at least two preset marker points.
[0134] Based on the 3D coordinates and 2D screen coordinates of at least two preset marker points, a conversion scale can be calculated. The conversion scale is the ratio of the length of a line segment in the 3D scene to the actual length of the corresponding line segment in the preset screen space. In other words, the distance between at least two preset marker points in the 3D scene can be calculated based on their 3D coordinates, and the distance between them in the preset screen space can be calculated based on their 2D screen coordinates. Then, based on the distances between the at least two preset marker points in the 3D scene and in the preset screen space, the conversion scale is calculated. Thus, by simply marking two points, 3D spatial coordinates can be quickly converted into 2D coordinates in a plane.
[0135] In an optional implementation, the conversion scale is calculated based on the three-dimensional coordinates of at least two preset marker points and the two-dimensional screen coordinates of at least two preset marker points, including:
[0136] Calculate the first coordinate difference between the horizontal coordinates of the two marker points in the three-dimensional coordinate system; calculate the second coordinate difference between the horizontal coordinates of the two marker points in the two-dimensional screen; use the ratio of the first coordinate difference to the second coordinate difference as the horizontal transformation scale; calculate the third coordinate difference between the vertical coordinates of the two marker points in the three-dimensional coordinate system; calculate the fourth coordinate difference between the vertical coordinates of the two marker points in the two-dimensional screen; use the ratio of the third coordinate difference to the fourth coordinate difference as the vertical transformation scale.
[0137] The system includes at least two preset marker points, and conversion scales including a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis. Two-dimensional screen coordinates include a two-dimensional screen x-coordinate and a two-dimensional screen y-coordinate.
[0138] The first coordinate difference is the difference in the x-coordinates of the two marker points in their three-dimensional coordinates, and the second coordinate difference is the difference in the x-coordinates of the two marker points in their two-dimensional screen coordinates. The horizontal conversion scale is the ratio of the first coordinate difference to the second coordinate difference.
[0139] The third coordinate difference is the difference between the ordinates of the two marker points in their three-dimensional coordinates, and the fourth coordinate difference is the difference between the ordinates of the two marker points in their two-dimensional screen coordinates. The vertical conversion scale is the ratio of the third coordinate difference to the fourth coordinate difference.
[0140] For example, in the three-dimensional coordinates of two marked points, the horizontal coordinate is A. X B X The two marker points have a horizontal coordinate of a on the two-dimensional screen. X b X Then, the horizontal scale is converted. The ordinate of the two marker points in the three-dimensional coordinate system is A. Y B YThe two-dimensional screen ordinates of the two marked points are a Y b Y Then, convert the scale vertically.
[0141] S503. Calculate the coordinate deviation value based on the three-dimensional coordinates of at least two preset marker points, the two-dimensional screen coordinates of at least two preset marker points, and the conversion scale.
[0142] After determining the conversion scale of at least two preset marker points, the coordinate deviation between the three-dimensional space and the preset screen space can be calculated by combining the three-dimensional coordinates of at least two preset marker points and the two-dimensional screen coordinates of at least two preset marker points.
[0143] In an optional implementation, the coordinate deviation value is calculated based on the three-dimensional coordinates of at least two preset marker points, the two-dimensional screen coordinates of at least two preset marker points, and the transformation scale, including:
[0144] Calculate the ratio of the x-coordinate to the horizontal conversion scale in the 3D coordinates of any one of the two preset marker points. Based on the difference between the ratio of the x-coordinate to the horizontal conversion scale and the 2D screen x-coordinate of any one marker point, calculate the horizontal coordinate deviation. Calculate the ratio of the y-coordinate to the vertical conversion scale in the 3D coordinates of any one marker point. Based on the difference between the ratio of the y-coordinate to the vertical conversion scale and the 2D screen y-coordinate of any one marker point, calculate the vertical coordinate deviation.
[0145] The coordinate deviation values include: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value.
[0146] Calculate the ratio of the x-coordinate to the horizontal transformation scale in the 3D coordinates of any marker point. Then calculate the difference between the ratio of the x-coordinate to the horizontal transformation scale in the 3D coordinates of any marker point and the x-coordinate of the 2D screen of any marker point. Use this difference as the horizontal coordinate deviation value.
[0147] Calculate the ratio of the ordinate of any marker point in the 3D coordinates to the vertical conversion scale. Then calculate the difference between the ratio of the ordinate of any marker point in the 3D coordinates to the vertical conversion scale and the ordinate of any marker point in the 2D screen. Use this difference as the vertical coordinate deviation value.
[0148] For example, for any given marker point, the x-coordinate A in the three-dimensional coordinate system... X And horizontal scale C X The ratio is Subtract the horizontal coordinate 'a' from the two-dimensional screen. X The horizontal coordinate deviation value is obtained. Vertical coordinate A in three-dimensional coordinate system Y and vertical scale C Y The ratio is Subtract the horizontal coordinate 'a' from the two-dimensional screen. Y The vertical coordinate deviation value is obtained.
[0149] Based on the same inventive concept, this application also provides a mapping device for three-dimensional space to two-dimensional plane corresponding to the mapping method for three-dimensional space to two-dimensional plane. Since the principle of the device in this application is similar to the mapping method for three-dimensional space to two-dimensional plane described above in this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0150] Figure 6 This is a schematic diagram of the structure of a mapping device from three-dimensional space to a two-dimensional plane provided in an embodiment of this application. This device can be integrated into an electronic device. Figure 6 As shown, the device may include:
[0151] The acquisition module 601 is used to respond to the selection operation of the target object in the three-dimensional scene and acquire the three-dimensional coordinates of each vertex on the target object;
[0152] The mapping module 602 is used to map the three-dimensional coordinates of each vertex to a preset screen space according to a preset conversion scale and coordinate deviation value, so as to obtain the two-dimensional screen coordinates corresponding to each vertex on the target item. The conversion scale is the conversion scale between the three-dimensional scene and the preset screen space, and the coordinate deviation value is the coordinate deviation between the coordinate reference point of the three-dimensional scene and the coordinate reference point of the preset screen space.
[0153] Display module 603 is used to display the target item on the planar map according to the two-dimensional screen coordinates corresponding to each vertex.
[0154] In an optional implementation, the mapping module 602 is specifically used for:
[0155] The three-dimensional coordinates of the target object are projected onto a two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target object on the two-dimensional plane.
[0156] Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled to obtain the scaled coordinates of the target item.
[0157] Based on the coordinate deviation value, the scaled coordinates of the target item are adjusted to obtain the two-dimensional screen coordinates of the target item.
[0158] In an optional implementation, the conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0159] Mapping module 602 is specifically used for:
[0160] Based on the horizontal conversion scale, the horizontal coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled horizontal coordinate of the target item.
[0161] Based on the vertical transformation scale, the vertical coordinates of the target item on the two-dimensional plane are scaled to obtain the scaled vertical coordinates of the target item.
[0162] In an optional implementation, the coordinate deviation values include: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value of the vertical coordinate axis;
[0163] Mapping module 602 is specifically used for:
[0164] Based on the horizontal coordinate deviation value, the scaled horizontal coordinate of the target item is adjusted to obtain the two-dimensional screen horizontal coordinate of the target item.
[0165] Based on the vertical coordinate deviation value, the scaled vertical coordinate of the target item is adjusted to obtain the two-dimensional screen vertical coordinate of the target item.
[0166] In an optional implementation, the acquisition module 601 is further configured to:
[0167] Obtain the 3D coordinates of at least two preset marker points in the 3D scene and their 2D screen coordinates in the preset screen space;
[0168] The calculation module 604 is used to calculate the conversion scale based on the three-dimensional coordinates of at least two preset marker points and the two-dimensional screen coordinates of at least two preset marker points; and to calculate the coordinate deviation value based on the three-dimensional coordinates of at least two preset marker points, the two-dimensional screen coordinates of at least two preset marker points, and the conversion scale.
[0169] In an optional implementation, the at least two preset marker points include two marker points, and the conversion scale includes a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis.
[0170] The computing module 604 is specifically used for:
[0171] Calculate the first coordinate difference between the x-coordinates of the two marker points in their three-dimensional coordinates;
[0172] Calculate the second coordinate difference between the two marker points on the two-dimensional screen horizontal coordinates;
[0173] The ratio of the first coordinate difference to the second coordinate difference is used as the horizontal transformation scale.
[0174] Calculate the difference in the third coordinate between the ordinates of the two marker points in their three-dimensional coordinates;
[0175] Calculate the fourth coordinate difference between the two two-dimensional screen ordinates of the marked points;
[0176] The ratio of the third coordinate difference to the fourth coordinate difference is used as the vertical transformation scale.
[0177] In an optional implementation, the coordinate deviation value includes: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value;
[0178] The computing module 604 is specifically used for:
[0179] Calculate the ratio of the x-coordinate of any one of the two preset marker points to the horizontal conversion scale in the three-dimensional coordinates;
[0180] The horizontal coordinate deviation value is calculated based on the ratio of the horizontal coordinate of any marker point in the three-dimensional coordinates to the horizontal transformation scale, and the difference between the horizontal coordinate of any marker point in the two-dimensional screen.
[0181] Calculate the ratio of the ordinate of any given marker point in its three-dimensional coordinates to the vertical transformation scale;
[0182] The vertical coordinate deviation value is calculated based on the ratio of the vertical coordinate of any given marker point in its three-dimensional coordinates to the vertical conversion scale, and the difference between the vertical coordinate of any given marker point in its two-dimensional screen coordinates.
[0183] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0184] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 7 As shown, the device may include a processor 701, a memory 702, and a bus 703. The memory 702 stores machine-readable instructions that can be executed by the processor 701. When the electronic device is running, the processor 701 communicates with the memory 702 through the bus 703. The processor 701 executes the machine-readable instructions to perform the mapping method from three-dimensional space to two-dimensional plane provided in the above method embodiment.
[0185] This application embodiment also provides a computer-readable storage medium storing a computer program, which is executed by a processor. The processor performs the mapping method from three-dimensional space to a two-dimensional plane provided in the above-described method embodiment.
[0186] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.
[0187] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0188] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0189] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0190] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0191] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0192] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A method for mapping from three-dimensional space to a two-dimensional plane, characterized in that, include: Obtain the 3D coordinates of the target object in the 3D scene; Based on a preset conversion scale and coordinate deviation value, the three-dimensional coordinates of the target item are mapped to a preset screen space to obtain the two-dimensional screen coordinates corresponding to the target item. The conversion scale is the conversion scale between the three-dimensional scene and the preset screen space, and the coordinate deviation value is the coordinate deviation between the coordinate reference point of the three-dimensional scene and the coordinate reference point of the preset screen space. Display the target item on a plan view based on the two-dimensional screen coordinates corresponding to the target item; The step of mapping the three-dimensional coordinates of the target item to a preset screen space according to a preset conversion scale and coordinate deviation value to obtain the two-dimensional screen coordinates corresponding to the target item includes: The three-dimensional coordinates of the target item are projected onto the two-dimensional plane corresponding to the preset screen space to obtain the coordinates of the target item on the two-dimensional plane; Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled proportionally to obtain the scaled coordinates of the target item. Based on the coordinate deviation value, the scaled coordinates corresponding to the target item are adjusted to obtain the two-dimensional screen coordinates corresponding to the target item. The two-dimensional screen coordinates corresponding to the target item are obtained by subtracting the coordinate deviation value from the scaled coordinates corresponding to the target item.
2. The method according to claim 1, characterized in that, The conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis. The step of scaling the coordinates of the target item on the two-dimensional plane according to the conversion scale to obtain the scaled coordinates of the target item includes: Based on the horizontal conversion scale, the horizontal coordinate of the target item on the two-dimensional plane is scaled proportionally to obtain the scaled horizontal coordinate of the target item. Based on the vertical conversion scale, the vertical coordinate of the target item on the two-dimensional plane is scaled to obtain the scaled vertical coordinate of the target item.
3. The method according to claim 2, characterized in that, The coordinate deviation values include: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value of the vertical coordinate axis; The step of adjusting the scaled coordinates of the target item based on the coordinate deviation value to obtain the two-dimensional screen coordinates of the target item includes: Based on the horizontal coordinate deviation value, the scaled horizontal coordinate corresponding to the target item is adjusted to obtain the two-dimensional screen horizontal coordinate corresponding to the target item; Based on the vertical coordinate deviation value, the scaled vertical coordinate of the target item is adjusted to obtain the two-dimensional screen vertical coordinate of the target item.
4. The method according to claim 1, characterized in that, Before mapping the three-dimensional coordinates of the target item to a preset screen space according to a preset conversion scale and coordinate deviation value to obtain the two-dimensional screen coordinates corresponding to the target item, the method further includes: Obtain the 3D coordinates of at least two preset marker points in the 3D scene and the 2D screen coordinates in the preset screen space; The conversion scale is calculated based on the three-dimensional coordinates of the at least two preset marker points and the two-dimensional screen coordinates of the at least two preset marker points; The coordinate deviation value is calculated based on the three-dimensional coordinates of the at least two preset marker points, the two-dimensional screen coordinates of the at least two preset marker points, and the conversion scale.
5. The method according to claim 4, characterized in that, The at least two preset marker points include: two marker points, and the conversion scale includes: a horizontal conversion scale for the horizontal coordinate axis and a vertical conversion scale for the vertical coordinate axis. The step of calculating the conversion scale based on the three-dimensional coordinates of the at least two preset marker points and the two-dimensional screen coordinates of the at least two preset marker points includes: Calculate the first coordinate difference between the x-coordinates of the two marker points in their three-dimensional coordinates; Calculate the second coordinate difference between the two marker points on the two-dimensional screen horizontal coordinates; The ratio of the first coordinate difference to the second coordinate difference is used as the horizontal transformation scale. Calculate the difference in the third coordinate between the ordinates of the two marker points in their three-dimensional coordinates; Calculate the fourth coordinate difference between the two two-dimensional screen ordinates of the marked points; The ratio of the third coordinate difference to the fourth coordinate difference is used as the vertical transformation scale.
6. The method according to claim 5, characterized in that, The coordinate deviation values include: the horizontal coordinate deviation value of the horizontal coordinate axis and the vertical coordinate deviation value; The step of calculating the coordinate deviation value based on the three-dimensional coordinates of the at least two preset marker points, the two-dimensional screen coordinates of the at least two preset marker points, and the conversion scale includes: Calculate the ratio of the x-coordinate of any one of the two preset marker points to the horizontal conversion scale in the three-dimensional coordinates; The horizontal coordinate deviation value is calculated based on the ratio of the horizontal coordinate of any given marker point in the three-dimensional coordinates to the horizontal conversion scale, and the difference between the horizontal coordinate of any given marker point in the two-dimensional screen. Calculate the ratio of the ordinate of any given marker point in its three-dimensional coordinates to the vertical transformation scale; The vertical coordinate deviation value is calculated based on the ratio of the vertical coordinate of any given marker point in its three-dimensional coordinates to the vertical conversion scale, and the difference between the vertical coordinate of any given marker point in its two-dimensional screen coordinates.
7. A mapping device from three-dimensional space to a two-dimensional plane, characterized in that, include: The acquisition module is used to respond to the selection operation of a target object in a three-dimensional scene and acquire the three-dimensional coordinates of each vertex on the target object; The mapping module is used to map the three-dimensional coordinates of each vertex to a preset screen space according to a preset conversion scale and coordinate deviation value, so as to obtain the two-dimensional screen coordinates corresponding to each vertex on the target item. The conversion scale is the conversion scale between the three-dimensional scene and the preset screen space, and the coordinate deviation value is the coordinate deviation value between the coordinate reference point of the three-dimensional scene and the coordinate reference point of the preset screen space. The display module is used to display the target item on the planar map according to the two-dimensional screen coordinates corresponding to each vertex; The mapping module is specifically used to project the three-dimensional coordinates of the target item onto a two-dimensional plane corresponding to the preset screen space, so as to obtain the coordinates of the target item on the two-dimensional plane; Based on the conversion scale, the coordinates of the target item on the two-dimensional plane are scaled proportionally to obtain the scaled coordinates of the target item. Based on the coordinate deviation value, the scaled coordinates corresponding to the target item are adjusted to obtain the two-dimensional screen coordinates corresponding to the target item. The two-dimensional screen coordinates corresponding to the target item are obtained by subtracting the coordinate deviation value from the scaled coordinates corresponding to the target item.
8. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the mapping method from three-dimensional space to a two-dimensional plane as described in any one of claims 1 to 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, performs the mapping method from three-dimensional space to a two-dimensional plane as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Object space positioning method and device in three-dimensional virtual reality scene
CN102722908A