Method, device and equipment for generating virtual object and storage medium
By acquiring virtual object frames and generating reference lines, the positional relationships of virtual object frames are determined and processed, solving the problems of virtual object overlap and discontinuous generation, achieving smooth virtual object generation, and improving the user experience.
Patent Information
- Application Number
- CN202210073858.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-21
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-02-06
AI Technical Summary
When generating virtual objects in real-world scenarios, overlapping and discontinuous generation issues may occur, affecting the user experience.
By acquiring the virtual object bounding box, generating reference lines, determining the positional relationship between the reference lines and the rendered virtual objects, and processing the virtual object bounding box according to the positional relationship to avoid overlap, virtual objects are added step by step.
Prevent virtual objects from overlapping, ensure smooth generation, and improve user experience.
Smart Images

Figure CN114419299B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of augmented reality, and in particular, to a virtual object generation method and device, equipment and a storage medium. BACKGROUND
[0002] Currently, when generating a virtual object in a real scene, the phenomenon of virtual object overlap may occur in the case of directly generating a virtual object according to a virtual object frame returned by an algorithm. In addition, when updating a virtual object in a current picture, if a clearing process is selected for the virtual object and a new virtual object is generated, the picture generated by the virtual object may not be smooth, thereby affecting the user experience. SUMMARY
[0003] Embodiments of the present disclosure provide a virtual object generation method, device, equipment and storage medium, which can avoid virtual object overlap and ensure the smooth generation of virtual objects, thereby improving the user experience.
[0004] In a first aspect, embodiments of the present disclosure provide a virtual object generation method, comprising:
[0005] obtaining a virtual object frame to be mounted;
[0006] generating a reference line based on the virtual object frame;
[0007] determining a positional relationship between the reference line and a rendered virtual object;
[0008] processing the virtual object frame according to the positional relationship;
[0009] generating a virtual object in the processed virtual object frame.
[0010] In a second aspect, embodiments of the present disclosure also provide a virtual object generation device, comprising:
[0011] a virtual object frame obtaining module configured to obtain a virtual object frame to be mounted;
[0012] a reference line generating module configured to generate a reference line based on the virtual object frame;
[0013] a positional relationship determining module configured to determine a positional relationship between the reference line and a rendered virtual object;
[0014] a virtual object frame processing module configured to process the virtual object frame according to the positional relationship;
[0015] a virtual object generating module configured to generate a virtual object in the processed virtual object frame.
[0016] In a third aspect, the present disclosure also provides an electronic device, which comprises:
[0017] one or more processing devices;
[0018] a storage device configured to store one or more programs;
[0019] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method for generating a virtual object according to the embodiments of the present disclosure.
[0020] In a fourth aspect, the present disclosure discloses a computer readable medium having a computer program stored thereon, which, when executed by a processing device, implements the method for generating a virtual object according to the embodiments of the present disclosure.
[0021] The embodiments of the present disclosure disclose a method and device for generating a virtual object, an electronic device and a storage medium. A virtual object frame to be mounted is obtained; a reference line is generated based on the virtual object frame; a positional relationship between the reference line and a rendered virtual object is determined; the virtual object frame is processed according to the positional relationship; and a virtual object is generated in the processed virtual object frame. The method for generating a virtual object provided by the embodiments of the present disclosure processes the virtual object frame according to the positional relationship between the reference line and the rendered virtual object, which can prevent the overlap of virtual objects and achieve the gradual addition of virtual objects, without the need for clearing the virtual objects, thereby ensuring the smooth generation of virtual objects and improving the user experience. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of a method for generating a virtual object in the embodiments of the present disclosure;
[0023] Figure 2 is an example diagram of a virtual object frame obtained in the embodiments of the present disclosure;
[0024] Figure 3 is a pinhole camera imaging principle diagram in the embodiments of the present disclosure;
[0025] Figure 4 is an example diagram of triangular meshing the surface of a rendered virtual object in the embodiments of the present disclosure;
[0026] Figure 5 is an example diagram of generating a virtual object in the embodiments of the present disclosure;
[0027] Figure 6 is a structural schematic diagram of a device for generating a virtual object in the embodiments of the present disclosure;
[0028] Figure 7 is a structural schematic diagram of an electronic device in the embodiments of the present disclosure. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure will be described in more detail with reference to the drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be interpreted in a limited sense as set forth in the embodiments set forth herein, but rather, the embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of protection of the present disclosure.
[0030] It should be understood that each of the steps recited in the method embodiments of the present disclosure can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] The term "comprising" and variations thereof as used herein are open-ended, that is "including, but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Related terms are defined in the following description.
[0032] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modification of "one" or "multiple" mentioned in the present disclosure is illustrative and not limiting, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as "one or more".
[0034] The names of the messages or information exchanged between the devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0035] Figure 1 A flowchart of a virtual object generation method according to an embodiment of the present disclosure is provided. The embodiment can be applied to the generation of a virtual object in a three-dimensional space. The method can be performed by a virtual object generation device, which can be composed of hardware and / or software, and can be integrated in a device having a virtual object generation function, such as a server, a mobile terminal, or a server cluster. As shown in FIG. 8, the method specifically includes the following steps: Figure 1
[0036] S110, acquire a virtual object frame to be mounted.
[0037] The virtual object frame is mounted on an object identified in the three-dimensional space and is used to place a virtual object. The virtual object frame can include multiple virtual object frames. In this embodiment, the virtual object can be a virtual object corresponding to an arbitrary theme. For example, the theme is "Spring Festival", and the virtual object can be a virtual couplet, a virtual lantern, a virtual New Year picture, and the like, which are not limited herein.
[0038] Optionally, the virtual object frame to be mounted can be acquired by performing object detection on a current image and determining the virtual object frame based on the detected object.
[0039] In this embodiment, the object detection module in the terminal device detects the object in the image at a certain frequency during the shooting of the current three-dimensional space, obtains the detection frame and semantic information corresponding to the object, and determines the virtual object frame based on the detection frame and the semantic information. For example, Figure 2 is an example diagram of the virtual object frame acquired in this embodiment, as shown in Figure 2 The detected objects in the image include the sky, the building, and the plant, and the virtual object frame is generated on these objects.
[0040] The size of the virtual object frame can be determined based on the detection frame of the object, and the category of the virtual object frame can be determined based on the semantic information. Specifically, the size of the virtual object frame can be smaller than or equal to the detection frame of the object, or the detection frame of the object can be split to obtain multiple virtual object frames. The category of the virtual object frame is used to determine the category of the virtual object inside the virtual object frame, which can include a static virtual object and a dynamic virtual object. For example, the theme is "Spring Festival", the static virtual object can be a "couplet", and the dynamic virtual object can be a "rotating lantern". In this embodiment, the virtual object frame is determined based on the detected object, so that the virtual object placed in the virtual object frame is more consistent with the real scene.
[0041] S120, generate a reference line based on the virtual object frame.
[0042] The reference line can be a ray emitted from the virtual object frame, and the reference line based on the virtual object frame can be generated according to the camera imaging principle. The camera imaging principle can be a pinhole camera imaging principle. For example, as shown in Figure 3As shown, the light reflected by the object in the three-dimensional space enters the pinhole camera, and the image collected by the pinhole camera is projected on the pixel plane. Each pixel point on the pixel plane can generate a reference line directed to the three-dimensional space in the direction of the light. In this embodiment, the virtual object frame obtained is located in the pixel plane, and a pixel point can be selected and set on the virtual object frame. A reference line directed to the three-dimensional space is generated in the direction of the light from the set pixel point. According to the inverse transformation principle of the pinhole camera, the direction vector of the reference line can be obtained.
[0043] Specifically, the virtual object frame includes vertex information and center point information of the virtual object frame, and the vertex includes a plurality of vertices. The way of generating the reference line based on the virtual object frame can be: generating the reference line corresponding to each vertex and the center point.
[0044] In this embodiment, the virtual object frame can be a parallelogram, and the virtual object frame includes four vertices. In this application scenario, five reference lines emitted from the four vertices and the center line of the virtual object frame are generated according to the camera imaging principle, and the direction vectors of the five reference lines can be obtained according to the inverse transformation principle of the pinhole camera. In this embodiment, the reference line corresponding to each vertex and the center point is generated, which can reduce the amount of calculation.
[0045] In this embodiment, a rayCast component can be added to the camera to generate the reference line. The component is used to generate the reference line emitted from the four vertices and the center point of the virtual object frame according to the camera imaging principle.
[0046] S130, determining the positional relationship between the reference line and the rendered virtual object.
[0047] The rendered virtual object can be understood as a virtual object displayed and mounted on the object in the three-dimensional space, and the virtual object is a 3D object. The positional relationship includes intersection and non-intersection.
[0048] Optionally, determining the positional relationship between the reference line and the rendered virtual object includes: determining the distance between the reference line corresponding to each vertex and the center point and the rendered virtual object; if the distance is less than or equal to a set value, the reference line intersects with the rendered virtual object; and if the distance is greater than the set value, the reference line does not intersect with the rendered virtual object.
[0049] The positional relationship between the reference line and the rendered virtual object includes the positional relationship between the reference line corresponding to each vertex and the rendered virtual object and the positional relationship between the reference line corresponding to the center point and the rendered virtual object.
[0050] The set value can be 0. The distance between the reference line and the rendered virtual object can be understood as the shortest distance between each point on the surface of the rendered object and the reference line. If the shortest distance is greater than 0, it indicates that the reference line does not intersect the rendered object. If the shortest distance is less than or equal to 0, it indicates that the reference line intersects the rendered object. In this embodiment, the position relationship is determined based on the distance between the reference line and the rendered virtual object, which can quickly and accurately determine whether the reference line intersects the rendered object.
[0051] In S140, the virtual object frame is processed according to the position relationship.
[0052] The processing manner can be deleting or lowering the transparency.
[0053] Specifically, the processing manner of the virtual object frame according to the position relationship can be: if the reference line corresponding to the center point intersects the rendered virtual object, the virtual object frame is deleted or the transparency is lowered; if the reference line corresponding to the center point does not intersect the rendered virtual object, and the reference lines corresponding to more than a set number of vertices intersect the rendered virtual object, the virtual object frame is deleted or the transparency is lowered.
[0054] The set number can be 2 or 3. In this embodiment, if the reference line corresponding to the center point intersects the rendered virtual object, it indicates that the virtual object in the virtual object frame will completely overlap the rendered virtual object, so the virtual object frame needs to be deleted or the transparency needs to be lowered. If the reference lines corresponding to more than a set number of vertices intersect the rendered virtual object, it indicates that the virtual object in the virtual object frame will overlap the rendered virtual object by a large part, so the virtual object frame needs to be deleted or the transparency needs to be lowered. This can improve the accuracy of processing the virtual object frame.
[0055] Optionally, the manner of determining the position relationship between the reference line and the rendered virtual object can be: performing triangular meshing on the surface of the rendered virtual object to obtain a plurality of triangular faces; determining the intersection of the reference line with each triangular face; and if the reference line intersects any triangular face, the reference line intersects the rendered virtual object.
[0056] The rendered virtual object is a three-dimensional object, and the triangular meshing on the surface of the rendered virtual object can be understood as dividing the surface of the rendered virtual object into a plurality of triangular planes. For example, Figure 4 is an example of triangular meshing on the surface of the rendered virtual object in this embodiment, as shown in Figure 4 The virtual object is a three-dimensional rabbit, and the surface of the object is divided into a plurality of triangular planes. The manner of determining the intersection of the reference line with each triangular face can be achieved by using the existing principle of intersection of straight lines and triangular faces, which is not limited here.
[0057] In this embodiment, after obtaining the plurality of triangular faces, the intersection of the reference line corresponding to the vertex and the center point respectively with each triangular face is determined. If the reference line intersects with any one of the triangular faces, it indicates that the reference line intersects with the rendered virtual object. In this embodiment, the intersection of the reference line with the rendered virtual object is determined by triangulating the surface of the rendered virtual object, which can improve the accuracy.
[0058] Optionally, the manner of determining the positional relationship between the reference line and the rendered virtual object can be: obtaining the bounding box of the rendered virtual object; determining the intersection of the reference line and the bounding box; if the reference line intersects with the bounding box, the reference line intersects with the rendered virtual object.
[0059] The bounding box has a cuboid shape, which can be understood as the minimum circumscribed cuboid of the rendered virtual object. The cuboid includes three pairs of parallel planes, namely front-back parallel planes, left-right parallel planes, and up-down parallel planes.
[0060] Specifically, the process of determining the intersection of the reference line and the bounding box can be: obtaining three line segments obtained by intersecting the three pairs of parallel planes corresponding to the reference line and the bounding box; if the three line segments all satisfy the following conditions, the reference line intersects with the bounding box: part or all of the line segments fall within the bounding box.
[0061] The three pairs of parallel planes corresponding to the bounding box can be understood as the planes extending to the entire space corresponding to the three pairs of parallel planes of the bounding box, including the front-back parallel planes extending to the entire space, the left-right parallel planes extending to the entire space, and the up-down parallel planes extending to the entire space. For each pair of parallel planes, the reference line intersects with the pair of parallel planes to obtain a line segment, thereby obtaining three line segments. In this embodiment, according to the direction vector of the reference line and the spatial function of each pair of parallel planes, the coordinates of the two endpoints of the line segment formed after the intersection of the reference line and the parallel plane can be obtained, and whether part or all of the line segment falls within the bounding box can be determined according to the coordinates of the two endpoints. In this embodiment, the intersection of the reference line and the rendered virtual object is determined based on the intersection of the reference line and the bounding box, which can improve the efficiency of determining the positional relationship.
[0062] In this embodiment, if the reference line intersects with the rendered virtual object, it indicates that the virtual object in the virtual object frame intersected by the reference line will partially or completely overlap with the rendered virtual object, and therefore the virtual object frame needs to be deleted or have its transparency reduced, without rendering the rendered virtual object in the processed virtual object frame.
[0063] S150, generating a virtual object in the processed virtual object frame.
[0064] After the virtual object frame colliding with the rendered virtual object is deleted or the transparency is lowered, the remaining virtual object frames are first mounted on the corresponding objects in the three-dimensional space, then the materials corresponding to the remaining virtual object frames are obtained, and the materials are rendered in the remaining virtual object frames, so as to generate the virtual object. Exemplarily, Figure 5 is an example diagram of generating a virtual object in this embodiment, as shown in Figure 5 a "virtual New Year picture" and a "virtual rotating lantern" are generated.
[0065] The technical scheme of the embodiment of the present disclosure obtains a virtual object frame to be mounted; generates a reference line based on the virtual object frame; determines the positional relationship between the reference line and a rendered virtual object; processes the virtual object frame according to the positional relationship; and generates a virtual object in the processed virtual object frame. The method for generating a virtual object provided in the embodiment of the present disclosure processes the virtual object frame according to the positional relationship between the reference line and the rendered virtual object, which can prevent the overlap of virtual objects and can realize the gradual addition of virtual objects, without the need for clearing the virtual objects, so as to ensure the smooth generation of virtual objects and improve the user experience.
[0066] Figure 6 is a structural schematic diagram of a virtual object generation device provided in the embodiment of the present disclosure, as shown in Figure 6 The device comprises:
[0067] A virtual object frame obtaining module 210 is configured to obtain a virtual object frame to be mounted.
[0068] A reference line generating module 220 is configured to generate a reference line based on the virtual object frame.
[0069] A positional relationship determining module 230 is configured to determine the positional relationship between the reference line and a rendered virtual object.
[0070] A virtual object frame processing module 240 is configured to process the virtual object frame according to the positional relationship.
[0071] A virtual object generating module 250 is configured to generate a virtual object in the processed virtual object frame.
[0072] Optionally, the virtual object frame obtaining module 210 is further configured to:
[0073] perform object detection on a current picture;
[0074] determine the virtual object frame according to the detected object.
[0075] Optionally, the virtual object frame comprises vertex information and center point information of the virtual object frame, and the vertices comprise a plurality of vertices; and the reference line generating module 220 is further configured to:
[0076] generate reference lines corresponding to the vertex and the center point respectively.
[0077] Optionally, the position relationship determining module 230 is further configured to:
[0078] determine distances between the reference lines corresponding to the vertex and the center point respectively and the rendered virtual object;
[0079] if the distance is less than or equal to a set value, the reference line intersects with the rendered virtual object; if the distance is greater than the set value, the reference line does not intersect with the rendered virtual object.
[0080] Optionally, the virtual object frame processing module 240 is further configured to:
[0081] if the reference line corresponding to the center point intersects with the rendered virtual object, delete or lower the transparency of the virtual object frame;
[0082] if the reference line corresponding to the center point does not intersect with the rendered virtual object, and the reference lines corresponding to more than a set number of the vertexes intersect with the rendered virtual object, delete or lower the transparency of the virtual object frame.
[0083] Optionally, the position relationship determining module 230 is further configured to:
[0084] triangulate the surface of the rendered virtual object to obtain a plurality of triangular faces;
[0085] determine intersection conditions of the reference line and the plurality of triangular faces respectively;
[0086] if the reference line intersects with any triangular face, the reference line intersects with the rendered virtual object.
[0087] Optionally, the position relationship determining module 230 is further configured to:
[0088] obtain a bounding box of the rendered virtual object;
[0089] determine an intersection condition of the reference line and the bounding box;
[0090] if the reference line intersects with the bounding box, the reference line intersects with the rendered virtual object.
[0091] Optionally, the position relationship determining module 230 is further configured to:
[0092] obtain three line segments intersected by three pairs of parallel faces corresponding to the reference line and the bounding box;
[0093] If the three line segments all satisfy the following condition, the reference line intersects the bounding box:
[0094] Part or all of the line segment falls within the bounding box.
[0095] The apparatus can perform the method provided by all the preceding embodiments of the present disclosure, has the corresponding function modules for performing the above method and the beneficial effects. The technical details not described in detail in the present embodiment can refer to the method provided by all the preceding embodiments of the present disclosure.
[0096] Reference is made below to Figure 7 , which shows a structural schematic diagram of an electronic device 300 suitable for implementing embodiments of the present disclosure. The electronic device in the embodiments of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (such as a vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like, or various forms of servers, such as a standalone server or a server cluster. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0097] As shown in Figure 7 , the electronic device 300 can include a processing device (such as a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to programs stored in a read-only memory device (ROM) 302 or programs loaded from a storage device 305 into a random access memory device (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0098] Generally, the following devices can be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage device 308 including, for example, a magnetic tape, a hard disk, and the like; and a communication device 309. The communication device 309 can allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 300 is shown with various devices, but it should be understood that all the shown devices are not required to be implemented or possessed. More or fewer devices can be alternatively implemented or possessed.
[0099] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for performing the method of recommending a term. In such embodiments, the computer program can be downloaded and installed from a network by the communication device 309, or installed from the storage device 305, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of embodiments of the present disclosure are performed.
[0100] It should be noted that the computer readable medium described above in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination thereof. The computer readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take many forms, including but not limited to, an electromagnetic signal, an optical signal or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that can send, propagate or transfer a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer readable medium can be transmitted by any suitable medium, including but not limited to, a wire, cable, optical fiber, RF (radio frequency), or any suitable combination thereof.
[0101] In some embodiments, the client, server, or other computing machines utilized by the system can communicate over any known or later developed network protocol, such as the HyperText Transfer Protocol (HTTP), and can be interconnected with any form or medium of digital data communication (for example, a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet, and peer-to-peer networks (for example, ad hoc peer-to-peer networks), as well as any then-current or later developed networks.
[0102] The computer-readable medium described above can be included in the electronic device described above; alternatively, the computer-readable medium can exist as a standalone entity.
[0103] The computer-readable medium described above carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquire a virtual object frame to be mounted; generate a reference line based on the virtual object frame; determine a positional relationship between the reference line and a rendered virtual object; process the virtual object frame according to the positional relationship; and generate a virtual object within the processed virtual object frame.
[0104] Computer program code for carrying out operations of the present disclosure can be written in any one or combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network ("LAN") or a wide area network ("WAN"), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0105] The flow and block diagrams in the drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow and block diagrams can represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or combinations of hardware and software.
[0106] The units described in the embodiments of the present disclosure can be implemented by software, or by hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
[0107] The functions described above in the specification can be implemented in part or in whole by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0108] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more of: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0109] According to one or more embodiments of the embodiments of the present disclosure, the embodiments of the present disclosure disclose a method for generating a virtual object, comprising:
[0110] acquire a virtual object frame to be mounted;
[0111] generate a reference line based on the virtual object frame;
[0112] determine a positional relationship between the reference line and a rendered virtual object;
[0113] process the virtual object frame according to the positional relationship;
[0114] generate a virtual object in the processed virtual object frame.
[0115] Further, the acquiring of the virtual object frame to be mounted comprises:
[0116] perform object detection on a current frame;
[0117] determine a virtual object frame according to the detected object.
[0118] Further, the virtual object frame contains vertex information and center point information of the virtual object frame, and the vertices include a plurality of vertices; the generating of the reference line based on the virtual object frame comprises:
[0119] generate a reference line corresponding to each of the vertices and the center point.
[0120] Further, the positional relationship includes intersection and non-intersection; the determining of the positional relationship between the reference line and the rendered virtual object comprises:
[0121] determine distances between the reference lines corresponding to the vertices and the center point and the rendered virtual object;
[0122] if the distance is less than or equal to a set value, the reference line intersects with the rendered virtual object; if the distance is greater than the set value, the reference line does not intersect with the rendered virtual object.
[0123] Further, the processing of the virtual object frame according to the positional relationship comprises:
[0124] if the reference line corresponding to the center point intersects with the rendered virtual object, delete or lower the transparency of the virtual object frame;
[0125] if the reference line corresponding to the center point does not intersect with the rendered virtual object, and a set number of the reference lines corresponding to the vertices intersect with the rendered virtual object, delete or lower the transparency of the virtual object frame.
[0126] Further, the determining of the positional relationship between the reference line and the rendered virtual object comprises:
[0127] Triangular meshing is performed on the surface of the rendered virtual object to obtain a plurality of triangular faces;
[0128] The intersection of the reference line and the plurality of triangular faces is determined respectively;
[0129] If the reference line intersects any triangular face, the reference line intersects the rendered virtual object.
[0130] Further, the position relationship between the reference line and the rendered virtual object is determined, including:
[0131] An enclosing box of the rendered virtual object is obtained;
[0132] The intersection of the reference line and the enclosing box is determined;
[0133] If the reference line intersects the enclosing box, the reference line intersects the rendered virtual object.
[0134] Further, the enclosing box is a cuboid, and the intersection of the reference line and the enclosing box is determined, including:
[0135] Three line segments obtained by intersecting three pairs of parallel faces corresponding to the reference line and the enclosing box are obtained;
[0136] If the three line segments all satisfy the following conditions, the reference line intersects the enclosing box:
[0137] Part or all of the line segment falls into the enclosing box.
[0138] Note that the above is only the preferred embodiment of the present disclosure and the technical principle applied. Those skilled in the art will understand that the present disclosure is not limited to the specific embodiments described herein, and those skilled in the art can make various obvious changes, readjustments and substitutions without departing from the protection scope of the present disclosure. Therefore, although the present disclosure has been described in more detail through the above embodiments, the present disclosure is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present disclosure, and the scope of the present disclosure is determined by the scope of the appended claims.
Claims
1. A method for generating virtual objects, characterized in that, include: Obtain the virtual object frame to be mounted; wherein the virtual object frame is suspended on the object detected in three-dimensional space and is used to place the virtual object, the size of the virtual object frame is determined based on the size of the detection frame of the object, the virtual object frame contains vertex information and center point information of the virtual object frame, and the vertex includes multiple vertices; Based on the virtual object frame, generate reference lines corresponding to the vertices and the center point respectively; Determine the positional relationship between the reference line and the rendered virtual object; wherein, the rendered virtual object refers to a virtual object that has been displayed and mounted on an object in three-dimensional space; the positional relationship includes intersecting and non-intersecting; If the reference line corresponding to the center point intersects with the rendered virtual object, then the virtual object frame is deleted or its transparency is reduced. If the reference line corresponding to the center point does not intersect with the rendered virtual object, and more than a set number of the reference lines corresponding to the vertices intersect with the rendered virtual object, then the virtual object frame is deleted or its transparency is reduced. The virtual object is generated within the processed virtual object frame.
2. The method according to claim 1, characterized in that, Obtain the bounding box of the virtual object to be mounted, including: Perform object detection on the current screen; The virtual object frame is determined based on the detected objects.
3. The method according to claim 1, characterized in that, Determining the positional relationship between the reference line and the rendered virtual object includes: Determine the distances between the reference lines corresponding to the vertex and the center point and the rendered virtual object; If the distance is less than or equal to the set value, the reference line intersects with the rendered virtual object; if the distance is greater than the set value, the reference line does not intersect with the rendered virtual object.
4. The method according to claim 3, characterized in that, Determining the positional relationship between the reference line and the rendered virtual object includes: The surface of the rendered virtual object is meshed into triangles to obtain multiple triangular faces; Determine the intersection of the reference line with each of the plurality of triangular faces; If the reference line intersects any triangular face, then the reference line intersects the rendered virtual object.
5. The method according to claim 3, characterized in that, Determining the positional relationship between the reference line and the rendered virtual object includes: Obtain the bounding box of the rendered virtual object; Determine the intersection of the reference line and the bounding box; If the reference line intersects the bounding box, then the reference line intersects the rendered virtual object.
6. The method according to claim 5, characterized in that, The bounding box is a cuboid. Determining the intersection of the reference line and the bounding box includes: Obtain three line segments by the intersection of the reference line and the three pairs of parallel planes corresponding to the bounding box; If all three line segments satisfy the following condition, then the reference line intersects the bounding box: Part or all of the line segment falls within the bounding box.
7. A device for generating virtual objects, characterized in that, include: A virtual object frame acquisition module is used to acquire a virtual object frame to be mounted; wherein, the virtual object frame is suspended on an object detected in three-dimensional space and is used to place the virtual object; the size of the virtual object frame is determined based on the size of the object's detection frame; the virtual object frame contains vertex information and center point information of the virtual object frame, and the vertex includes multiple vertices; A reference line generation module is used to generate reference lines emitted from the virtual object frame according to the camera imaging principle; A reference line generation module is used to generate reference lines corresponding to the vertex and the center point based on the virtual object frame; A positional relationship determination module is used to determine the positional relationship between the reference line and the rendered virtual object; wherein, the rendered virtual object refers to a virtual object that has been displayed and mounted on an object in three-dimensional space; the positional relationship includes intersecting and non-intersecting; The virtual object frame processing module is used to delete or reduce the transparency of the virtual object frame if the reference line corresponding to the center point intersects with the rendered virtual object; and to delete or reduce the transparency of the virtual object frame if the reference line corresponding to the center point does not intersect with the rendered virtual object, and more than a set number of reference lines corresponding to the vertices intersect with the rendered virtual object. The virtual object generation module is used to generate the virtual object within the processed virtual object frame.
8. An electronic device, characterized in that, The electronic device includes: One or more processing devices; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method for generating virtual objects as described in any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by a processing device, the program implements the method for generating virtual objects as described in any one of claims 1-6.
Citation Information
Patent Citations
Display method and device for scene font in virtual environment, equipment and medium
CN113058266A
Camera pose determination method and device, virtual object display method and device and electronic equipment
CN113643356A