A code verification method and apparatus
By generating real-time rendered video streams and performing trajectory error analysis, the problem of not being able to verify the actual visual effects of code in existing technologies is solved, ensuring that the motion trajectory of virtual objects conforms to the design intent and improving the reliability and efficiency of 3D game development.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, automated programming agents can only verify the theoretical correctness of the code, but cannot guarantee whether the actual visual effect after the code runs in the 3D rendering engine meets the requirements, causing the motion trajectory of virtual objects to deviate from the design intent.
By acquiring the code to be tested and generating a real-time rendered video stream, a trajectory estimation algorithm is used to compare the expected trajectory with the actual trajectory to perform trajectory error analysis, ensuring that the motion trajectory of the virtual object conforms to the design intent.
It enables visual verification of code generated by automated programming, improves the accuracy and repeatability of code verification, ensures that the movement trajectory of virtual objects conforms to the design intent, and enhances the reliability and efficiency of 3D game development.
Smart Images

Figure CN120929354B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of code verification technology, and in particular to a code verification method and apparatus. Background Technology
[0002] With the rapid development of artificial intelligence technology (especially Large Language Modeling (LLM)), automated programming has become an important research direction in the field of software development. For example, in the development of 3D games, developers can use natural language instructions (such as "create a camera movement that rotates around the game's main character" or "have a non-player character patrol along the lake") to drive an automated programming agent to generate code that controls the movement of virtual cameras or non-player characters. Automated programming technology enables end-to-end automated generation from high-level design intent to concrete code.
[0003] In current technology, after generating code to control the movement of virtual cameras or non-player characters through automated programming techniques, the automated programming agent usually verifies the syntax and logic of the code through its own logic, such as whether the generated code conforms to programming standards and whether there are any syntax errors.
[0004] However, the way that automated programming agents in current technology verify code can only verify the theoretical correctness of the code, and cannot guarantee that the actual visual effect after the code runs will meet the requirements, thus ruining the visual effect. Summary of the Invention
[0005] To address the aforementioned issues, this application provides a code verification method and apparatus. By running the code under test to generate a real-time rendered video stream to obtain the actual trajectory, and performing error analysis on the expected trajectory and the actual trajectory, the method achieves visual effect verification of the code generated by automated programming. This effectively solves the problem that existing technologies can only verify the theoretical correctness of the code but cannot guarantee the actual running effect, thereby ensuring that the motion trajectory of the virtual object conforms to the design intent.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] In a first aspect, embodiments of this application provide a code verification method, including:
[0008] Obtain the code to be tested; wherein the code to be tested is used to control the target virtual object to run according to the expected trajectory;
[0009] Run the code to be tested to obtain a video stream corresponding to the code to be tested; wherein, the video stream includes: a series of real-time rendered frames;
[0010] Using a trajectory estimation algorithm, the actual trajectory of the target virtual object is obtained based on the real-time rendered images of multiple consecutive frames included in the video stream;
[0011] Trajectory error analysis is performed on the actual trajectory and the expected trajectory to obtain code verification results.
[0012] In one possible implementation, when the target virtual object is a virtual camera, the step of using a trajectory estimation algorithm to obtain the actual trajectory of the target virtual object based on the continuous multi-frame real-time rendered images includes:
[0013] Extract feature points of the static background from the continuous multi-frame real-time rendered images;
[0014] Using the Simultaneous Localization and Mapping (SLAM) algorithm, based on the feature points of the static background, the actual pose sequence of the target virtual camera in three-dimensional space is calculated in reverse.
[0015] Based on the actual pose sequence, the actual trajectory of the target virtual camera is constructed.
[0016] In one possible implementation, when the target virtual object is a virtual entity, the step of using a trajectory estimation algorithm to obtain the actual trajectory of the target virtual object based on the continuous multi-frame real-time rendered images includes:
[0017] From the continuous multi-frame real-time rendered images, feature points of the static background are extracted, and the SLAM algorithm is used to reverse calculate the actual pose sequence of the virtual camera in three-dimensional space based on the feature points of the static background.
[0018] Using an object detection model, the bounding box of the target virtual entity is identified and located in the real-time rendering of the consecutive multiple frames;
[0019] Based on the actual pose sequence, the displacement of the bounding box of the target virtual entity caused by the movement of the virtual camera is compensated to obtain the actual position sequence of the bounding box of the target virtual entity; wherein, the actual position sequence is a two-dimensional coordinate sequence;
[0020] Based on the actual location sequence, the actual trajectory of the target virtual entity is constructed.
[0021] In one possible implementation, when the consecutive multi-frame real-time rendered images have corresponding depth maps, constructing the actual trajectory of the target virtual entity based on the actual position sequence includes:
[0022] From the depth maps corresponding to the real-time rendering frames of the consecutive frames, the depth values corresponding to the center point of the bounding box of the target virtual entity are extracted to obtain a depth value sequence.
[0023] Based on the real-time position sequence and depth value sequence, combined with the intrinsic parameters of the virtual camera, the three-dimensional coordinate sequence of the target virtual entity is obtained by back projection;
[0024] Based on the three-dimensional coordinate sequence, the actual trajectory of the target virtual entity is constructed.
[0025] In one possible implementation, when the consecutive multi-frame real-time rendered images do not have corresponding depth maps, constructing the actual trajectory of the target virtual entity based on the actual position sequence includes:
[0026] By utilizing the geometric relationships of multi-view images, the actual trajectory of the target virtual entity is constructed based on the actual position sequence.
[0027] In one possible implementation, the step of performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain code verification results includes:
[0028] Calculate the trajectory error between the actual trajectory and the expected trajectory; wherein the trajectory error includes at least one of: absolute trajectory error and relative attitude error;
[0029] Determine whether the trajectory error is less than a preset trajectory error threshold;
[0030] When the trajectory error is less than the preset trajectory error threshold, the code verification result is "verification passed".
[0031] If the trajectory error is not less than the preset trajectory error threshold, the code verification result is "verification failed".
[0032] In one possible implementation, after performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain code verification results, the method further includes:
[0033] When the code verification result is that the verification fails, the code to be tested is corrected through automated programming based on the trajectory error to obtain the corrected code to be tested, and the corrected code to be tested is run repeatedly to obtain the code verification result.
[0034] In one possible implementation, after performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain code verification results, the method further includes:
[0035] When the code verification result is successful, the code to be tested is determined to be the target code and output.
[0036] In one possible implementation, after performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain code verification results, the method further includes:
[0037] Based on the trajectory error, the preset trajectory error threshold, and the code verification result, a verification report corresponding to the code to be tested is generated.
[0038] Secondly, embodiments of this application provide a code verification device, including:
[0039] The code acquisition module is used to acquire the code to be tested; wherein the code to be tested is used to control the target virtual object to run according to the expected trajectory;
[0040] The image acquisition module is used to run the code under test and acquire the video stream corresponding to the code under test; wherein, the video stream includes: a series of real-time rendered images;
[0041] The trajectory construction module is used to obtain the actual trajectory of the target virtual object based on the real-time rendering of the continuous multi-frame images using a trajectory estimation algorithm.
[0042] The code verification module is used to perform trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result.
[0043] Compared with the prior art, this application has the following beneficial effects: by running the code under test to generate a real-time rendered video stream, and comparing the expected trajectory with the actual trajectory based on the trajectory estimation algorithm, the visual effect verification of the code under test is realized, which effectively solves the problem that the prior art can only verify the theoretical correctness of the code but cannot guarantee the actual running effect, thereby ensuring that the motion trajectory of the virtual object conforms to the design intent. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 A flowchart illustrating a code verification method provided in an embodiment of this application;
[0046] Figure 2 A schematic diagram illustrating the process of obtaining the actual trajectory of the target virtual camera as provided in an embodiment of this application;
[0047] Figure 3 A flowchart illustrating the process of obtaining the actual trajectory of the target virtual entity as provided in this embodiment of the application;
[0048] Figure 4 An example diagram of a verification report provided for an embodiment of this application;
[0049] Figure 5 This is a schematic diagram of the structure of a code verification device provided in an embodiment of this application. Detailed Implementation
[0050] As described earlier, automated programming refers to the process of automatically generating, validating, or optimizing code based on high-level instructions (such as natural language descriptions, design intent, or mathematical models) using artificial intelligence (especially Large Language Modeling, LLM), rule engines, or algorithms. Its core goal is to improve development efficiency, consistency, and code quality by replacing or assisting repetitive and patterned tasks in traditional programming through technological means.
[0051] In modern 3D interactive content development, especially in game engines (such as Unity and Unreal Engine), virtual production, digital twins, and metaverse applications, developers typically need to write numerous scripts to control dynamic behaviors in virtual worlds. Traditional development workflows rely on programmers manually writing code to implement the movement trajectories of virtual cameras or non-player characters. This process is not only time-consuming and labor-intensive but also presents a high barrier to entry for designers without a programming background. Automated programming addresses the shortcomings of traditional programming by automatically generating code to control the movement of virtual cameras or non-player characters based on natural language instructions, achieving end-to-end automated generation from high-level design intent to concrete code.
[0052] In current technologies, after code is generated using automated programming techniques, the automated programming agent typically performs self-checks on the generated code. This involves semantic analysis and logical reasoning to verify the syntax and logic of the code. However, this self-check only ensures the generated code is syntactically correct; it cannot verify whether the actual visual effects produced when running in a complex 3D rendering engine meet the requirements. For example, the generated code might be logically correct, but incorrect rendering parameters, physical collision interference, or other script conflicts could cause the virtual object's trajectory to deviate from the requirements. In other words, the automated programming agent's self-check can only verify the theoretical correctness of the code; it cannot guarantee that the actual visual effects after execution will meet the requirements, and there may even be cases where the code is logically correct but the visual effects are incorrect.
[0053] Furthermore, besides automated programming agents performing self-checks, current technologies involve developers running code generated by automated programming and then manually observing the actual visual effects produced when the code runs in the rendering engine to verify if they meet the requirements. However, manually observing the actual visual effects when running the code to verify it relies heavily on subjective human experience and cannot guarantee the accuracy and repeatability of code verification.
[0054] This application provides a code verification method, including: acquiring the code to be tested; running the code to be tested to acquire a video stream corresponding to the code; using a trajectory estimation algorithm, based on real-time rendering of multiple consecutive frames included in the video stream, to obtain the actual trajectory of the target virtual object; and performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result. In this application, by running the code to be tested to generate a real-time rendered video stream, and comparing the expected trajectory with the actual trajectory based on the trajectory estimation algorithm, the visual effect verification of the code to be tested is achieved. This effectively solves the problem that existing technologies can only verify the theoretical correctness of code but cannot guarantee the actual running effect, ensuring that the motion trajectory of the virtual object conforms to the design intent, thereby improving the reliability and development efficiency of automated programming in 3D game development. Furthermore, it eliminates the need for manual visual observation of whether the actual visual effect produced by the code during runtime in the rendering engine meets the requirements, improving the accuracy and repeatability of code verification.
[0055] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0056] Example 1:
[0057] The following is combined Figures 1-4 This application provides a detailed description of a code verification method based on its embodiments.
[0058] like Figure 1 As shown in the figure, a code verification method provided in this application includes the following steps:
[0059] S101. Obtain the code to be tested.
[0060] The code under test is used to control the target virtual object to run according to the expected trajectory.
[0061] Virtual objects refer to dynamic objects controlled by code in three-dimensional (3D) applications (such as 3D games or simulated scenes). In the embodiments of this application, virtual objects mainly include two types: virtual cameras and virtual entities.
[0062] A virtual camera is a tool that uses software or hardware to simulate the functions of a real camera to generate visual effects (such as 2D rendered images or 3D panoramic images) in a virtual environment. Virtual cameras can simulate the parameters (such as focal length, aperture, and shutter speed) and motion trajectories (such as smooth panning and zooming).
[0063] A virtual entity is a mathematical model representing a user, role, or object in a virtual environment. It typically includes geometric shape, physical properties, and interaction logic. Specifically, virtual entities are virtual dynamic objects (such as non-player character NPCs, virtual vehicles, etc.), and virtual entities can simulate real-world behavior through algorithms.
[0064] The expected trajectory refers to the parameterized running path of the target virtual object in three-dimensional space. Simply put, the expected trajectory is a three-dimensional running trajectory. For example, the expected trajectory includes the dynamic changes in position and attitude.
[0065] In one possible implementation, the code under test is obtained by generating the corresponding expected trajectory and the code under test that controls the target virtual object to run according to the expected trajectory through automated programming in response to input instructions.
[0066] Input instructions refer to high-level natural language descriptions provided by the user or system to describe / define the operational requirements of the target virtual object. Input instructions do not include specific code implementation details, but rather describe / define the behavioral goals or visual effects of the target virtual object. For example, the input instruction could be: "Create a shot that rapidly advances from the castle gate to the throne, with slight shaking."
[0067] Specifically, an automated programming agent responds to input commands (i.e., high-level commands) to determine the expected trajectory corresponding to the input command; and based on the expected trajectory, generates test code to control the virtual object of the target. Path planning, velocity curves, and attitude adjustments are performed based on the key elements indicated by the input command to construct the expected trajectory corresponding to the input command; and based on the expected trajectory, test code to control the virtual object of the target is generated.
[0068] In this context, an Automated Programming Agent refers to a tool or system that implements automated programming techniques. For example, an Automated Programming Agent can be an AI programming agent.
[0069] For example, an automated programming agent can parse input instructions to obtain the key elements of the input instructions. The key elements include at least the target virtual object and the running objective. Further key elements may include constraints. For example, if the input instruction is "make the NPC patrol along the lake", then the key elements of the parsed input instruction include: the target virtual object is "NPC", the running objective is "patrol along the lake", and the constraint is "avoid obstacles and maintain a steady speed".
[0070] S102. Run the code to be tested and obtain the video stream corresponding to the code to be tested.
[0071] Video streams include: a series of consecutive, real-time rendered frames. A video stream (Video Streaming) refers to a continuously transmitted sequence of images (frames), characterized by its real-time and continuous nature.
[0072] Specifically, the code under test is loaded and run in the test framework, and the rendering engine is called to output a series of real-time rendered images corresponding to the code under test. The series of real-time rendered images constitute a video stream corresponding to the code under test.
[0073] The testing framework provides a standardized set of rules, tools, and interfaces for loading and running the code under test.
[0074] The rendering engine is used to convert 3D models or scene data (such as geometry, materials, and lighting) into realistic 2D images or videos. In this embodiment, the rendering engine is used to render multiple consecutive real-time frames of images corresponding to the code under test.
[0075] In one possible implementation, the rendering engine is invoked to output a series of real-time rendered frames corresponding to the code under test at a fixed frequency.
[0076] S103. Using a trajectory estimation algorithm, based on real-time rendering of multiple consecutive frames, the actual trajectory of the target virtual object is obtained.
[0077] Trajectory estimation algorithms are a technique for modeling and predicting the motion state (position, attitude, velocity, etc.) of a target virtual object based on a video stream. In this embodiment, the trajectory estimation algorithm is used to infer the actual trajectory of the target virtual object in three-dimensional space from the real-time rendered images of multiple consecutive frames in the video stream obtained by running the code under test.
[0078] The actual trajectory refers to the actual running trajectory of the target virtual object in three-dimensional space when the code under test is actually executed. Simply put, the actual trajectory is a three-dimensional running trajectory.
[0079] In this application embodiment, depending on the type of the target virtual object, the method of obtaining the actual trajectory of the target virtual object is divided into two types, which are described below in conjunction with... Figure 2 and Figure 3 This section introduces how to obtain the actual trajectory of the target virtual object when the target virtual object is a virtual camera and a virtual entity, respectively.
[0080] First, combine Figure 2 This section details how to obtain the actual trajectory of a virtual camera when the target virtual object is a virtual camera.
[0081] S201. Extract feature points of the static background from multiple consecutive frames of real-time rendered images.
[0082] In this context, static background refers to elements that remain relatively unchanged across multiple frames of real-time rendering. Examples include buildings, roads, and trees in outdoor scenes. Static backgrounds remain constant or change very little across multiple frames, thus providing a reference coordinate system for the virtual camera.
[0083] Feature points refer to local areas in a real-time rendered image that possess unique properties and can be reliably detected, such as corner points (e.g., the corners of buildings, intersections), edge points (e.g., the edges of walls, the boundaries of roads), and texture points (e.g., the texture of brick walls, the patterns on the ground). Feature points exhibit stability and robustness.
[0084] In general, feature points of a static background refer to local regions in a real-time rendered image that possess unique properties and can be reliably detected for identifying static backgrounds. These feature points are considered "landmarks" in the environment, used to estimate the actual trajectory of the virtual camera.
[0085] Specifically, from multiple consecutive frames of real-time rendered footage, static backgrounds and virtual objects (i.e., virtual dynamic objects) are separated, retaining only the static background area to avoid interference from virtual objects in feature point extraction. Feature points of the static background are then extracted from the static background area in the multiple consecutive frames of real-time rendered footage using a feature point detection algorithm. For example, feature point detection algorithms include: Fast Feature Detector (FAST) and Scale-Invariant Feature Transform (SIFT).
[0086] S202. Using the simultaneous localization and mapping algorithm, based on the feature points of the static background, the actual pose sequence of the target virtual camera in three-dimensional space is calculated in reverse.
[0087] Simultaneous Localization and Mapping (SLAM) algorithms refer to algorithms that enable robots or mobile devices to simultaneously perform self-localization and environmental mapping in an unknown environment. In this embodiment, the mobile device in the SLAM algorithm refers to a virtual camera. For example, the SLAM algorithm can be an ORB-SLAM algorithm, i.e., a SLAM algorithm that relies on ORB features. Specifically, the SLAM algorithm uses a closed-loop process of perception-mapping-optimization to reverse-calculate the actual pose sequence of the target virtual camera in three-dimensional space.
[0088] The actual pose sequence refers to the record of the virtual camera's position and orientation in three-dimensional space as it changes over time, typically represented as 6 degrees of freedom parameters per frame. In this embodiment, the actual pose sequence of the virtual camera in three-dimensional space is used to reflect the virtual camera's trajectory in a series of consecutive rendered frames.
[0089] Specifically, feature points of the static background in multiple consecutive real-time rendered frames are associated to form feature point pairs; using the feature point pairs, the relative motion (rotation and translation) of the target virtual camera is calculated through epipolar geometry; and the actual pose sequence of the target virtual camera is decomposed using an essential matrix or a fundamental matrix.
[0090] S203. Based on the actual pose sequence, construct the actual trajectory of the target virtual camera.
[0091] In one possible implementation, the actual pose sequence is interpolated to generate a smooth, continuous trajectory as the actual trajectory of the target virtual camera.
[0092] The above combination Figure 2 This section describes in detail how to obtain the actual trajectory of a virtual target object when the target virtual object is a virtual camera. The following section will combine... Figure 3 This section details how to obtain the actual trajectory of a virtual entity when the target virtual object is a virtual entity.
[0093] S301. Extract feature points of the static background from multiple consecutive real-time rendered frames, and use the SLAM algorithm to reverse calculate the actual pose sequence of the virtual camera in three-dimensional space based on the feature points of the static background.
[0094] It should be noted that S301 and Figure 2 The S201-S202 shown are the same. For details on the specific implementation of S301, please refer to [link / reference]. Figure 2 The specific implementation methods of S201-S202 shown will not be elaborated here.
[0095] S302. Using an object detection model, identify and locate the bounding box of the target virtual entity in a series of real-time rendered frames.
[0096] Object detection is a computer vision technique that uses neural networks to classify and locate objects in images or videos. In this embodiment, the object detection model is used to classify and locate virtual entities in a video stream and identify target virtual entities. Examples of object detection models include R-CNN and YOLOv5-lite models.
[0097] In one possible implementation, a lightweight object detection model is used to identify and locate the bounding boxes of virtual target entities in real-time rendering of multiple consecutive frames.
[0098] In this context, a bounding box is a simplified geometric shape that approximates a complex geometric object. It replaces a complex object with a slightly larger but computationally simple shape, allowing for quick determination of relationships between objects. In this embodiment, the bounding box of the target virtual entity refers to a shape that replaces the target virtual entity with a slightly larger but computationally simple shape.
[0099] In one possible implementation, the bounding box is represented as an axis-aligned bounding box (AABB), which is the coordinates of the top-left and bottom-right corners of the rectangle. For example, the bounding box of the target virtual entity (such as an NPC) is [120, 150, 200, 250], to represent the range of the target virtual entity's position in the real-time rendered screen.
[0100] In this embodiment of the application, by identifying and locating the bounding box of the target virtual entity, the amount of computation and computational complexity of generating the actual trajectory can be effectively reduced.
[0101] S303. Based on the actual pose sequence, compensate for the displacement of the bounding box of the target virtual entity caused by the movement of the virtual camera, and obtain the actual position sequence of the bounding box of the target virtual entity.
[0102] The actual position sequence is a two-dimensional coordinate sequence.
[0103] Specifically, based on the actual pose sequence of the virtual camera, the pose difference of the virtual camera in the real-time rendering of multiple consecutive frames is analyzed; the relative displacement of the bounding box of the target virtual entity caused by the movement of the virtual camera is compensated according to the pose difference, thereby obtaining the actual position sequence of the bounding box of the target virtual entity.
[0104] During the movement of the virtual camera, the bounding box of the target virtual entity will experience visual displacement due to changes in the virtual camera's viewpoint. However, this visual displacement caused by changes in the virtual camera's viewpoint is not considered displacement of the bounding box itself. For example, when the virtual camera moves forward, the bounding box of the target virtual entity may move backward in the real-time rendered image; when the virtual camera rotates, the bounding box of the target virtual entity may shift (projection change) in the image. Therefore, in this embodiment, the actual position sequence of the bounding box of the target virtual entity is obtained by compensating for the displacement of the bounding box caused by the virtual camera's movement using the actual pose sequence of the virtual camera.
[0105] S304. Based on the actual location sequence, construct the actual trajectory of the target virtual entity.
[0106] In the embodiments of this application, different implementation methods are used for two cases: one where there are corresponding depth maps for multiple consecutive real-time rendered frames, and another where there are no corresponding depth maps.
[0107] A depth map is a special type of image where each pixel value represents the actual physical distance (absolute depth) or relative distance (relative depth) of a point in the scene from the virtual camera. The depth map uses grayscale values (i.e., depth values) to reflect distance information: brighter grayscale values (closer to white) indicate that the point is closer to the camera; darker grayscale values (closer to black) indicate that the point is farther from the camera.
[0108] In one possible implementation, when there are corresponding depth maps for each of the consecutive real-time rendered frames, the depth value corresponding to the center point of the bounding box of the target virtual entity is extracted from the depth maps corresponding to the consecutive real-time rendered frames to obtain a depth value sequence; based on the actual position sequence and the depth value sequence, combined with the intrinsic parameters of the virtual camera, the three-dimensional coordinate sequence of the target virtual entity is obtained by back-projection; based on the three-dimensional coordinate sequence, the actual trajectory of the target virtual entity is constructed.
[0109] In another possible implementation, when there are no corresponding depth maps for multiple consecutive real-time rendered frames, the geometric relationships of the multi-view images are used to construct the actual trajectory of the target virtual entity based on the actual position sequence.
[0110] Among them, the geometric relationships of multi-view images are used to describe the geometric relationships of reconstructed 3D scenes in different frames. The most common way to represent the geometric relationships of multi-view images is through the principle of triangulation.
[0111] The principle of triangulation refers to using the two-dimensional coordinates of the bounding box of a target virtual entity in two real-time rendered frames, combined with virtual camera parameters (intrinsic and extrinsic parameters), to infer the three-dimensional coordinates of the bounding box of the target virtual entity.
[0112] Specifically, when multiple consecutive real-time rendered frames do not have corresponding depth maps, the actual trajectory of the target virtual entity is constructed based on the actual position sequence using the principle of triangulation.
[0113] The above combination Figure 2 and Figure 3 This section describes how the actual trajectory is obtained when the target virtual object is a virtual camera and a virtual entity, respectively. The following section continues with... Figure 1 This application introduces a code verification method provided by an embodiment.
[0114] S104. Perform trajectory error analysis on the actual trajectory and the expected trajectory to obtain code verification results.
[0115] The code verification result includes: verification passed or verification failed.
[0116] In one possible implementation, the trajectory error between the actual trajectory and the expected trajectory is calculated; it is determined whether the trajectory error is less than a preset trajectory error threshold; if the trajectory error is less than the preset trajectory error threshold, the code verification result is "verification passed"; if the trajectory error is not less than the preset trajectory error threshold, the code verification result is "verification failed".
[0117] The trajectory error refers to the deviation between the actual trajectory and the expected trajectory. In this embodiment, the trajectory error includes at least one of absolute trajectory error and relative attitude error. For example, the code verification result can be obtained based on the absolute trajectory error between the actual trajectory and the expected trajectory; the code verification result can also be obtained based on the relative attitude error between the actual trajectory and the expected trajectory; or the code verification result can be obtained based on both the absolute trajectory error and the relative attitude error between the actual trajectory and the expected trajectory.
[0118] The absolute trajectory error (ATE) measures the direct deviation between the expected trajectory and the actual trajectory at each time point. Specifically, the absolute trajectory error is obtained by calculating the Euclidean distance between the expected and actual trajectories at the same time point and taking the root mean square error (RMSE) of the Euclidean distance at all time points.
[0119] The relative pose error (RPE) measures the deviation between the expected trajectory and the actual trajectory at two points in time, i.e., the relative motion error between the expected trajectory and the actual trajectory within a fixed time interval. Specifically, the relative pose error is obtained by calculating the deviation between the expected trajectory and the actual trajectory within a fixed time interval and taking the root mean square error of the deviations of all valid pose changes.
[0120] It should be noted that the expected trajectory and the actual trajectory are aligned by default according to the correspondence of time points.
[0121] For example, when the trajectory error is the absolute trajectory error, the absolute trajectory error between the actual trajectory and the expected trajectory is calculated; it is determined whether the absolute trajectory error is less than the preset absolute trajectory error threshold; if yes, the code verification result is "verification passed"; if no, the code verification result is "verification failed".
[0122] For example, when the trajectory error is the relative attitude error, the relative attitude error between the actual trajectory and the expected trajectory is calculated; it is determined whether the relative attitude error is less than the preset relative attitude error threshold; if so, the code verification result is "verification passed"; if not, the code verification result is "verification failed".
[0123] For example, when the trajectory error consists of absolute trajectory error and relative attitude error, the absolute trajectory error and relative attitude error between the actual trajectory and the expected trajectory are calculated; it is determined whether the absolute trajectory error is less than a preset absolute trajectory error threshold and the relative attitude error is less than a preset relative attitude error threshold; if so, the code verification result is "verification passed"; if not, the code verification result is "verification failed".
[0124] In one possible implementation, a verification report corresponding to the code under test is generated based on the trajectory error, a preset trajectory error threshold, and the code verification result. For ease of understanding, the following section will combine... Figure 4 The verification report shown is an example.
[0125] like Figure 4 The verification report shown includes: the code verification result is verification failed; the calculated absolute trajectory error is 0.85; the preset absolute trajectory error threshold is 0.5; the calculated relative attitude error is 0.2; and the preset relative attitude error threshold is 0.1.
[0126] In one possible implementation, when the code verification result is "verification failed," the code under test is corrected through automated programming based on the trajectory error between the expected trajectory and the actual trajectory, resulting in corrected code under test. This corrected code is then run repeatedly to obtain the code verification result. When the code verification result is "verification passed," the code under test is identified as the target code and output, allowing for subsequent application of this target code, thereby controlling the virtual object to run according to the expected trajectory.
[0127] Furthermore, when the code verification result is that the verification fails, the code under test is corrected through automated programming based on the verification report.
[0128] In this embodiment, automated programming technology can automatically correct the code under test based on trajectory errors (such as ATE or RPE) without manual adjustment, significantly shortening the debugging cycle; it also reduces reliance on manual debugging and improves development efficiency. Furthermore, in this embodiment, dynamic verification-iterative correction is used to continuously optimize code performance until verification is passed, at which point the target code is output.
[0129] This application provides a code verification method, including: acquiring code to be tested; running the code to be tested to acquire a video stream corresponding to the code; using a trajectory estimation algorithm to obtain the actual trajectory of a target virtual object based on real-time rendering of multiple consecutive frames; and performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result. In this application embodiment, by running the code to be tested to generate a real-time rendered video stream and comparing the expected trajectory with the actual trajectory based on the trajectory estimation algorithm, the visual effect verification of the code to be tested is achieved. This effectively solves the problem that existing technologies can only verify the theoretical correctness of code but cannot guarantee the actual running effect, ensuring that the motion trajectory of the virtual object conforms to the design intent, thereby improving the reliability and development efficiency of automated programming in 3D game development. Furthermore, it eliminates the need for manual visual observation of whether the actual visual effect produced by the code during runtime in the rendering engine meets the requirements, improving the accuracy and repeatability of code verification.
[0130] Furthermore, by constructing the actual trajectory of the target virtual object, visual perception capability is given to code verification. By comparing the error between the actual trajectory and the expected trajectory, visual verification of the code can be achieved.
[0131] Furthermore, when the code verification result is that the verification fails, the code under test is corrected through automated programming based on the trajectory error between the actual trajectory and the expected trajectory, thus realizing a closed loop of "acquiring code -> running verification -> error analysis -> automatic correction", thereby achieving rapid correction of the code under test.
[0132] Furthermore, in this embodiment of the application, the verification of the code under test is based on the final rendered screen (video stream), completely bypassing the intermediate complexity of the code (such as compiler optimization, low-level API calls, etc.), and avoiding verification deviations caused by the uncertainty of intermediate steps.
[0133] Example 2:
[0134] The following is combined Figure 5 This application provides a detailed description of a code verification device provided in its embodiments.
[0135] like Figure 5 As shown in the embodiment of this application, a code verification device includes the following modules:
[0136] The code acquisition module 501 is used to acquire the code to be tested; the code to be tested is used to control the target virtual object to run according to the expected trajectory.
[0137] The image acquisition module 502 is used to run the code under test and acquire the video stream corresponding to the code under test; wherein, the video stream includes: continuous multi-frame real-time rendered images;
[0138] The trajectory construction module 503 is used to obtain the actual trajectory of the target virtual object by using a trajectory estimation algorithm based on the real-time rendering of multiple consecutive frames included in the video stream.
[0139] The code verification module 504 is used to perform trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification results.
[0140] In one possible implementation, when the target virtual object is a virtual camera, the trajectory construction module 503 is specifically used to extract feature points of the static background from multiple consecutive real-time rendered images; use the Simultaneous Localization and Mapping (SLAM) algorithm to reverse calculate the actual pose sequence of the target virtual camera in three-dimensional space based on the feature points of the static background; and construct the actual trajectory of the target virtual camera based on the actual pose sequence.
[0141] In one possible implementation, when the target virtual object is a virtual entity, the trajectory construction module 503 is specifically used to extract feature points of the static background from multiple consecutive real-time rendered frames, and use the SLAM algorithm to inversely calculate the actual pose sequence of the virtual camera in three-dimensional space based on the feature points of the static background; use the target detection model to identify and locate the bounding box of the target virtual entity in multiple consecutive real-time rendered frames; based on the actual pose sequence, compensate for the displacement of the bounding box of the target virtual entity caused by the movement of the virtual camera to obtain the actual position sequence of the bounding box of the target virtual entity; wherein, the actual position sequence is a two-dimensional coordinate sequence; and construct the actual trajectory of the target virtual entity based on the actual position sequence.
[0142] In one possible implementation, when multiple consecutive real-time rendered frames have corresponding depth maps, the trajectory construction module 503 is specifically used to extract the depth value corresponding to the center point of the bounding box of the target virtual entity from the depth maps corresponding to the multiple consecutive real-time rendered frames, and obtain a depth value sequence; based on the actual position sequence and the depth value sequence, combined with the intrinsic parameters of the virtual camera, the three-dimensional coordinate sequence of the target virtual entity is obtained by back-projection; based on the three-dimensional coordinate sequence, the actual trajectory of the target virtual entity is constructed.
[0143] In one possible implementation, when there are no corresponding depth maps for each of the consecutive real-time rendered frames, the trajectory construction module 503 is specifically used to construct the actual trajectory of the target virtual entity based on the actual position sequence by utilizing the geometric relationship of the multi-view images.
[0144] In one possible implementation, the code verification module 504 is specifically used to calculate the trajectory error between the actual trajectory and the expected trajectory; wherein the trajectory error includes at least one of absolute trajectory error and relative attitude error; determine whether the trajectory error is less than a preset trajectory error threshold; when the trajectory error is less than the preset trajectory error threshold, the code verification result is verified as passed; when the trajectory error is not less than the preset trajectory error threshold, the code verification result is verified as failed.
[0145] In one possible implementation, the device further includes a code correction module, which, when the code verification result is that the verification failed, corrects the code to be tested through automated programming based on the trajectory error to obtain the corrected code to be tested, and repeatedly runs the corrected code to be tested to obtain the code verification result.
[0146] In one possible implementation, the device further includes a code output module, used to determine the code to be tested as the target code and output it when the code verification result is that the verification is passed.
[0147] In one possible implementation, the device further includes a report generation module, used to generate a verification report corresponding to the code under test based on the trajectory error, a preset trajectory error threshold, and the code verification result.
[0148] This application provides a code verification device, comprising: a code acquisition module 501 for acquiring code to be tested; a screen acquisition module 502 for running the code to be tested and acquiring a video stream corresponding to the code; a trajectory construction module 503 for using a trajectory estimation algorithm to render a screen in real time based on multiple consecutive frames to obtain the actual trajectory of a target virtual object; and a code verification module 504 for performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result. In this application embodiment, by running the code to be tested to generate a real-time rendered video stream and comparing the expected trajectory with the actual trajectory based on the trajectory estimation algorithm, the visual effect verification of the code to be tested is achieved. This effectively solves the problem that existing technologies can only verify the theoretical correctness of code but cannot guarantee the actual running effect, ensuring that the motion trajectory of the virtual object conforms to the design intent, thereby improving the reliability and development efficiency of automated programming in 3D game development. Furthermore, by constructing the actual trajectory of the target virtual object, the automated programming is endowed with visual effect perception capabilities, enabling the visual effect verification of the code generated by automated programming by comparing the error between the actual trajectory and the expected trajectory.
[0149] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. The components indicated as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment solution according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0150] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A code verification method characterized by, The method comprises the following steps: acquiring a to-be-tested code; wherein the to-be-tested code is used to control a target virtual object to run according to an expected trajectory; running the to-be-tested code to acquire a video stream corresponding to the to-be-tested code; wherein the video stream comprises continuous multiple frames of real-time rendering pictures; using a trajectory estimation algorithm to obtain an actual trajectory of the target virtual object based on the continuous multiple frames of real-time rendering pictures; performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain a code verification result; when the target virtual object is a virtual entity, the step of using the trajectory estimation algorithm to obtain the actual trajectory of the target virtual object based on the continuous multiple frames of real-time rendering pictures comprises the following steps: extracting feature points of a static background from the continuous multiple frames of real-time rendering pictures, and using a SLAM algorithm to inversely solve an actual pose sequence of a virtual camera in a three-dimensional space based on the feature points of the static background; using a target detection model to identify and locate a bounding box of the target virtual entity in the continuous multiple frames of real-time rendering pictures; compensating for displacement of the bounding box of the target virtual entity caused by movement of the virtual camera based on the actual pose sequence to obtain an actual position sequence of the bounding box of the target virtual entity; wherein the actual position sequence is a two-dimensional coordinate sequence; constructing the actual trajectory of the target virtual entity based on the actual position sequence.
2. The method of claim 1, wherein, when the target virtual object is a virtual camera, the step of using the trajectory estimation algorithm to obtain the actual trajectory of the target virtual object based on the continuous multiple frames of real-time rendering pictures comprises the following steps: extracting feature points of a static background from the continuous multiple frames of real-time rendering pictures; using a simultaneous localization and mapping (SLAM) algorithm to inversely solve an actual pose sequence of the target virtual camera in a three-dimensional space based on the feature points of the static background; constructing the actual trajectory of the target virtual camera based on the actual pose sequence.
3. The method of claim 1, wherein, when the continuous multiple frames of real-time rendering pictures have respective depth maps, the step of constructing the actual trajectory of the target virtual entity based on the actual position sequence comprises the following steps: extracting a depth value corresponding to a center point of the bounding box of the target virtual entity from the respective depth maps corresponding to the continuous multiple frames of real-time rendering pictures to obtain a depth value sequence; based on the actual position sequence and the depth value sequence, inversely projecting to obtain a three-dimensional coordinate sequence of the target virtual entity in combination with an intrinsic parameter of the virtual camera; constructing the actual trajectory of the target virtual entity based on the three-dimensional coordinate sequence.
4. The method of claim 1, wherein, when the continuous multiple frames of real-time rendering pictures do not have respective depth maps, the step of constructing the actual trajectory of the target virtual entity based on the actual position sequence comprises the following steps: using a geometric relationship of multi-view images to construct the actual trajectory of the target virtual entity based on the actual position sequence.
5. The method of claim 1, wherein, the step of performing trajectory error analysis on the actual trajectory and the expected trajectory to obtain a code verification result comprises the following steps: calculating a trajectory error between the actual trajectory and the expected trajectory; wherein the trajectory error comprises at least one of an absolute trajectory error and a relative attitude error; determining whether the trajectory error is less than a preset trajectory error threshold; when the trajectory error is less than the preset trajectory error threshold, obtaining a code verification result as passing verification; when the trajectory error is not less than the preset trajectory error threshold, obtaining a code verification result as failing verification.
6. The method of claim 5, wherein, After the trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result, the method further comprises: when the code verification result is failing verification, correcting the to-be-tested code through automated programming based on the trajectory error, obtaining a corrected to-be-tested code, and repeatedly running the corrected to-be-tested code to obtain a code verification result.
7. The method of claim 6, wherein, After the trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result, the method further comprises: when the code verification result is passing verification, determining the to-be-tested code as a target code and outputting.
8. The method of claim 6, wherein, After the trajectory error analysis on the actual trajectory and the expected trajectory to obtain the code verification result, the method further comprises: generating a verification report corresponding to the to-be-tested code according to the trajectory error, the preset trajectory error threshold, and the code verification result.
9. A code verification apparatus characterized by comprising: comprises: a code acquisition module configured to acquire a to-be-tested code; wherein the to-be-tested code is used to control a target virtual object to run according to an expected trajectory; a picture acquisition module configured to run the to-be-tested code and acquire a video stream corresponding to the to-be-tested code; wherein the video stream comprises continuous multiple frames of real-time rendering pictures; a trajectory construction module configured to obtain an actual trajectory of the target virtual object by using a trajectory estimation algorithm based on the continuous multiple frames of real-time rendering pictures; a code verification module configured to perform trajectory error analysis on the actual trajectory and the expected trajectory to obtain a code verification result; when the target virtual object is a virtual entity, the trajectory construction module is specifically configured to: extract feature points of a static background from the continuous multiple frames of real-time rendering pictures, and inversely solve an actual pose sequence of a virtual camera in a three-dimensional space based on the feature points of the static background by using a SLAM algorithm; identify and locate a bounding box of a target virtual entity in the continuous multiple frames of real-time rendering pictures by using a target detection model; compensate for displacement of the bounding box of the target virtual entity caused by movement of the virtual camera based on the actual pose sequence to obtain an actual position sequence of the bounding box of the target virtual entity; wherein the actual position sequence is a two-dimensional coordinate sequence; construct an actual trajectory of the target virtual entity based on the actual position sequence.
Citation Information
Patent Citations
Robot RGB-D SLAM method based on grid segmentation and double-map coupling
CN114612525A
Reliability analysis method and system of body model, medium, equipment and product
CN120449922A