Model shooting method and device in virtual space and electronic equipment
By determining and correcting the target position in the virtual space, generating a virtual model to simulate the shape of the preset logo, and controlling the shooting of the virtual camera, the lens distortion problem caused by the perspective mode of the logo animation in the game is solved, and the display effect and game experience are improved.
Patent Information
- Application Number
- CN202411313009.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-02-07
AI Technical Summary
When generating animations based on logo images in the game, the perspective mode cannot allow the model to present a standard logo shape, resulting in lens distortion and poor display effect.
By obtaining the preset identifier in the target image, the target position in the virtual space and the position and camera parameters of the virtual camera are determined, and multiple initial positions are determined in the virtual space based on these parameters and corrected, and a virtual model is generated to simulate the pre-pre- Set the shape of the logo and control the virtual camera to take pictures of the model.
The lens distortion phenomenon is avoided, and the display effect of the model that simulates the preset logo in the captured images or videos is improved, which improves the player's gaming experience.
Smart Images

Figure CN119402605A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of virtual scenes, and in particular to a method, device and electronic equipment for photographing a model in a virtual space. Background Art
[0002] In some games, the title animation or transition animation usually needs to be generated based on the game's logo. Among them, logo is the abbreviation of the English "logo type", which refers to the visual symbol used to identify a specific brand, company or product, and can be translated as "logo" or "sign", etc. The logo usually appears in the form of a simple, prominent and easy-to-recognize graphic or text, and the logo can be saved through a picture. When making an animation based on a logo image, it is usually necessary to use the logo image to generate a dot matrix, distribute the model on the dot matrix, and then use the camera perspective mode to shoot the model array, which will have a real-world perspective effect. However, in this method, the perspective mode cannot make the final model present the shape of the standard logo image, resulting in lens distortion, resulting in poor animation display effect. Summary of the invention
[0003] In view of this, the purpose of the present disclosure is to provide a model shooting method, device and electronic device in a virtual space, so that when the model is photographed by a virtual camera, distortion can be avoided, the display effect of the model simulating a preset logo in the captured image or video can be improved, and the player's gaming experience can be enhanced.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for shooting a model in a virtual space, the method comprising: acquiring a target image; the target image includes a preset mark; based on a preset shooting requirement, determining a target position corresponding to the target image in the preset virtual space, as well as a posture and camera parameters of a virtual camera in the virtual space; based on the target position and the pixel points constituting the preset mark in the target image, determining a plurality of initial positions in the virtual space, correcting the plurality of initial positions based on the posture and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, generating a virtual model at each target position so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; and controlling the virtual camera to shoot the plurality of virtual models according to the posture and camera parameters.
[0005] In a second aspect, an embodiment of the present disclosure provides a model shooting device in a virtual space, the device comprising: an image acquisition module, used to acquire a target image; the target image includes a preset mark; a parameter determination module, used to determine a target position corresponding to the target image in a preset virtual space, as well as a posture and camera parameters of a virtual camera in the virtual space based on preset shooting requirements; a model generation module, used to determine a plurality of initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image, correct the plurality of initial positions based on the posture and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, and generate a virtual model at each target position so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; a shooting module, used to control the virtual camera to shoot the plurality of virtual models according to the posture and camera parameters.
[0006] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned model shooting method in the virtual space.
[0007] In a fourth aspect, an embodiment of the present invention provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned model shooting method in the virtual space.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] The above-mentioned model shooting method, device and electronic device in a virtual space obtain a target image; the target image includes a preset mark; based on the preset shooting requirements, determine the target position corresponding to the target image in the preset virtual space, as well as the posture and camera parameters of the virtual camera in the virtual space; based on the target position and the pixel points constituting the preset mark in the target image, determine multiple initial positions in the virtual space, correct the multiple initial positions based on the posture and camera parameters of the virtual camera in the virtual space, obtain multiple target positions, generate virtual models at each target position, so that the display area occupied by the multiple virtual models in the virtual space simulates the shape of the preset mark; according to the posture and camera parameters, control the virtual camera to shoot the multiple virtual models. In this method, the position of the model used to simulate the preset mark is determined based on the position and camera parameters of the virtual camera, taking into account the distortion generated when the camera shoots, and when the model is shot by the virtual camera, the distortion phenomenon can be avoided, and the display effect of the model simulating the preset mark in the shot image or video is improved, which improves the game experience of the player.
[0010] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0011] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 A flowchart of a method for photographing a model in a virtual space provided by an embodiment of the present disclosure;
[0014] Figure 2 A schematic diagram of a target area range provided in an embodiment of the present disclosure;
[0015] Figure 3 A schematic diagram of a logo image provided in an embodiment of the present disclosure;
[0016] Figure 4 A schematic diagram of a dot matrix provided for an embodiment of the present disclosure;
[0017] Figure 5 A schematic diagram of generating a bell model in a dot matrix provided by an embodiment of the present disclosure;
[0018] Figure 6 A schematic diagram of a bell model photographed before correction provided by an embodiment of the present disclosure;
[0019] Figure 7 A schematic diagram of a bell model photographed after correction provided by an embodiment of the present disclosure;
[0020] Figure 8 A schematic diagram of the structure of a model shooting device in a virtual space provided by an embodiment of the present disclosure;
[0021] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0023] At the beginning or transition of the game, it is often necessary to produce an animation performance. The virtual camera (also called a "camera") shuttles through a bunch of bell models, and finally presents a lens animation of the logo text composed of bell models. In this process, it is usually necessary to first use the logo image to generate a dot matrix, and then distribute the model on the dot matrix. Use the camera perspective mode to shoot the model array composed of bells, which will have the perspective effect of the real world. When showing the model screen generated by a logo image, the perspective effect of the real world cannot make the final model present the shape of the standard logo image, which will cause lens distortion and lead to poor viewing experience for players.
[0024] Based on this, the embodiments of the present disclosure provide a method, device and electronic device for shooting a model in a virtual space. This technology can be applied to scenarios where a model simulation logo needs to be shot by a virtual camera.
[0025] See also Figure 1 First, a method for photographing a model in a virtual space provided by an embodiment of the present invention is introduced, and a graphical user interface is provided by a terminal device. The method comprises the following steps:
[0026] Step S102, obtaining a target image; the target image includes a preset mark.
[0027] The target image may be an image showing a person image, text, graphics, etc., which is usually related to the subject of the image or animation to be captured by the virtual camera. The target image may be one or more, which is not limited here. The preset logo may be one or more of a person image, text, and graphics.
[0028] The preset logo may occupy part of the display area of the target image or the entire target image. When the preset logo occupies part of the display area of the target image, the remaining area of the target image may be regarded as the background. The display color of the background is usually different from the display color of the preset logo, usually black or white, or a specified color, which is not limited here.
[0029] Step S104, based on the preset shooting requirements, determining the target position corresponding to the target image in the preset virtual space, as well as the position and camera parameters of the virtual camera in the virtual space.
[0030] Shooting requirements are usually used to limit the position, size, etc. of the virtual model (also called "model") generated based on the target image in the image or video generated by the virtual camera. The target position corresponding to the target image can limit the setting position of the model in the virtual space. The posture and camera parameters of the virtual camera in the virtual space can determine the content of the picture captured by the virtual camera. The above shooting requirements actually limit the relative position between the virtual camera and the model generated based on the target image.
[0031] The above-mentioned posture usually refers to position and attitude. The posture of the virtual camera in the virtual space can usually be represented by position coordinates and direction vectors. The posture of the virtual camera in the virtual space can be preset, for example, the virtual camera is set at the origin of the virtual space, facing a certain coordinate axis. The camera parameters of the virtual camera usually include the parameters of the virtual camera mainly including camera state, camera priority, follow object, shooting object, field of view angle, near clipping plane, far clipping plane, etc. The user can set the above parameters of the virtual camera to meet the shooting requirements. Then, according to the shooting requirements and the posture and shooting parameters of the virtual camera, the target position of the target image in the virtual space can be set.
[0032] In practical applications, the target position corresponding to the target model in the virtual space can also be determined first. The virtual model used to simulate the preset logo also needs to be set in the virtual space so that the virtual camera can shoot the virtual model. The target image is usually unrelated to the virtual space. A target position can be specified in the virtual space, assuming that it is the placement position of the target image, such as specifying the origin position in the virtual space as the placement position of the target image. Usually, the center position of the target image coincides with the origin position. Then, based on the target position of the target image in the virtual space and the above-mentioned shooting requirements, the virtual camera's posture and shooting parameters are determined.
[0033] Step S106, based on the target position and the pixel points that constitute the preset mark in the target image, multiple initial positions are determined in the virtual space, and the multiple initial positions are corrected based on the posture and camera parameters of the virtual camera in the virtual space to obtain multiple target positions, and a virtual model is generated at each target position so that the display area occupied by the multiple virtual models in the virtual space simulates the shape of the preset mark.
[0034] As mentioned above, when a virtual camera shoots an object in perspective mode, distortion will occur. After generating multiple models corresponding to the preset logo, these models are photographed by the virtual camera. Due to the distortion effect, the arrangement of these models in the photographed picture is difficult to simulate the preset logo. Therefore, when generating the model, it is necessary to make the location of the model pass through the virtual camera to offset the effect of distortion.
[0035] Since the shape of the preset logo needs to be simulated through the display area occupied by multiple models in the virtual space, the position of the model needs to be within the display range of the preset logo. When the placement position of the target image in the virtual space is set, the display range occupied by the preset logo in the target image can be determined based on the pixels constituting the preset logo in the target image. Then, based on the target position corresponding to the target image in the virtual space, the display range of the preset logo in the virtual space is determined.
[0036] Then, multiple positions can be randomly determined in the display range. Since the image distortion caused by the virtual camera during the shooting process is not taken into account when determining these positions, these positions need to be corrected. In the specific implementation, the perspective matrix corresponding to the virtual camera is determined based on the posture and camera parameters of the virtual camera, and the position coordinates of the determined position are inversely transformed by the perspective matrix to obtain the transformed position coordinates, and the transformed position coordinates are determined as the target position. Then, the required model is generated at the target position. The model can be a bell model, a star model, a sphere model, etc., which is not limited here.
[0037] Step S108, controlling the virtual camera to shoot the multiple virtual models according to the posture and camera parameters.
[0038] After the virtual model is generated, it can be photographed by a virtual camera. When the virtual camera needs to shoot an animation, the position and posture of the virtual camera may change. At this time, it is necessary to redetermine the perspective matrix corresponding to the virtual camera and correct the position of the virtual model based on the redetermined perspective matrix, so that the picture taken by the virtual camera with the changed posture will not be affected by the lens distortion.
[0039] When there are multiple target images, the position of the model corresponding to one or some target images in the virtual space may change during the animation shooting process of the virtual camera, and the model corresponding to the same target image usually moves as a whole. At this time, it is necessary to correct the position of the model after the move based on the perspective matrix, so that the picture containing the moved model taken by the virtual camera will not be affected by the lens distortion.
[0040] The above-mentioned model shooting method in a virtual space obtains a target image; the target image includes a preset mark; based on the preset shooting requirements, the target position corresponding to the target image in the preset virtual space, as well as the posture and camera parameters of the virtual camera in the virtual space are determined; based on the target position and the pixel points constituting the preset mark in the target image, multiple initial positions are determined in the virtual space, and the multiple initial positions are corrected based on the posture and camera parameters of the virtual camera in the virtual space to obtain multiple target positions, and virtual models are generated at each target position so that the display area occupied by the multiple virtual models in the virtual space simulates the shape of the preset mark; according to the posture and camera parameters, the virtual camera is controlled to shoot the multiple virtual models. In this method, the position of the model used to simulate the preset mark is determined based on the position and camera parameters of the virtual camera, and the distortion generated when the camera is shooting is taken into account. When the model is shot by the virtual camera, the distortion phenomenon can be avoided, and the display effect of the model simulating the preset mark in the shot image or video is improved, which improves the game experience of the player.
[0041] The following embodiment provides a specific method for determining multiple initial positions in a virtual space based on a target position and pixel points constituting a preset mark in a target image.
[0042] Assume that the target image includes a first pixel and a second pixel, the first pixel constitutes a preset mark, and the second pixel does not constitute the preset mark and is usually in the background area. The positions of the first pixel and the second pixel can be predetermined or distinguished based on pixel values. For example, if the background color is white or black, the pixel value of the first pixel is 255 or 0, and the pixel value of the first pixel is a value different from the pixel value of the second pixel. At this time, by reading the pixel value of the pixel in the target image, it can be determined whether a certain pixel constitutes a preset mark.
[0043] Usually, a corresponding target position is set for the target image in the virtual space. The initial position of the model in the virtual space can be determined based on the target and the first pixel in the target image. Specifically, after the pixels constituting the preset representation are determined, the target area range can be determined based on the positions of the pixels constituting the preset identifier in the target image. Figure 2As shown, the gray and black squares are the first pixels, the white squares represent the second pixels, and the area where the gray and black squares are located is the target area range. Then, based on the target position and the target area range, the target area in the virtual space is determined. The target position can usually correspond to the center of the target image or to a certain position in the target image, and the orientation of the target image in the virtual space is usually determined. Based on the first position and orientation corresponding to the target image, the target area range is "translated" and "rotated" into the virtual space, and the target area in the virtual space is obtained. Furthermore, it is necessary to determine multiple initial positions in the target area. Multiple initial positions can be determined according to a certain rule, such as determining a position in the target area every set distance from a preset starting point to a set direction, or multiple initial positions can be determined randomly. The specific method is not limited here.
[0044] The following embodiment provides a specific method for correcting multiple initial positions based on the posture of the virtual camera in the virtual space and the camera parameters.
[0045] After determining the initial position, it is necessary to correct the multiple initial positions based on the pose of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera, and then determine the corrected multiple initial positions as multiple target positions. Specifically, first, based on the pose of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera, generate the perspective matrix corresponding to the virtual camera. Among them, the pose of the virtual camera can be represented by two parameters: camera position coordinates and camera rotation matrix. Camera parameters include focal length, aperture, picture width, picture height, near clipping plane parameters and far clipping plane parameters. Among them, the picture width and picture height respectively represent the width and height of the resolution of the captured picture. Based on the above parameters, the perspective matrix corresponding to the virtual camera can be calculated, and then the inverse matrix corresponding to the perspective matrix needs to be generated. Specifically, the perspective matrix can be inversely operated to obtain the corresponding inverse matrix.
[0046] After obtaining the inverse matrix, multiple initial positions need to be corrected based on the inverse matrix. In virtual space, the position in space is usually represented by Cartesian coordinates, and the above initial positions are also represented by Cartesian coordinates. For each initial position, it is necessary to determine the homogeneous coordinates corresponding to the initial position based on the camera parameters of the virtual camera and the Cartesian coordinates corresponding to the initial position.
[0047] Homogeneous coordinates are a commonly used coordinate representation method in computer graphics. This method allows points and vectors to be processed uniformly and can easily perform coordinate transformations such as translation and rotation. In the virtual camera model, the generation of homogeneous coordinates involves several key steps, including defining the camera coordinate system, image plane coordinate system, and image coordinate system, and performing necessary matrix operations through homogeneous coordinate transformation to achieve the conversion from the world coordinate system to the camera coordinate system, and finally mapping it to the image coordinate system. The specific method will not be repeated here.
[0048] After determining the homogeneous coordinates of the initial position, the homogeneous coordinates are multiplied by the inverse matrix to obtain a first multiplication result; then the first multiplication result is converted into Cartesian coordinates, and the position corresponding to the converted Cartesian coordinates is determined as the corrected initial position. The corrected initial position is the desired target position, which means that the correction of the generated position of the model is completed.
[0049] The following embodiment provides a specific method for controlling a virtual camera to shoot multiple virtual models according to posture and camera parameters.
[0050] In the process of controlling the virtual camera to shoot multiple virtual models, in response to the change in the posture of the virtual camera, it is necessary to adjust the positions of the multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera, and then shoot the multiple models with adjusted positions through the virtual camera with the updated posture. The specific adjustment method is similar to the above-mentioned correction method for the initial position. It is necessary to generate an updated perspective matrix based on the updated posture and camera parameters, and generate an updated inverse matrix corresponding to the updated perspective matrix, and further adjust the positions of the multiple virtual models in the virtual space based on the updated inverse matrix.
[0051] In the process of adjusting the model position, it is necessary to update the homogeneous coordinates corresponding to the initial position for each virtual model based on the camera parameters of the virtual camera, the updated posture and the Cartesian coordinates corresponding to the initial position. Then multiply the updated homogeneous coordinates with the updated inverse matrix to obtain a second multiplication result, and convert the second multiplication result into Cartesian coordinates, and then adjust the position of the virtual model to the position corresponding to the Cartesian coordinates in the virtual space. This process is similar to the correction process for the initial position of the virtual model. It is worth noting that the initial position corresponding to the virtual camera needs to be adjusted by the updated inverse matrix, rather than the current position of the virtual camera. If adjustment is required based on the current position, the current position also needs to be restored to the initial position corresponding to the model. The restoration process is the inverse process of the correction process, which will not be repeated here.
[0052] The motion trajectory of the virtual camera can be pre-set. The motion trajectory of the virtual camera causes the posture of the virtual camera to change. When the virtual camera needs to move in the virtual space, the posture of the virtual camera in the virtual space usually includes multiple postures that change in sequence. When the posture of the virtual camera in the virtual space can be predetermined, for each of the multiple postures that change in sequence, multiple initial positions can be corrected based on the posture and the camera parameters of the virtual camera to determine multiple target positions corresponding to the posture. And generate a virtual model at each target position corresponding to the first posture in the multiple postures that change in sequence. Then, during the shooting process, in response to the change in the posture of the virtual camera, control the multiple virtual models to move to each target position corresponding to the changed posture. In this process, when the posture of the virtual camera changes, the position of the model will also change to offset the distortion generated in the picture taken by the virtual camera.
[0053] The disclosed embodiment also provides another method for photographing a model in a virtual space. Figure 1 The method shown in the figure is implemented on the basis of the method shown in the figure to ensure that the model image captured by the camera is as accurate as the input image. This method mainly uses the inverse perspective matrix operation of the model vertices in the model space to restore the accurate effect in the camera.
[0054] The method is mainly implemented through the following steps:
[0055] 1 Generate a dot matrix based on the LOGO image (equivalent to the above-mentioned "target image") information.
[0056] The logo image contains pixel information. The RGBA value of the pixel in the area containing information is greater than 0, and the RGBA value of the pixel in the area without information is equal to 0. Figure 3 As shown. You can create a plane model with the number of vertices equal to the width and height of the image (for example, 1280*720). Use the image loading function of some model making software (such as Houdini) to assign the color of the image pixel to each vertex. Then, based on the color of the vertex, use the code to delete the vertices with the color RGBA value equal to 0. And use the Scatter function that comes with Houdini to randomly generate the position information of the points in the area where the vertices are retained. The dot matrix generated according to the logo image is as follows Figure 4 shown.
[0057] 2Correct the position of each generated vertex.
[0058] First, obtain the camera parameters (equivalent to the above-mentioned "camera parameters"), such as camera position cam_pos, camera rotation cam_rot, focal length focal_length, aperture aperture, picture width width, picture height height, etc.
[0059] Then get the parameters required to calculate the perspective matrix, calculate the aspect ratio based on the image width and image height, and calculate the field of view (FOV) using the following formula:
[0060] fov=2*atan(aperture / (2*focal_length))
[0061] The position of the near clipping plane is calculated using the following formula:
[0062] near=cam_pos.y+0.1
[0063] Among them, the above cam_pos.y represents the y coordinate of the camera position.
[0064] The position of the far clipping plane is calculated using the following formula:
[0065] far=cam_pos.y+10000
[0066] And further create the perspective matrix:
[0067]
[0068] Then, the inverse matrix of the perspective matrix is calculated, and then the homogeneous coordinates of each vertex are converted and multiplied by the inverse perspective matrix, and the multiplied homogeneous coordinates are further converted back to Cartesian coordinates.
[0069] 3. Assign the bell model to the dot matrix to form a model array, such as Figure 5 shown.
[0070] Figure 6 This is the effect of the model presented in the camera without algorithm correction, with obvious lens distortion. Figure 7 This is the result of algorithm correction. The shape of the model on the right matches the shape of the original LOGO image.
[0071] In this method, when a perspective camera must be used to express 2D art effects in a 3D space, it can be ensured that the final image in the camera is as accurate as the input image.
[0072] For the above method embodiments, see Figure 8 A model shooting device in a virtual space is shown, the device comprising:
[0073] The image acquisition module 802 is used to acquire a target image; the target image includes a preset mark;
[0074] The parameter determination module 804 is used to determine the target position corresponding to the target image in the preset virtual space, and the position and camera parameters of the virtual camera in the virtual space based on the preset shooting requirements;
[0075] The model generation module 806 is used to determine a plurality of initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image, correct the plurality of initial positions based on the position and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, and generate a virtual model at each target position so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark;
[0076] The shooting module 808 is used to control the virtual camera to shoot multiple virtual models according to the posture and camera parameters.
[0077] The above-mentioned model shooting device in a virtual space obtains a target image; the target image includes a preset mark; based on the preset shooting requirements, the target position corresponding to the target image in the preset virtual space, as well as the posture and camera parameters of the virtual camera in the virtual space are determined; based on the target position and the pixel points constituting the preset mark in the target image, multiple initial positions are determined in the virtual space, and the multiple initial positions are corrected based on the posture and camera parameters of the virtual camera in the virtual space to obtain multiple target positions, and virtual models are generated at each target position so that the display area occupied by the multiple virtual models in the virtual space simulates the shape of the preset mark; according to the posture and camera parameters, the virtual camera is controlled to shoot the multiple virtual models. In this method, the position of the model used to simulate the preset mark is determined based on the position and camera parameters of the virtual camera, and the distortion generated when the camera is shooting is taken into account. When the model is shot by the virtual camera, the distortion phenomenon can be avoided, and the display effect of the model simulating the preset mark in the shot image or video is improved, which improves the game experience of the player.
[0078] The above-mentioned model generation module is also used to: determine the scope of the target area based on the position of the pixel points constituting the preset mark in the target image; determine the target area in the virtual space based on the target position and the scope of the target area; and determine multiple initial positions in the target area.
[0079] The above-mentioned model generation module is also used to: generate a perspective matrix corresponding to the virtual camera based on the position of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera; generate an inverse matrix corresponding to the perspective matrix; and correct multiple initial positions based on the inverse matrix.
[0080] The above-mentioned initial position is represented by Cartesian coordinates; the above-mentioned model generation module is also used to: for each initial position, based on the camera parameters, posture of the virtual camera and the Cartesian coordinates corresponding to the initial position, determine the homogeneous coordinates corresponding to the initial position; multiply the homogeneous coordinates with the inverse matrix to obtain a first multiplication result; convert the first multiplication result into Cartesian coordinates, and determine the position corresponding to the converted Cartesian coordinates as the corrected initial position.
[0081] The above-mentioned shooting module is also used for: during the shooting process, in response to changes in the posture of the virtual camera, adjusting the positions of multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera; and shooting the multiple models with adjusted positions through the virtual camera with updated posture.
[0082] The above-mentioned shooting module is also used to: update the perspective matrix corresponding to the virtual camera based on the updated posture and camera parameters of the virtual camera, generate an updated inverse matrix corresponding to the updated perspective matrix; and adjust the positions of multiple virtual models in the virtual space based on the updated inverse matrix.
[0083] The above-mentioned shooting module is also used to: for each virtual model, based on the camera parameters of the virtual camera, the updated posture and the Cartesian coordinates corresponding to the initial position, update the homogeneous coordinates corresponding to the initial position; multiply the updated homogeneous coordinates with the updated inverse matrix to obtain a second multiplication result; convert the second multiplication result into Cartesian coordinates, and adjust the position of the virtual model to the position corresponding to the Cartesian coordinates in the virtual space.
[0084] The posture of the virtual camera in the virtual space includes multiple postures that change in sequence; the model generation module is also used to: for each of the multiple postures that change in sequence, correct multiple initial positions based on the posture and camera parameters of the virtual camera, and determine multiple target positions corresponding to the posture; generate a virtual model at each target position corresponding to the first posture among the multiple postures that change in sequence; the shooting module is also used to: in response to the change in the posture of the virtual camera, control the multiple virtual models to move to each target position corresponding to the changed posture.
[0085] This embodiment further provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned model shooting method in the virtual space, for example:
[0086] Acquire a target image; the target image includes a preset mark; based on a preset shooting requirement, determine a target position corresponding to the target image in a preset virtual space, as well as a position and camera parameters of a virtual camera in the virtual space; based on the target position and the pixel points constituting the preset mark in the target image, determine a plurality of initial positions in the virtual space, correct the plurality of initial positions based on the position and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, generate a virtual model at each target position, so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; according to the position and camera parameters, control the virtual camera to shoot the plurality of virtual models.
[0087] In the above method, the position of the model used to simulate the preset logo is determined based on the position of the virtual camera and the camera parameters, taking into account the distortion caused by the camera shooting. When the model is photographed by the virtual camera, the distortion phenomenon can be avoided, thereby improving the display effect of the model simulating the preset logo in the captured image or video, and enhancing the player's gaming experience.
[0088] Optionally, the above-mentioned step of determining multiple initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image includes: determining the scope of the target area based on the position of the pixel points constituting the preset mark in the target image; determining the target area in the virtual space based on the target position and the target area scope; and determining multiple initial positions in the target area.
[0089] Optionally, the above-mentioned step of correcting multiple initial positions based on the posture of the virtual camera in the virtual space and camera parameters includes: generating a perspective matrix corresponding to the virtual camera based on the posture of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera; generating an inverse matrix corresponding to the perspective matrix; and correcting multiple initial positions based on the inverse matrix.
[0090] Optionally, the above-mentioned initial position is represented by Cartesian coordinates; the step of correcting multiple initial positions based on the inverse matrix includes: for each initial position, based on the camera parameters, posture of the virtual camera and the Cartesian coordinates corresponding to the initial position, determining the homogeneous coordinates corresponding to the initial position; multiplying the homogeneous coordinates with the inverse matrix to obtain a first multiplication result; converting the first multiplication result into Cartesian coordinates, and determining the position corresponding to the converted Cartesian coordinates as the corrected initial position.
[0091] Optionally, the above-mentioned step of controlling the virtual camera to shoot multiple virtual models according to the posture and camera parameters includes: during the shooting process, in response to the change of the posture of the virtual camera, adjusting the positions of the multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera; and shooting the multiple models with the adjusted positions by the virtual camera with the updated posture.
[0092] Optionally, the step of adjusting the positions of multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera includes: updating the perspective matrix corresponding to the virtual camera based on the updated posture and camera parameters of the virtual camera, and generating an updated inverse matrix corresponding to the updated perspective matrix; and adjusting the positions of multiple virtual models in the virtual space based on the updated inverse matrix.
[0093] Optionally, the step of adjusting the positions of multiple virtual models in the virtual space based on the updated inverse matrix includes: for each virtual model, updating the homogeneous coordinates corresponding to the initial position based on the camera parameters of the virtual camera, the updated posture and the Cartesian coordinates corresponding to the initial position; multiplying the updated homogeneous coordinates with the updated inverse matrix to obtain a second multiplication result; converting the second multiplication result into Cartesian coordinates, and adjusting the position of the virtual model to the position corresponding to the Cartesian coordinates in the virtual space.
[0094] Optionally, the posture of the virtual camera in the virtual space includes multiple postures that change in sequence; based on the posture of the virtual camera in the virtual space and camera parameters, multiple initial positions are corrected, and a virtual model is generated at each target position, including: for each posture in the multiple successively changing postures, based on the posture and camera parameters of the virtual camera, multiple initial positions are corrected to determine multiple target positions corresponding to the posture; a virtual model is generated at each target position corresponding to the first posture in the multiple successively changing postures; according to the posture and camera parameters, the virtual camera is controlled to shoot multiple virtual models, including: in response to the change in the posture of the virtual camera, the multiple virtual models are controlled to move to each target position corresponding to the changed posture.
[0095] See also Fig. 9 As shown, the electronic device includes a processor 100 and a memory 101, wherein the memory 101 stores machine executable instructions that can be executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the above-mentioned model shooting method in the virtual space.
[0096] Further, Fig. 9 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0097] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0098] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0099] This embodiment also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned model shooting method in the virtual space.
[0100] The embodiments of the present disclosure provide a method, device, and electronic device for photographing a model in a virtual space, including a computer-readable storage medium storing program codes, wherein the program codes include instructions that can be used to execute the methods described in the foregoing method embodiments, for example:
[0101] Acquire a target image; the target image includes a preset mark; based on a preset shooting requirement, determine a target position corresponding to the target image in a preset virtual space, as well as a position and camera parameters of a virtual camera in the virtual space; based on the target position and the pixel points constituting the preset mark in the target image, determine a plurality of initial positions in the virtual space, correct the plurality of initial positions based on the position and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, generate a virtual model at each target position, so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; according to the position and camera parameters, control the virtual camera to shoot the plurality of virtual models.
[0102] In the above method, the position of the model used to simulate the preset logo is determined based on the position of the virtual camera and the camera parameters, taking into account the distortion caused by the camera shooting. When the model is photographed by the virtual camera, the distortion phenomenon can be avoided, thereby improving the display effect of the model simulating the preset logo in the captured image or video, and enhancing the player's gaming experience.
[0103] Optionally, the above-mentioned step of determining multiple initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image includes: determining the scope of the target area based on the position of the pixel points constituting the preset mark in the target image; determining the target area in the virtual space based on the target position and the target area scope; and determining multiple initial positions in the target area.
[0104] Optionally, the above-mentioned step of correcting multiple initial positions based on the posture of the virtual camera in the virtual space and camera parameters includes: generating a perspective matrix corresponding to the virtual camera based on the posture of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera; generating an inverse matrix corresponding to the perspective matrix; and correcting multiple initial positions based on the inverse matrix.
[0105] Optionally, the above-mentioned initial position is represented by Cartesian coordinates; the step of correcting multiple initial positions based on the inverse matrix includes: for each initial position, based on the camera parameters, posture of the virtual camera and the Cartesian coordinates corresponding to the initial position, determining the homogeneous coordinates corresponding to the initial position; multiplying the homogeneous coordinates with the inverse matrix to obtain a first multiplication result; converting the first multiplication result into Cartesian coordinates, and determining the position corresponding to the converted Cartesian coordinates as the corrected initial position.
[0106] Optionally, the above-mentioned step of controlling the virtual camera to shoot multiple virtual models according to the posture and camera parameters includes: during the shooting process, in response to the change of the posture of the virtual camera, adjusting the positions of the multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera; and shooting the multiple models with the adjusted positions by the virtual camera with the updated posture.
[0107] Optionally, the step of adjusting the positions of multiple virtual models in the virtual space based on the updated posture and camera parameters of the virtual camera includes: updating the perspective matrix corresponding to the virtual camera based on the updated posture and camera parameters of the virtual camera, and generating an updated inverse matrix corresponding to the updated perspective matrix; and adjusting the positions of multiple virtual models in the virtual space based on the updated inverse matrix.
[0108] Optionally, the step of adjusting the positions of multiple virtual models in the virtual space based on the updated inverse matrix includes: for each virtual model, updating the homogeneous coordinates corresponding to the initial position based on the camera parameters of the virtual camera, the updated posture and the Cartesian coordinates corresponding to the initial position; multiplying the updated homogeneous coordinates with the updated inverse matrix to obtain a second multiplication result; converting the second multiplication result into Cartesian coordinates, and adjusting the position of the virtual model to the position corresponding to the Cartesian coordinates in the virtual space.
[0109] Optionally, the posture of the virtual camera in the virtual space includes multiple postures that change in sequence; based on the posture of the virtual camera in the virtual space and camera parameters, multiple initial positions are corrected, and a virtual model is generated at each target position, including: for each posture in the multiple successively changing postures, based on the posture and camera parameters of the virtual camera, multiple initial positions are corrected to determine multiple target positions corresponding to the posture; a virtual model is generated at each target position corresponding to the first posture in the multiple successively changing postures; according to the posture and camera parameters, the virtual camera is controlled to shoot multiple virtual models, including: in response to the change in the posture of the virtual camera, the multiple virtual models are controlled to move to each target position corresponding to the changed posture.
[0110] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0111] In addition, in the description of the embodiments of the present disclosure, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances.
[0112] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0113] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present disclosure. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0114] Finally, it should be noted that the above embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above embodiments, those skilled in the art should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for photographing a model in a virtual space, characterized in that: The method comprises: Acquire a target image; the target image includes a preset mark; Based on preset shooting requirements, determine a target position corresponding to the target image in a preset virtual space, as well as a position and camera parameters of a virtual camera in the virtual space; Based on the target position and the pixel points constituting the preset mark in the target image, a plurality of initial positions are determined in the virtual space, the plurality of initial positions are corrected based on the posture and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, and a virtual model is generated at each target position so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; According to the posture and the camera parameters, the virtual camera is controlled to shoot the multiple virtual models.
2. The method according to claim 1, characterized in that: The step of determining a plurality of initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image comprises: Determine the range of the target area based on the positions of the pixels constituting the preset mark in the target image; Determining a target area in the virtual space based on the target position and the target area range; A plurality of initial positions are determined in the target area.
3. The method according to claim 2, characterized in that The step of correcting the multiple initial positions based on the posture and camera parameters of the virtual camera in the virtual space includes: Generate a perspective matrix corresponding to the virtual camera based on the position of the virtual camera in the virtual space and the camera parameters corresponding to the virtual camera; Generate an inverse matrix corresponding to the perspective matrix; The multiple initial positions are corrected based on the inverse matrix.
4. The method according to claim 3, characterized in that The initial position is represented by Cartesian coordinates; The step of correcting the multiple initial positions based on the inverse matrix comprises: For each of the initial positions, based on camera parameters of the virtual camera, the position and the Cartesian coordinates corresponding to the initial position, determine the homogeneous coordinates corresponding to the initial position; Multiplying the homogeneous coordinates by the inverse matrix to obtain a first multiplication result; The first multiplication result is converted into Cartesian coordinates, and the position corresponding to the converted Cartesian coordinates is determined as the corrected initial position.
5. The method according to claim 1, characterized in that: The step of controlling the virtual camera to shoot the plurality of virtual models according to the posture and the camera parameters comprises: During the shooting process, in response to a change in the posture of the virtual camera, adjusting the positions of the plurality of virtual models in the virtual space based on the updated posture of the virtual camera and the camera parameters; The multiple models after position adjustment are photographed through the virtual camera with updated posture.
6. The method according to claim 5, characterized in that The step of adjusting the positions of the plurality of virtual models in the virtual space based on the updated position and the camera parameters of the virtual camera comprises: Based on the updated position and posture of the virtual camera and the camera parameters, updating the perspective matrix corresponding to the virtual camera, and generating an updated inverse matrix corresponding to the updated perspective matrix; Based on the updated inverse matrix, the positions of the plurality of virtual models in the virtual space are adjusted.
7. The method according to claim 6, characterized in that The step of adjusting the positions of the plurality of virtual models in the virtual space based on the updated inverse matrix comprises: For each of the virtual models, based on the camera parameters of the virtual camera, the updated posture and the Cartesian coordinates corresponding to the initial position, updating the homogeneous coordinates corresponding to the initial position; Multiplying the updated homogeneous coordinates by the updated inverse matrix to obtain a second multiplication result; The second multiplication result is converted into Cartesian coordinates, and the position of the virtual model is adjusted to a position corresponding to the Cartesian coordinates in the virtual space.
8. The method according to claim 1, characterized in that The position and posture of the virtual camera in the virtual space includes a plurality of position and postures that change sequentially; The step of correcting the multiple initial positions based on the position and camera parameters of the virtual camera in the virtual space and generating a virtual model at each target position includes: For each of the plurality of successively changing postures, correcting the plurality of initial positions based on the posture and camera parameters of the virtual camera, and determining a plurality of target positions corresponding to the posture; Generate a virtual model at each target position corresponding to the first posture among the plurality of successively changing postures; The step of controlling the virtual camera to shoot the plurality of virtual models according to the posture and the camera parameters comprises: In response to a change in the position and posture of the virtual camera, the plurality of virtual models are controlled to move to respective target positions corresponding to the changed position and posture.
9. A model shooting device in a virtual space, characterized in that: The device comprises: An image acquisition module, used to acquire a target image; the target image includes a preset mark; A parameter determination module, used to determine a target position corresponding to the target image in a preset virtual space, and a position and camera parameters of a virtual camera in the virtual space based on preset shooting requirements; A model generation module, configured to determine a plurality of initial positions in the virtual space based on the target position and the pixel points constituting the preset mark in the target image, correct the plurality of initial positions based on the posture and camera parameters of the virtual camera in the virtual space to obtain a plurality of target positions, and generate a virtual model at each target position so that the display area occupied by the plurality of virtual models in the virtual space simulates the shape of the preset mark; A shooting module is used to control the virtual camera to shoot the multiple virtual models according to the posture and the camera parameters.
10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the model shooting method in the virtual space described in any one of claims 1-8.
11. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions prompt the processor to implement the model shooting method in the virtual space described in any one of claims 1-8.