A method for automatically generating virtual data sets for marine infrared target recognition

By combining three-dimensional modeling and game engine technology, the marine infrared target recognition data set is generated, which solves the problems of high data acquisition costs and insufficient data diversity in the existing technology, and realizes efficient and low-cost marine infrared target recognition data set generation.

CN119048683BActive Publication Date: 2025-04-22ZHENGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411248357.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2025-04-22
Estimated Expiration
2044-09-06

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively generate high-quality offshore infrared target identification data sets, especially in the problems of high data acquisition costs, insufficient data diversity and heavy labeling work.

Method used

By combining three-dimensional modeling, game engine technology and computer vision algorithms, high randomization of maritime scenes, automatic generation and arrangement of target instances, accurate occlusion detection, simulation of infrared imaging effects, and automatic annotation of data sets.

Benefits of technology

It realizes the large-scale and low-cost generation of diversified marine infrared target images, simulating various complex sea conditions, weather conditions and target states, thereby providing rich and high-quality data support for marine infrared target recognition algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119048683B_ABST
    Figure CN119048683B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for automatically generating a virtual data set for marine infrared target recognition, which relates to the technical field of virtual reality and image processing, including: S1 establishing a marine target model, importing the target model into Unity3D, and setting it as a prefabricated body; S2 constructing a virtual marine environment, randomly generating target model instances within a preset range; S3 generating a bounding box for the target model, and setting the camera to generate an infrared target image; S4 generating a marine infrared target data set in Yolo format based on the infrared target image. The present invention can not only generate a variety of marine infrared target images on a large scale and at low cost, but also simulate various complex sea conditions, weather conditions and target states, thereby providing rich and high-quality data support for the training and testing of marine infrared target recognition algorithms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of virtual reality and image processing, and in particular to a method for automatically generating a virtual data set for marine infrared target recognition. Background Art

[0002] Maritime target recognition is an important task in the fields of ocean monitoring, maritime search and rescue, and marine safety. With the development of deep learning technology, target detection algorithms based on convolutional neural networks have been widely used in maritime target recognition. However, the performance of these algorithms depends largely on large-scale, high-quality training datasets.

[0003] In practical applications, there are many difficulties in obtaining sufficient infrared image datasets of real marine targets: High data acquisition cost. Professional infrared equipment and marine platforms are required, and the acquisition process is time-consuming and expensive. Limited scene and target types. It is difficult for real data to cover various sea conditions, weather conditions and target types. The annotation work is arduous. Manual annotation of infrared images requires professional knowledge and is time-consuming and labor-intensive.

[0004] To solve these problems, researchers began to explore the use of computer graphics and virtual simulation technology to generate synthetic datasets. However, existing virtual dataset generation methods are mainly aimed at visible light images and lack simulation of infrared imaging characteristics. In addition, there is a lack of effective processing for the occlusion problem unique to marine targets (such as partial immersion in water). Therefore, it is of great significance to develop a method for automatically generating virtual datasets specifically for marine infrared target recognition. Summary of the invention

[0005] In view of this, the present invention proposes a method for automatically generating virtual data sets for marine infrared target recognition. By combining 3D modeling, game engine technology and computer vision algorithms, the method realizes high randomization of marine scenes, automatic generation and arrangement of target instances, accurate occlusion detection, simulation of infrared imaging effects and automatic annotation of data sets. This method can not only generate diversified marine infrared target images on a large scale and at low cost, but also simulate various complex sea conditions, weather conditions and target states, thereby providing rich and high-quality data support for the training and testing of marine infrared target recognition algorithms.

[0006] The technical solution of the present invention is implemented as follows: The present invention provides a method for automatically generating a virtual data set for marine infrared target recognition, comprising:

[0007] S1 builds a marine target model, imports the target model into Unity3D, and sets it as a prefab;

[0008] S2 constructs a virtual ocean environment and randomly generates target model instances within a preset range;

[0009] S3 generates a bounding box for the target model and sets the camera to generate an infrared target image;

[0010] S4 generates a marine infrared target dataset in Yolo format based on infrared target images.

[0011] Based on the above technical solution, preferably, step S1 includes:

[0012] S11 used Maya to build models of marine targets according to various targets, including cruise ships, bulk carriers, warships, sailboats, kayaks, container ships and fishing boats;

[0013] S12 sets the material map UV for all targets, adds the normal map and bakes it;

[0014] S13 exports all target models to FBX format and imports the target models into Unity3D;

[0015] S14 converts the imported target model into a Prefab prefab in Unity3D, and sets a tag corresponding to the target name for each prefab in the Inspector panel.

[0016] Based on the above technical solution, preferably, step S2 includes:

[0017] S21 builds an ocean environment based on Unity Ocean System URP, which randomly adjusts the light, waves and ripple effects, and defines the range of the ocean environment according to the size and distribution of different targets;

[0018] S22 uses the Instantiate method to randomly generate target model instances within the defined marine environment;

[0019] S23 randomizes environmental parameters, including weather conditions, time, and sea conditions.

[0020] Based on the above technical solution, preferably, step S3 includes:

[0021] S31 obtains the Mesh of the target model and its sub-objects, obtains the AABB bounding box of the target through the Mesh, combines the size, center point and target data of the AABB bounding box into the OBB bounding box of the target, and adds a box-type collision body to all target models;

[0022] S32 performs occlusion detection on all target models using an occlusion detection algorithm. If a target model is completely occluded, the target model is skipped. Otherwise, step S33 is executed on the target model.

[0023] S33 obtains the world coordinates of the box-shaped collision body of the target model, converts the world coordinates to screen coordinates according to the Camera.WorldToScreenPoint method, calculates the maximum and minimum values ​​of the screen coordinates, and creates a label box containing all vertices;

[0024] S34 enables Use Physical Properties, controls the Allow DynamicResolution and Focal Length of the Camera, sets the resolution and focal length, and randomly changes the angle and height of the Camera to simulate different viewing angles;

[0025] S35 uses OpenCV to randomly add salt and pepper noise and Gaussian noise to the camera video stream;

[0026] S36 writes and applies the shader that realizes the infrared effect to generate the infrared target image.

[0027] Based on the above technical solution, preferably, step S32 includes:

[0028] S321 uses the box-shaped collision body of the created target model to construct the scene octree, optimize the space division, perform frustum culling, quickly exclude the target model outside the camera's field of view, and perform depth sorting on the remaining target models;

[0029] S322 defines a key point K={v1, v2, ..., v8, c} for each target model based on the OBB bounding box, where v1 to v8 are eight vertices of the OBB bounding box, and c is the center point of the OBB bounding box;

[0030] S323 calculates the screen projection area A of each target model at the current viewing angle according to the camera parameters and the key point K;

[0031] S324 dynamically adjusts the ray sampling density of each target model according to the projection area A, and generates a sampling point set in the OBB bounding box;

[0032] S325: for each target model, generating a ray set according to the sampling point set, emitting rays from the camera to the sampling point set, and calculating the ray hit rate of each target model;

[0033] S326: Preliminarily determine the occlusion state of each target model based on the ray hit rate and the dynamic threshold. The occlusion state is divided into unoccluded, fully occluded, and partially occluded. For a non-fully occluded target model, execute step S327;

[0034] S327 divides the non-fully occluded target model into 3*3 grid sub-regions, calculates the occlusion degree of each sub-region respectively, and generates an occlusion mask containing partial occlusion information;

[0035] S328 summarizes the occlusion status of each target model. For target models that are not fully occluded, save their occlusion masks, and filter out a list of target models that are not occluded and contain occlusion masks from all target models to execute step S33. For the remaining fully occluded target models, skip these target models.

[0036] Based on the above technical solution, preferably, step S324 includes:

[0037] Step 1: Set the basic sampling density ρ base , calculate the ray sampling density based on the projection area A:

[0038] ρ final =ρ adaptive ×f distance ×f importance

[0039] ρ adaptive =ρ base ×log(1+A / A ref )

[0040]

[0041] f importance =1+α×p

[0042] In the formula, ρ final is the ray sampling density, ρ adaptive is the adaptive density, f distance is the distance factor, f importance is the importance factor, A ref is the reference projection area, d is the distance from the center point c of the OBB bounding box to the camera, and d ref is the reference distance, α is the adjustable coefficient, and p is the normalized importance score;

[0043] Step 2: Calculate the number of rays based on the ray sampling density:

[0044] N = ceil(ρ final ×A)

[0045] Where N is the number of rays, and ceil represents the upward rounding function;

[0046] Step 3: Set the upper and lower limits of the number of rays:

[0047] N=clamp(N,N min ,N max)

[0048] Where clamp represents the restriction function. If the calculated number of rays N is less than N min , then use N min As the number of rays, if the calculated number of rays N is greater than N max , then use N max As the number of rays, if the calculated number of rays N is in N min and N max If it is between , the original value is maintained;

[0049] Step 4: Sort the six faces of the OBB bounding box by area and calculate the relative area ratio of each face;

[0050] Step 5: For each sampling point, randomly select a face according to the relative area ratio of the faces;

[0051] Step 6: Generate two random numbers u and v in the range of [0,1] on the selected surface, and use these two random numbers as the local coordinates of the surface;

[0052] Step 7: Convert the local coordinates (u, v) to the global coordinate system of OBB;

[0053] Step 8: Repeat steps 5 to 7 until N sampling points are generated.

[0054] Based on the above technical solution, preferably, step S325 includes:

[0055] Define the scene geometry. The scene consists of a set of triangle meshes, each triangle is defined by three vertices and a normal vector;

[0056] For each target model M, according to the sampling point set S = {s1, s2, ..., s N}, generate ray set R = {r1, r2, ... r N}, each ray r i Defined as: r i (t) = O + t * E i , where O is the optical center of the camera, E i From O to sampling point s i The unit direction vector of ;

[0057] Use the spatial acceleration structure to optimize the intersection test between rays and scene geometry. Perform an intersection test for each ray:

[0058] a. Set the initial step length Δt = Δt init , set the maximum number of iterations max iter , set the convergence threshold ε;

[0059] b. For ray r i , let t = 0;

[0060] c. Set the number of iterations iter = 1;

[0061] d. Calculate the current point P = O + t * E i ;

[0062] e. Find the scene geometry closest to P, calculate the distance D from P to the nearest scene geometry, if D < ε, then record the intersection point P i =P and the corresponding object O i , otherwise, let t = t + max (D * 0.8, Δt);

[0063] f. If the scene geometry is not found, record P i is the point at infinity, O i is empty;

[0064] g. Determine whether iter is equal to max iter If yes, the intersection test ends and the intersection point P is output. i and the corresponding object O i If not, let iter+1, and based on the current pixel density ρ pixel , calculate the ray precision adjustment factor ρ b is the benchmark pixel density, and the iteration step size is adjusted to Δt = Δt init / f res , adjust the convergence threshold ε=ε / f res , return to step d;

[0065] Define the importance weight vector of the sampling points W = {w1,w2,...,w N}, calculate the distance attenuation factor λ is the attenuation coefficient, and the ray hit indication function is defined as:

[0066]

[0067] Calculate the ray hit rate:

[0068]

[0069] In the formula, H(r i ) is the ray r i The ray hit rate.

[0070] Based on the above technical solution, preferably, step S33 includes:

[0071] According to the boxCollider.bounds under the BoxCollider bounding box, the world coordinates of the eight vertices of the box collider of the target model are obtained, as shown below:

[0072]

[0073] In the above formula, ver[i] is a three-dimensional array defined to store the coordinates of 8 vertices, bounds is the bounding box information stored when the bounding box is automatically generated, which includes the center, size, maximum and minimum coordinate points of the bounding box in three-dimensional space, and bounds.max and bounds.min are the maximum and minimum coordinate points of the bounding box in three-dimensional space respectively;

[0074] For each vertex ver[i], use the Camera.WorldToScreenPoint method to convert it. The conversion formula is as follows:

[0075] screenPoint[i]=Camera.WorldToScreenPoint(ver[i])

[0076] Where screenPoint[i] is a Vector3 containing the screen coordinates (x, y) and the depth value z;

[0077] Calculate the maximum and minimum values ​​of the screen coordinates and create a rectangular box containing all vertices, that is, the marking box of the target on the screen. The rectangular box is calculated as follows:

[0078]

[0079] In the above formula: minX and minY are the screen coordinates of the minimum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, maxX and maxY are the screen coordinates of the maximum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, and Screen.height is the height of the screen.

[0080] Based on the above technical solution, preferably, step S35 includes:

[0081] Integrate OpenCV in Unity, use Unity's Camera.render method to render the camera view to RenderTexture, convert RenderTexture to Mat format that OpenCV can process to obtain the camera video stream;

[0082] Define the salt and pepper noise density, randomly select pixels and set them to black or white;

[0083] Define the mean and standard deviation of Gaussian noise, and add a random value that conforms to the Gaussian distribution to each pixel;

[0084] Randomly add salt and pepper noise or Gaussian noise to each frame of the camera video stream.

[0085] Based on the above technical solution, preferably, step S36 includes:

[0086] Create a new Shader file in Unity, name it InfraredEffect, and write the vertex shader and fragment shader;

[0087] Implement infrared effects, including converting color space, applying temperature mapping, adding hotspot effects, and simulating thermal radiation blur;

[0088] Create a material and set its shader to the InfraredEffect just created, and apply this material to the Camera through the post-processing stack;

[0089] Add adjustable parameters, including temperature range and contrast, and dynamically modify the adjustable parameters at runtime to simulate different infrared imaging effects and generate infrared target images.

[0090] Compared with the prior art, the present invention has the following beneficial effects:

[0091] (1) By integrating 3D modeling and Unity3D, we can achieve high randomization of marine scenes, automatic generation and arrangement of target instances, accurate occlusion detection, and simulation of infrared imaging effects, so as to automatically and efficiently generate large-scale, high-quality virtual datasets for marine infrared target recognition. This method significantly reduces the cost of data collection and annotation, while improving the diversity and representativeness of data, and effectively improving the training effect and generalization ability of marine infrared target recognition algorithms;

[0092] (2) By introducing an accurate occlusion detection algorithm based on ray sampling and combining it with the intersection test optimized by the spatial acceleration structure, the occlusion state of the target model can be accurately detected and quantified, including partial occlusion and full occlusion. This method can not only simulate complex occlusion situations in real sea conditions (such as partially submerged ships), but also provide more realistic and diverse target representations for the training algorithm, significantly improving the recognition algorithm's ability to adapt to complex scenes;

[0093] (3) By adopting an adaptive ray sampling density calculation method based on the target projection area, distance and importance, combined with the dynamic adjustment of the ray precision adjustment factor, the goal of optimizing the use of computing resources while ensuring the accuracy of occlusion detection is achieved. This method can dynamically adjust the sampling density according to the size and importance of the target, improving the generation efficiency while ensuring the detection quality of key targets;

[0094] (4) By creating a custom shader in Unity, we implemented infrared imaging effects simulation including color space conversion, temperature mapping, hotspot effects, and thermal radiation blur. Combined with adjustable parameters such as temperature range and contrast, this approach not only generates highly realistic infrared target images, but also simulates different infrared imaging conditions, enhancing the authenticity, diversity, and applicability of virtual datasets. BRIEF DESCRIPTION OF THE DRAWINGS

[0095] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0096] Figure 1 is a flow chart of a method according to an embodiment of the present invention;

[0097] Figure 2 This is a visualization effect diagram of the annotation box according to an embodiment of the present invention. DETAILED DESCRIPTION

[0098] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0099] like Figure 1 As shown, the present invention provides a method for automatically generating a virtual data set for marine infrared target recognition, comprising:

[0100] S1 builds a marine target model, imports the target model into Unity3D, and sets it as a prefab;

[0101] S2 constructs a virtual ocean environment and randomly generates target model instances within a preset range;

[0102] S3 generates a bounding box for the target model and sets the camera to generate an infrared target image;

[0103] S4 generates a marine infrared target dataset in Yolo format based on infrared target images.

[0104] Specifically, in one embodiment of the present invention, step S1 includes:

[0105] S11 used Maya to build models of maritime targets according to the various targets, including cruise ships, bulk carriers, warships, sailboats, kayaks, container ships and fishing boats.

[0106] Specifically, open Maya software, create a new scene for each target, use polygonal modeling technology, create the basic shape of each target according to reference pictures or blueprints, use subdivision, extrusion, chamfer and other tools to refine the model details, and use Boolean operations and combination operations for complex structures such as decks and masts.

[0107] S12 sets material map UVs for all targets, adds normal maps and bakes them.

[0108] Specifically, expand the model UV in the UV editor, ensure that the texture mapping is uniform and without distortion, create and apply materials for each target, such as metal, wood, glass, etc., design appropriate maps, including color maps, normal maps, apply maps to the model, adjust the map size and position, and use Maya's baking tools to bake the normal map to the model.

[0109] S13 exports all target models to FBX format and imports the target models into Unity3D.

[0110] Specifically, select all model elements that need to be exported, use Maya's export function, select the FBX format, set export options such as scaling factor, animation options, select the export path, export the model, and then import it into Unity3D.

[0111] S14 converts the imported target model into a Prefab prefab in Unity3D, and sets a tag corresponding to the target name for each prefab in the Inspector panel.

[0112] Specifically, create a suitable folder structure in the Unity project, import the FBX file into Unity, and drag the imported model into the scene. Adjust the position, rotation, and scale of the model, drag the adjusted model into the Project window, and create a Prefab prefab. Select the created Prefab prefab, add the Tag component in the Inspector panel, set the corresponding Tag name for each Prefab prefab, such as Cruise, Cargo, etc., check and test the Prefab prefab to ensure correct instantiation.

[0113] Specifically, in one embodiment of the present invention, step S2 includes:

[0114] S21 builds an ocean environment based on the Unity Ocean System URP, which randomly adjusts the light, waves and ripple effects, and defines the scope of the ocean environment according to the size and distribution of different targets.

[0115] First, create a new 3D project in Unity. Install the Universal Render Pipeline (URP) package through the Package Manager. Create a URP Asset and apply it in the Project Settings.

[0116] In the Hierarchy window, right-click and select Effects>Ocean Renderer. This will add an Ocean Renderer component to the scene. Select the Ocean Renderer object and find the Ocean Material properties in the Inspector window. Select Create>Material to create a new ocean material. In the newly created material, adjust the Base Color, Smoothness, and Transparency parameters to get the ideal ocean look.

[0117] To simulate dynamic lighting effects, add a Directional Light to the scene. Create a new C# script named LightController.cs and attach it to the Directional Light object. In this script, write code to randomly adjust the intensity, color, and direction of the light source, for example: randomly adjust the light intensity, sunLight.intensity = Mathf.PingPong (Time.time*0.1f, 0.5f) + 0.5f; randomly adjust the light color, sunLight.color = Color.Lerp (Color.white, Color.yellow, Mathf.PingPong (Time.time*0.05f, 1)); slowly rotate the light source direction, transform.Rotate (Vector3.right, Time.deltaTime*5).

[0118] Select the Ocean Renderer object and expand the Wave Spectrum settings in the Inspector window. Adjust parameters such as Wave Scale, Choppiness, and Wind Speed ​​to create the desired wave effect. Create a new Shader Graph and use the node editor to create custom water surface details, such as adding normal maps and ripple animations. Apply the created Shader Graph to the Ocean Material.

[0119] Create an empty object in the Hierarchy and name it "EnvironmentBoundary". Add a BoxCollider component and adjust its Size property to define a suitable environment boundary.

[0120] S22 uses the Instantiate method to randomly generate target model instances within a defined marine environment.

[0121] Create an empty object "TargetSpawner" in the Hierarchy. Create a TargetSpawner.cs script and attach it to the object to create a target spawn manager.

[0122] Use the grid system to optimize the scene generation efficiency. At this time, modify TargetSpawner.cs:

[0123] First, add two new private fields to the TargetSpawner class: occupancyGrid: A two-dimensional Boolean array that records whether each cell in the grid is occupied. gridSize: Defines the size of the grid, for example 100*100.

[0124] In the Start method, add a call to the InitializeGrid method to initialize the grid system.

[0125] Use the InitializeGrid method to create a two-dimensional Boolean array of gridSize*gridSize size. In the initial state, all cells are unoccupied (the default value is false).

[0126] The GetValidSpawnPosition method is overridden to use a grid system to find a valid spawn position: a do-while loop is used to randomly select x and z coordinates in the grid. The loop continues until an unoccupied grid cell is found. Once a free cell is found, it is marked as occupied (true). Finally, the GridToWorldPosition method is called to convert the grid coordinates to world coordinates and return it.

[0127] The GridToWorldPosition method converts the grid coordinates to actual world coordinates: Calculate worldX: Normalize the x coordinate to between -0.5 and 0.5, then multiply by spawnAreaSize.x. Calculate worldZ: Do the same for the z coordinate. Returns a new Vector3 with the y coordinate fixed to 0 (assuming all targets are on a horizontal plane).

[0128] S23 randomizes environmental parameters, including weather conditions, time, and sea conditions.

[0129] Create an empty object "EnvironmentController" in the Hierarchy. Create the EnvironmentController.cs script and attach it. Add a Post-processing Volume to the scene. Add the Fog effect to the Volume component and create the FogController.cs script to dynamically adjust the fog effect parameters. Add a smooth transition method in EnvironmentController.cs.

[0130] Specifically, in one embodiment of the present invention, step S3 includes:

[0131] S31 obtains the Mesh of the target model and its sub-objects, obtains the AABB bounding box of the target through the Mesh, combines the size, center point and target data of the AABB bounding box into the OBB bounding box of the target, and adds a box-type collision body to all target models;

[0132] S32 performs occlusion detection on all target models using an occlusion detection algorithm. If a target model is completely occluded, the target model is skipped. Otherwise, step S33 is executed on the target model.

[0133] S33 obtains the world coordinates of the box-shaped collision body of the target model, converts the world coordinates to screen coordinates according to the Camera.WorldToScreenPoint method, calculates the maximum and minimum values ​​of the screen coordinates, and creates a label box containing all vertices;

[0134] S34 enables Use Physical Properties, controls the Allow DynamicResolution and Focal Length of the Camera, sets the resolution and focal length, and randomly changes the angle and height of the Camera to simulate different viewing angles;

[0135] S35 uses OpenCV to randomly add salt and pepper noise and Gaussian noise to the Camera video stream;

[0136] S36 writes and applies the shader that realizes the infrared effect to generate the infrared target image.

[0137] In this embodiment, step S31 includes:

[0138] Using Unity's GetComponentsInChildren <meshfilter>() method obtains the MeshFilter components of the target model and all its child objects. Extracts Mesh data from each MeshFilter.

[0139] For each Mesh, use Unity's Mesh.bounds property to get its AABB. If the target is composed of multiple Meshes, you need to merge these AABBs and take the minimum and maximum points of all AABBs to create an AABB that contains the entire target.

[0140] Get the size (size) and center point (center) of the AABB. Get the rotation information (rotation) of the target model. Create an OBB using size, center and rotation.

[0141] Using Unity's AddComponent <boxcollider>The () method adds a BoxCollider component to each target model. Set the size and center of the BoxCollider to make it consistent with the OBB. If the target model already has another type of collision body, choose to replace or keep it.

[0142] In this embodiment, step S32 includes:

[0143] S321 uses the box-shaped collision body of the created target model to build a scene octree, optimize the space division, perform frustum culling, quickly exclude target models outside the camera's field of view, and perform depth sorting on the remaining target models.

[0144] Specifically, an octree is constructed using a recursive method, with each node containing an AABB and a list of objects. Fast culling is performed using the camera's frustum planes. For each target's OBB, check if it intersects with the frustum. Use a quick sort algorithm to sort based on the distance from the target to the camera.

[0145] S322 defines key points K={v1, v2, ..., v8, c} for each target model based on the OBB bounding box, where v1 to v8 are 8 vertices of the OBB bounding box, and c is the center point of the OBB bounding box.

[0146] S323 calculates the screen projection area A of each target model under the current viewing angle according to the camera parameters and the key point K.

[0147] Get the camera parameters, including position, direction, field of view (FOV), near plane distance, far plane distance, and aspect ratio. Get the OBB bounding box key points K of the target model.

[0148] Construct the view matrix: View = LookAt (cameraPosition, cameraTarget, cameraUp); Construct the projection matrix: Projection = Perspective (FOV, aspectRatio, nearPlane, farPlane); Calculate the view projection matrix: VP = Projection*View.

[0149] Convert the OBB keypoints from world coordinates to clip space coordinates: For each vertex v i :v' i =VP*v i .

[0150] Perform perspective division to convert the clip space coordinates to normalized device coordinates (NDC):

[0151] For each v' i :v" i .x=v' i .x / v' i .w;v" i .y=v' i .y / v' i .w;v" i .z=v' i .z / v' i .w.

[0152] Convert NDC coordinates to screen coordinates:

[0153] For each v" i :screen x =(v" i .x+1)*screen Width / 2; screen y =(1-v" i .y)*screen Height / 2.

[0154] The Graham scanning algorithm is used to calculate the 2D convex hull of the screen coordinate point set. The vector cross product method is used to calculate the convex hull area, that is, the projected area A.

[0155] S324 dynamically adjusts the ray sampling density of each target model according to the projection area A, and generates a sampling point set in the OBB bounding box.

[0156] Step S324 includes:

[0157] Step 1: Set the basic sampling density ρ base , calculate the ray sampling density based on the projection area A:

[0158] ρ final =ρ adaptive ×f distance ×f importance

[0159] ρ adaptive =ρ base ×log(1+A / A ref )

[0160]

[0161] f importance =1+α×p

[0162] In the formula, ρ final is the ray sampling density, ρ adaptive is the adaptive density, f distance is the distance factor, f importance is the importance factor, A ref is the reference projection area, d is the distance from the center point c of the OBB bounding box to the camera, and d ref is the reference distance, α is the adjustable coefficient, and p is the normalized importance score;

[0163] Step 2: Calculate the number of rays based on the ray sampling density:

[0164] N = ceil(ρ final ×A)

[0165] Where N is the number of rays, and ceil represents the upward rounding function;

[0166] Step 3: Set the upper and lower limits of the number of rays:

[0167] N=clamp(N,N min ,N max )

[0168] Where clamp represents the restriction function. If the calculated number of rays N is less than N min , then use N min As the number of rays, if the calculated number of rays N is greater than N max , then use N max As the number of rays, if the calculated number of rays N is in N min and N max If it is between , the original value is maintained;

[0169] Step 4: Sort the six faces of the OBB bounding box by area and calculate the relative area ratio of each face;

[0170] Step 5: For each sampling point, randomly select a face according to the relative area ratio of the faces;

[0171] Step 6: Generate two random numbers u and v in the range of [0,1] on the selected surface, and use these two random numbers as the local coordinates of the surface;

[0172] Step 7: Convert the local coordinates (u, v) to the global coordinate system of OBB;

[0173] Step 8: Repeat steps 5 to 7 until N sampling points are generated.

[0174] S325: For each target model, a ray set is generated according to the sampling point set, rays are emitted from the camera to the sampling point set, and the ray hit rate of each target model is calculated.

[0175] Step S325 includes:

[0176] Define the scene geometry. The scene consists of a set of triangle meshes, each triangle is defined by three vertices and a normal vector;

[0177] For each target model M, according to the sampling point set S = {s1, s2, ..., s N }, generate ray set R = {r1, r2, ... r N }, each ray r i Defined as: r i (t) = O + t * E i , where O is the optical center of the camera, E i From O to sampling point s i The unit direction vector of ;

[0178] Use the spatial acceleration structure to optimize the intersection test between rays and scene geometry. Perform an intersection test for each ray:

[0179] a. Set the initial step length Δt = Δt init , set the maximum number of iterations max iter , set the convergence threshold ε;

[0180] b. For ray r i , let t = 0;

[0181] c. Set the number of iterations iter = 1;

[0182] d. Calculate the current point P = O + t * E i ;

[0183] e. Find the scene geometry closest to P, calculate the distance D from P to the nearest scene geometry, if D < ε, then record the intersection point P i =P and the corresponding object O i , otherwise, let t = t + max (D * 0.8, Δt);

[0184] f. If the scene geometry is not found, record P i is the point at infinity, O i is empty;

[0185] g. Determine whether iter is equal to max iter If yes, the intersection test ends and the intersection point P is output. i and the corresponding object O i If not, let iter+1, and based on the current pixel density ρ pixel , calculate the ray precision adjustment factor ρ b is the benchmark pixel density, and the iteration step size is adjusted to Δt = Δt init / f res , adjust the convergence threshold ε=ε / f res , return to step d;

[0186] Define the importance weight vector of the sampling points W = {w1,w2,...,w N }, calculate the distance attenuation factor λ is the attenuation coefficient, and the ray hit indication function is defined as:

[0187]

[0188] Calculate the ray hit rate:

[0189]

[0190] In the formula, H(r i ) is the ray r i The ray hit rate.

[0191] S326: Preliminarily determine the occlusion state of each target model based on the ray hit rate and the dynamic threshold. The occlusion state is divided into unoccluded, fully occluded, and partially occluded. For a non-fully occluded target model, execute step S327;

[0192] Set the dynamic threshold τ = τ base +γ×(1-A / A max ), where τ base is the basic threshold, γ is the adjustment coefficient, A max is the maximum projected area.

[0193] According to the ray hit rate H(r i ) and dynamic threshold τ determine the occlusion state:

[0194] If H(r i )>1-τ, it is not blocked;

[0195] If H(r i )<τ, it is full occlusion;

[0196] Otherwise it is non-full occlusion.

[0197] S327 divides the non-fully occluded target model into 3*3 grid sub-regions, calculates the occlusion degree of each sub-region respectively, and generates an occlusion mask containing partial occlusion information.

[0198] Project the OBB to the screen space and divide the projected 2D convex hull into 3*3 grids. Assume that the boundary of the projected 2D convex hull is (minX, minY, maxX, maxY), cell Width =(maxX-minX) / 3, cell Height = (maxY-minY) / 3. For the sub-region of row i and column j (i, j from 1 to 3): subRegion[i][j] = {x1:minX+j*cell Width ,y1:minY+i*cell Height ,x2:minX+(j+1)*cell Width ,y2:minY+(i+1)*cell Height }.

[0199] Calculate the occlusion degree of the sub-region: emit N rays for each sub-region, occlusionRate[i][j] = occludedRays[i][j] / N, where occludedRays[i][j] is the number of occluded rays.

[0200] Set the occlusion threshold T, initialize the 9-bit binary mask to 0, start from the upper left corner, scan each sub-region row by row, and if the occlusion degree of the sub-region exceeds the threshold T, set the corresponding bit to 1.

[0201] S328 summarizes the occlusion status of each target model. For target models that are not fully occluded, save their occlusion masks, and filter out a list of target models that are not occluded and contain occlusion masks from all target models to execute step S33. For the remaining fully occluded target models, skip these target models.

[0202] Specifically, in one embodiment of the present invention, step S33 includes:

[0203] According to the boxCollider.bounds under the BoxCollider bounding box, the world coordinates of the eight vertices of the box collider of the target model are obtained, as shown below:

[0204]

[0205] In the above formula, ver[i] is a three-dimensional array defined to store the coordinates of 8 vertices, bounds is the bounding box information stored when the bounding box is automatically generated, which includes the center, size, maximum and minimum coordinate points of the bounding box in three-dimensional space, and bounds.max and bounds.min are the maximum and minimum coordinate points of the bounding box in three-dimensional space respectively;

[0206] For each vertex ver[i], use the Camera.WorldToScreenPoint method to convert it. The conversion formula is as follows:

[0207] screenPoint[i]=Camera.WorldToScreenPoint(ver[i])

[0208] Where screenPoint[i] is a Vector3 containing the screen coordinates (x, y) and the depth value z;

[0209] Calculate the maximum and minimum values ​​of the screen coordinates and create a rectangular box containing all vertices, that is, the marking box of the target on the screen. The rectangular box is calculated as follows:

[0210]

[0211] In the above formula: minX and minY are the screen coordinates of the minimum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, maxX and maxY are the screen coordinates of the maximum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, and Screen.height is the height of the screen.

[0212] In this embodiment, the visualization effect diagram of the target annotation box is as follows: Figure 2 shown.

[0213] Specifically, in one embodiment of the present invention, step S34 includes:

[0214] Check the Physical Camera option in the Camera component to enable the camera's physical property simulation.

[0215] Find the Allow Dynamic Resolution option in the Camera component and enable or disable it as needed to control dynamic resolution.

[0216] In the Physical Camera settings of the Camera component, adjust the Focal Length parameter, first to set a range, then to randomly choose a value each simulation.

[0217] Use the captureCamera.Render() method to trigger the camera rendering operation, draw the picture to the RenderTexture, randomize the resolution on the RenderTexture through new RenderTexture(), then pass the rendered image data into a new Texture2D object, and finally call the texture.EncodeToPNG() method to save the annotated image data of different resolutions.

[0218] Use the Transform.rotation property to change the rotation of the camera. Set an angle range on the X and Y axes (such as -30 degrees to 30 degrees), and then randomly generate the rotation angle. Use the Quaternion.Euler() method to convert the angle to a rotation.

[0219] Modify the Y coordinate of the camera Transform to change the height. Set a reasonable height range (such as 1m to 10m), and then randomly select a value.

[0220] Create a parameter variation function that contains the randomization logic for all the above parameters. Control the frequency of parameter variation.

[0221] Specifically, in one embodiment of the present invention, step S35 includes:

[0222] Integrate OpenCV in Unity, use Unity's Camera.render method to render the camera view to RenderTexture, convert RenderTexture to Mat format that OpenCV can process to obtain the camera video stream;

[0223] Define the salt and pepper noise density, randomly select pixels and set them to black or white;

[0224] Define the mean and standard deviation of Gaussian noise, and add a random value that conforms to the Gaussian distribution to each pixel;

[0225] Randomly add salt and pepper noise or Gaussian noise to each frame of the camera video stream.

[0226] Let's take a specific example:

[0227] First, you need to integrate the OpenCV library into your Unity project. Create a RenderTexture asset in Unity and set its resolution to match the desired output size. Set the camera's targetTexture property to this RenderTexture, and the camera's view will be rendered to this texture instead of being output directly to the screen.

[0228] In each frame, call the Camera.Render() method to ensure that the camera view is rendered to the RenderTexture. Then, use Texture2D.ReadPixels to copy the contents of the RenderTexture into a readable and writable Texture2D object.

[0229] Create an OpenCV Mat object that matches the size of the Texture2D. Transfer the raw pixel data of the Texture2D directly to the Mat object using the Utils.texture2DToMat method. Make sure to handle pixel format conversions correctly.

[0230] Create adjustable parameters to control the noise characteristics. For salt and pepper noise, define a floating point number representing the noise density, and for Gaussian noise, define the mean (usually 0) and standard deviation.

[0231] Iterate over each pixel of Mat. For each pixel, generate a random number and compare it with the predefined noise density. If the random number is less than the noise density, randomly set the pixel to black (0,0,0) or white (255,255,255).

[0232] Create a noise Mat of the same size as the original Mat and fill it with random values ​​that conform to the Gaussian distribution using OpenCV's randn() function. Then, add this noise Mat to the original image using the addWeighted() function.

[0233] At each frame, a random number generator is used to decide whether to add salt and pepper noise, Gaussian noise, or neither. This increases the diversity of the output.

[0234] After processing the noise, copy the Mat data back to Texture2D for display. You can use the Utils.matToTexture2D method to do this.

[0235] Create a UI element to display the processed image (such as RawImage). Set the updated Texture2D as the texture of this UI element.

[0236] Specifically, in one embodiment of the present invention, step S36 includes:

[0237] Create a new Shader file in Unity, name it InfraredEffect, and write the vertex shader and fragment shader;

[0238] Implement infrared effects, including converting color space, applying temperature mapping, adding hotspot effects, and simulating thermal radiation blur;

[0239] Create a material and set its shader to the InfraredEffect just created, and apply this material to the Camera through the post-processing stack;

[0240] Add adjustable parameters, including temperature range and contrast, and dynamically modify the adjustable parameters at runtime to simulate different infrared imaging effects and generate infrared target images.

[0241] Let's take a specific example:

[0242] In the Unity project, right-click the Assets folder, select Create>Shader>Unlit Shader, name it InfraredEffect, and create a Shader file.

[0243] In the shader file, find the vertex shader function. Modify this function to pass the necessary data to the fragment shader, including the vertex position and UV coordinates.

[0244] Implement the main infrared effect logic in the fragment shader function, including:

[0245] Color space conversion: Convert from RGB color space to a color space more suitable for representing temperature, such as HSV or YUV.

[0246] Temperature Mapping: Create a temperature mapping function based on the converted color values. Map the brightness value to a predefined temperature color range, such as from dark blue (cold) to bright red (hot).

[0247] Hotspot Effect: Generates hotspots using world space positions or texture coordinates. Simulates heat sources or high temperature areas by increasing brightness or changing color at specific locations.

[0248] Heat Radiant Blur: Applies a Gaussian blur or similar blur effect to simulate the spread of heat radiation.

[0249] Create a new material in Unity and set its shader property to the InfraredEffectshader you just created.

[0250] Use Unity's Post-processing Stack to apply this effect. Add a Post-process Layer component to the camera, then create a Post-process Volume and set its profile to contain the newly created infrared effect material.

[0251] Define properties in the shader, such as _TemperatureRange (for controlling the temperature range) and _Contrast (for adjusting the contrast). In Unity's Inspector, these parameters are automatically displayed, allowing adjustments at runtime.

[0252] Create a C# script to control these parameters. Use the Material.SetFloat() or Material.SetVector() methods to modify the shader's property values ​​at runtime.

[0253] The camera renders the scene using this shader, producing an infrared effect. To capture this effect as an image, render the view into a texture using the Camera.RenderToCubemap() method, and then save this texture as an image file.

[0254] Specifically, in one embodiment of the present invention, step S4 includes:

[0255] S41 automatically generates a category file in txt format according to the tag name of the target in the scene, generates an infrared target image, and stores the image in an image file.

[0256] Create a C# script to scan all objects with a specific Tag in the scene, using HashSet <string>To store unique tag names to avoid duplication, iterate over all objects in the scene, sort the collected unique tag names in alphabetical order, and assign an index number starting from 0. Create a text file called "classes.txt" and write each class name and corresponding index number to the file, one class per line.

[0257] Using the target infrared image of the infrared effect generated in step S3, create a unique file name for each generated image and use the System.IO.File.WriteAllBytes() method to save the image to the specified image folder.

[0258] S42 generates a txt format annotation file based on the target's annotation box on the screen. The annotation file contains the object's category number, the center position of the target object in the image, and the width and height of the target object. At this point, when the Unity3D project is closed, a Yolo format marine infrared target dataset is automatically generated.

[0259] First, add a custom component for each target object to be annotated to store its category information. Use the Camera.WorldToScreenPoint() method to convert the world coordinates of the target object's bounding box to screen coordinates. Since similar Labelimg annotation software uses the upper left corner of the image as the origin (0,0) to annotate the target coordinates, and the screen coordinates in Unity use the lower left corner as the origin (0,0), the screen coordinates of the bounding box are converted and the bounding box coordinates are recalculated with the upper left corner as the origin. Calculate the bounding box of the target object on the screen based on the bounding box, that is, the annotation box of the target, and then normalize the image to obtain the coordinate value in Yolo format and save it.

[0260] Yolo format requirements: Category ID, x center ,y center ,width,height (all values ​​are relative to the image size). Convert viewport coordinates to relative coordinates: x center and center It is the ratio of the center point of the object to the width and height of the image. To calculate the width and height: divide the screen width and height of the object by the width and height of the image.

[0261] Create a corresponding .txt file for each generated image. The file name is the same as the image file name. For each target object in the image, write a line of annotation data in the format of "category ID, center point x coordinate, center point y coordinate, width, height". Use the System.IO.File.WriteAllLines() method to write all lines to the text file.

[0262] Create a main control script and add a menu item or button in the Unity editor to trigger the dataset generation process. Implement a coroutine to handle the entire generation process, including scene traversal, image rendering, data calculation, and file saving. Add a progress bar display and display the generation progress in the Unity editor through EditorUtility.DisplayProgressBar().

[0263] Create a dedicated folder in the project root directory to store the generated dataset, such as "YOLODataset". Create subfolders in this folder: images to store all generated infrared images. labels to store the corresponding annotation files. Save the classes.txt file in the dataset root directory.

[0264] Create a simple text file to record basic information about the dataset, such as the total number of images, the number of samples in each category, the image resolution, etc.

[0265] In this embodiment, according to the above process, a marine infrared target dataset that meets the Yolo format requirements is automatically generated. This dataset will contain infrared images, corresponding annotation files and category information files, and can be directly used to train the YOLO model.

[0266] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.< / string> < / boxcollider> < / meshfilter>

Claims

1. A method for automatically generating a virtual data set for marine infrared target recognition, characterized in that: include: S1 builds a marine target model, imports the target model into Unity3D, and sets it as a prefab; S2 constructs a virtual ocean environment and randomly generates target model instances within a preset range; S3 generates a bounding box for the target model and sets the camera to generate an infrared target image; Step S3 includes: S31 obtains the Mesh of the target model and its sub-objects, obtains the AABB bounding box of the target through the Mesh, combines the size, center point and target data of the AABB bounding box into the OBB bounding box of the target, and adds a box-type collision body to all target models; S32 performs occlusion detection on all target models using an occlusion detection algorithm. If a target model is completely occluded, the target model is skipped. Otherwise, step S33 is executed on the target model. S33 obtains the world coordinates of the box-shaped collision body of the target model, converts the world coordinates to screen coordinates according to the Camera.WorldToScreenPoint method, calculates the maximum and minimum values ​​of the screen coordinates, and creates a label box containing all vertices; S34 enables Use Physical Properties, controls the Allow Dynamic Resolution and Focal Length of the Camera, sets the resolution and focal length, and randomly changes the angle and height of the Camera to simulate different viewing angles; S35 uses OpenCV to randomly add salt and pepper noise and Gaussian noise to the camera video stream; S36 writes and applies the shader that realizes the infrared effect to generate the infrared target image; S4 generates a marine infrared target dataset in Yolo format based on infrared target images.

2. A method for automatically generating a virtual data set for marine infrared target recognition as claimed in claim 1, characterized in that: Step S1 includes: S11 used Maya to build models of marine targets according to various targets, including cruise ships, bulk carriers, warships, sailboats, kayaks, container ships and fishing boats; S12 sets the material map UV for all targets, adds the normal map and bakes it; S13 exports all target models to FBX format and imports the target models into Unity3D; S14 converts the imported target model into a Prefab prefab in Unity3D, and sets a tag corresponding to the target name for each prefab in the Inspector panel.

3. The method for automatically generating a virtual data set for marine infrared target recognition according to claim 1, characterized in that: Step S2 includes: S21 builds an ocean environment based on Unity Ocean System URP, which randomly adjusts the light, waves and ripple effects, and defines the range of the ocean environment according to the size and distribution of different targets; S22 uses the Instantiate method to randomly generate target model instances within the defined marine environment; S23 randomizes environmental parameters, including weather conditions, time, and sea conditions.

4. The method for automatically generating a virtual data set for marine infrared target recognition according to claim 1, characterized in that: Step S32 includes: S321 uses the box-shaped collision body of the created target model to construct the scene octree, optimize the space division, perform frustum culling, quickly exclude the target model outside the camera's field of view, and perform depth sorting on the remaining target models; S322 defines a key point K={v1, v2, ..., v8, c} for each target model based on the OBB bounding box, where v1 to v8 are eight vertices of the OBB bounding box, and c is the center point of the OBB bounding box; S323 calculates the screen projection area A of each target model at the current viewing angle according to the camera parameters and the key point K; S324 dynamically adjusts the ray sampling density of each target model according to the projection area A, and generates a sampling point set in the OBB bounding box; S325: for each target model, generating a ray set according to the sampling point set, emitting rays from the camera to the sampling point set, and calculating the ray hit rate of each target model; S326: Preliminarily determine the occlusion state of each target model based on the ray hit rate and the dynamic threshold. The occlusion state is divided into unoccluded, fully occluded, and partially occluded. For a non-fully occluded target model, execute step S327; S327 divides the non-fully occluded target model into 3*3 grid sub-regions, calculates the occlusion degree of each sub-region respectively, and generates an occlusion mask containing partial occlusion information; S328 summarizes the occlusion status of each target model. For target models that are not fully occluded, save their occlusion masks, and filter out a list of target models that are not occluded and contain occlusion masks from all target models to execute step S33. For the remaining fully occluded target models, skip these target models.

5. The method for automatically generating a virtual data set for marine infrared target recognition according to claim 4, characterized in that: Step S324 includes: Step 1: Set the basic sampling density ρ base , calculate the ray sampling density based on the projection area A: r final =ρ adaptive ×f distance ×f importance r adaptive =ρ base ×log(1+A / A ref ) f importance =1+α×p In the formula, ρ final is the ray sampling density, ρ adaptive is the adaptive density, f distance is the distance factor, f importance is the importance factor, A ref is the reference projection area, d is the distance from the center point c of the OBB bounding box to the camera, and d ref is the reference distance, α is the adjustable coefficient, and p is the normalized importance score; Step 2: Calculate the number of rays based on the ray sampling density: N=ceil(ρ final ×A) Where N is the number of rays, and ceil represents the upward rounding function; Step 3: Set the upper and lower limits of the number of rays: N=clamp(N,N min ,N max ) Where clamp represents the restriction function. If the calculated number of rays N is less than N min , then use N min As the number of rays, if the calculated number of rays N is greater than N max , then use N max As the number of rays, if the calculated number of rays N is N min and N max If it is between , the original value is maintained; Step 4: Sort the six faces of the OBB bounding box by area and calculate the relative area ratio of each face; Step 5: For each sampling point, randomly select a face according to the relative area ratio of the faces; Step 6: Generate two random numbers u and v in the range of [0,1] on the selected surface, and use these two random numbers as the local coordinates of the surface; Step 7: Convert the local coordinates (u, v) to the global coordinate system of OBB; Step 8: Repeat steps 5 to 7 until N sampling points are generated.

6. A method for automatically generating a virtual data set for marine infrared target recognition as claimed in claim 5, characterized in that: Step S325 includes: Define the scene geometry. The scene consists of a set of triangle meshes, each triangle is defined by three vertices and a normal vector; For each target model M, according to the sampling point set S = {s1, s2, ..., s N }, generate ray set R = {r1, r2, ... r N }, each ray r i Defined as: r i (t) = O + t * E i , where O is the optical center of the camera, E i From O to sampling point s i The unit direction vector of ; Use the spatial acceleration structure to optimize the intersection test between rays and scene geometry. Perform an intersection test for each ray: a. Set the initial step length Δt = Δt init , set the maximum number of iterations max iter , set the convergence threshold ε; b. For ray r i , let t = 0; c. Set the number of iterations iter = 1; d. Calculate the current point P = O + t * E i ; e. Find the scene geometry closest to P, calculate the distance D from P to the nearest scene geometry, if D < ε, then record the intersection point P i =P and the corresponding object O i , otherwise, let t = t + max (D * 0.8, Δt); f. If the scene geometry is not found, record P i is the point at infinity, O i is empty; g. Determine whether iter is equal to max iter If yes, the intersection test ends and the intersection point P is output. i and the corresponding object O i If not, let iter+1, and based on the current pixel density ρ pixel , calculate the ray precision adjustment factor ρ b is the benchmark pixel density, and the iteration step size is adjusted to Δt = Δt init / f res , adjust the convergence threshold ε=ε / f res , return to step d; Define the importance weight vector of the sampling points W = {w1,w2,...,w N }, calculate the distance attenuation factor λ is the attenuation coefficient, and the ray hit indication function is defined as: Calculate the ray hit rate: In the formula, H(r i ) is the ray r i The ray hit rate.

7. The method for automatically generating a virtual data set for marine infrared target recognition according to claim 1, characterized in that: Step S33 includes: According to the boxCollider.bounds under the BoxCollider bounding box, the world coordinates of the eight vertices of the box collider of the target model are obtained, as shown below: In the above formula, ver[i] is a three-dimensional array defined to store the coordinates of 8 vertices, bounds is the bounding box information stored when the bounding box is automatically generated, which includes the center, size, maximum and minimum coordinate points of the bounding box in three-dimensional space, and bounds.max and bounds.min are the maximum and minimum coordinate points of the bounding box in three-dimensional space respectively; For each vertex ver[i], use the Camera.WorldToScreenPoint method to convert it. The conversion formula is as follows: screenPoint[i]=Camera.WorldToScreenPoint(ver[i]) Where screenPoint[i] is a Vector3 containing the screen coordinates (x, y) and the depth value z; Calculate the maximum and minimum values ​​of the screen coordinates and create a rectangular box containing all vertices, that is, the marking box of the target on the screen. The rectangular box is calculated as follows: In the above formula: minX and minY are the screen coordinates of the minimum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, maxX and maxY are the screen coordinates of the maximum coordinate point after the coordinates of the 8 vertices of the box collider are converted to screen coordinates, and Screen.height is the height of the screen.

8. The method for automatically generating a virtual data set for marine infrared target recognition according to claim 1, characterized in that: Step S35 includes: Integrate OpenCV in Unity, use Unity's Camera.render method to render the camera view to RenderTexture, convert RenderTexture to Mat format that OpenCV can process to obtain the camera video stream; Define the salt and pepper noise density, randomly select pixels and set them to black or white; Define the mean and standard deviation of Gaussian noise, and add a random value that conforms to the Gaussian distribution to each pixel; Randomly add salt and pepper noise or Gaussian noise to each frame of the camera video stream.

9. A method for automatically generating a virtual data set for marine infrared target recognition as claimed in claim 8, characterized in that: Step S36 includes: Create a new Shader file in Unity, name it InfraredEffect, and write the vertex shader and fragment shader; Implement infrared effects, including converting color space, applying temperature mapping, adding hotspot effects, and simulating thermal radiation blur; Create a material and set its shader to the InfraredEffect just created, and apply this material to the Camera through the post-processing stack; Add adjustable parameters, including temperature range and contrast, and dynamically modify the adjustable parameters at runtime to simulate different infrared imaging effects and generate infrared target images.

Citation Information

Patent Citations

  • Virtual-reality modeling method of ocean water body

    CN101650837A

  • Data enhancement method and system based on digital twinning and image conversion

    CN114049422A