A method for extracting the three-dimensional position of video images
Through 3D modeling tools and Shader shader technology, UV mapping tables are built to achieve rapid correspondence between video images and three-dimensional positions, solving the problem of automatic extraction of three-dimensional positions of video images in the existing technology, and improving the portability and real-time nature of the system.
Patent Information
- Application Number
- CN202111351609.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-16
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2041-11-16
AI Technical Summary
The prior art is difficult to realize automatic extraction of three-dimensional positions of video images, resulting in the matching of three-dimensional scenes and video images positions that require manual operation and cannot track dynamic targets in real time.
Create a real-site three-dimensional scene through 3D modeling tools, set up a virtual camera and calibrate its angle, use Shader shader to build a UV mapping table, extract the three-dimensional position of the pixel points of the video image, and achieve the fast correspondence between the video image and the three-dimensional position.
It realizes automatic extraction of three-dimensional positions of video images, improves the portability and real-time nature of the system, and can quickly batch extract three-dimensional scene position information, saving labor costs.
Smart Images

Figure CN114220042B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image signal processing, and in particular to a method for extracting three-dimensional positions of video images. Background Art
[0002] Nowadays, video image acquisition technology has become very mature and common. Video acquisition equipment is installed in places ranging from communities to entire cities, and video images can be captured in real time.
[0003] With the development of computer technology, 3D technology, especially 3D modeling technology, has also made great progress in recent years. This technology is widely used in the display of urban communities. Visitors can see the scenery of urban communities at a glance from the 3D simulation model scene displayed on the screen combined with the real-life images.
[0004] However, how to match the position of the 3D scene with the position of the image captured by the video capture device in real time is an engineering difficulty that needs to be solved urgently. At present, manual methods are often used to record the installation locations of the video capture devices one by one, and roughly and tediously match them with the positions in the 3D scene. This method not only makes the portability of the entire display system poor, because each time it is deployed in a new location, it is necessary to manually match the position of the 3D scene and the video image again; it is also impossible to track dynamic targets in the video image in real time in the 3D scene, such as a moving car. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, a method for extracting three-dimensional positions of video images provided by the present invention solves the problem of automatically extracting three-dimensional positions of video images.
[0006] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: a method for extracting three-dimensional position of a video image, comprising the following steps:
[0007] S1. Use 3D modeling tools to create a real-life three-dimensional scene;
[0008] S2. According to the position of the video image acquisition device at the real scene, a virtual camera is set at the corresponding position of the three-dimensional scene, and the angle between the video image acquisition device and the virtual camera is calibrated;
[0009] S3, constructing a UV mapping table for the three-dimensional scene through the Shader shader;
[0010] S4. According to the UV mapping table, the three-dimensional position corresponding to the pixel point of the video image captured by each virtual camera is extracted to realize the rapid finding of the three-dimensional position through the pixel position of the video image.
[0011] Furthermore, the step S3 includes the following sub-steps:
[0012] S301. Color the U-axis coordinates of the 3D scene using a Shader shader;
[0013] S302. Collect the pixel values of the 3D scene after U-axis coordinate coloring;
[0014] S303. Obtain the U-axis coordinate values from the pixel values of the 3D scene after U-axis coordinate coloring according to the pixel conversion equations;
[0015] S304. Color the V-axis coordinates of the 3D scene using a Shader shader;
[0016] S305. Collect the pixel values of the 3D scene after V-axis coordinate coloring;
[0017] S306. Obtain the V-axis coordinate values from the pixel values of the 3D scene after V-axis coordinate coloring according to the pixel conversion equations;
[0018] S307. Color the X-axis coordinates of the 3D scene using a Shader shader;
[0019] S308. Collect the pixel values of the 3D scene after X-axis coordinate coloring;
[0020] S309. Obtain the X-axis coordinate values from the pixel values of the 3D scene after X-axis coordinate coloring according to the pixel conversion equations;
[0021] S310. Color the X-axis symbols of the 3D scene using a Shader shader;
[0022] S311. Collect the pixel values of the 3D scene after X-axis symbol coloring;
[0023] S312. Obtain the X-axis symbol values from the pixel values of the 3D scene after X-axis symbol coloring according to the pixel conversion equations;
[0024] S313. Color the Y-axis coordinates of the 3D scene using a Shader shader;
[0025] S314. Collect the pixel values of the 3D scene after Y-axis coordinate coloring;
[0026] S315. Obtain the Y-axis coordinate values from the pixel values of the 3D scene after Y-axis coordinate coloring according to the pixel conversion equations;
[0027] S316. Color the Y-axis symbols of the 3D scene using a Shader shader;
[0028] S317. Collect the pixel values of the 3D scene after Y-axis symbol coloring;
[0029] S318. Obtain the Y-axis symbol value from the pixel values of the three-dimensional scene colored by the Y-axis symbol according to the pixel conversion equation set;
[0030] S319. Color the three-dimensional scene with the Z-axis coordinate through the Shader shader;
[0031] S320. Collect the pixel values of the three-dimensional scene colored by the Z-axis coordinate;
[0032] S321. Obtain the Z-axis coordinate value from the pixel values of the three-dimensional scene colored by the Z-axis coordinate according to the pixel conversion equation set;
[0033] S322. Color the three-dimensional scene with the Z-axis symbol through the Shader shader;
[0034] S323. Collect the pixel values of the three-dimensional scene colored by the Z-axis symbol;
[0035] S324. Obtain the Z-axis symbol value from the pixel values of the three-dimensional scene colored by the Z-axis symbol according to the pixel conversion equation set;
[0036] S325. Calculate the three-dimensional position of each pixel of the three-dimensional scene according to the X-axis coordinate value, X-axis symbol value, Y-axis coordinate value, Y-axis symbol value, Z-axis coordinate value and Z-axis symbol value of each pixel of the three-dimensional scene through the three-dimensional coordinate calculation equation set, and construct a UV mapping table representing the UV coordinate-three-dimensional position mapping relationship according to the U-axis coordinate value and V-axis coordinate value.
[0037] Further, the pixel conversion equation set in steps S303, S306, S309, S312, S315, S318, S321, and S324 includes the following equations:
[0038] R = frac(d·1)·255 (1)
[0039] G = frac(d·255)·255 (2)
[0040] B = frac(d·255·255)·255 (3)
[0041] A = frac(d·255·255·255)·255 (4)
[0042] Rlt = Vector(R, G, B, A)·
[0043] Vector(1, 1 / 255, 1 / (255·255), 1 / (255·255·255)) (5)
[0044] Wherein, R is the red component, G is the green component, B is the blue component, A is the transparency component, frac() is a function that takes the fractional part of the variable in the parentheses, Vector() is a four-dimensional vector function, d is the input value of the pixel conversion equation system, and Rlt is the output value of the pixel conversion equation system.
[0045] Further, the three-dimensional coordinate calculation equation system in step S325 includes the following equations:
[0046] tX = x · sX (6)
[0047] tY = y · sY (7)
[0048] tZ = z · sZ (8)
[0049] Wherein, x is the X-axis coordinate value, sX is the X-axis sign value, y is the Y-axis coordinate value, sY is the Y-axis sign value, z is the Z-axis coordinate value, sZ is the Z-axis sign value, tX is the three-dimensional position X coordinate value, tY is the three-dimensional position Y coordinate value, and tZ is the three-dimensional position Z coordinate value.
[0050] Further, step S4 includes the following sub-steps:
[0051] S41. Obtain the abscissa I and ordinate J of each pixel point in the video image captured by each virtual camera;
[0052] S42. Obtain the width A and height B of the video image;
[0053] S43. Calculate the U-axis coordinate value and V-axis coordinate value of each pixel point in the video image through the following two formulas:
[0054] u = I / A (9)
[0055] v = J / B (10)
[0056] Wherein, u is the U-axis coordinate value and v is the V-axis coordinate value.
[0057] S44. According to the UV mapping table, obtain the three-dimensional position of each pixel point in the video image through the U-axis coordinate value and V-axis coordinate value of each pixel point, so as to quickly find the three-dimensional position through the pixel position of the video image.
[0058] The beneficial effects of the present invention are as follows: By using a 3D modeling tool, a three-dimensional scene of the real scene is established. The Shader shader is used to color the X-axis coordinate, X-axis symbol, Y-axis coordinate, Y-axis symbol, Z-axis coordinate, and Z-axis symbol. The pixel values of the colored three-dimensional scene are used to obtain the X-axis coordinate value, X-axis symbol value, Y-axis coordinate value, Y-axis symbol value, Z-axis coordinate value, and Z-axis symbol value according to the pixel conversion equation set. Through the three-dimensional coordinate calculation equation set, the three-dimensional position of each pixel in the three-dimensional scene is calculated, and a UV mapping table representing the UV coordinate-three-dimensional position mapping relationship is constructed based on the U-axis coordinate value and V-axis coordinate value. According to the UV mapping table, the three-dimensional positions of the video images captured by each virtual camera are extracted, so as to quickly find the three-dimensional position through the pixel positions of the video images; through the present invention, the three-dimensional scene position information of the video images can be batch-extracted quickly, saving labor costs and meeting the real-time requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a schematic flow chart of a method for extracting the three-dimensional position of a video image. DETAILED DESCRIPTION OF THE INVENTION
[0060] The following describes the specific embodiments of the present invention to facilitate those skilled in the art to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions made using the concept of the present invention are within the scope of protection.
[0061] As Figure 1 shown, in an embodiment of the present invention, a method for extracting the three-dimensional position of a video image includes the following steps:
[0062] S1. Establish a three-dimensional scene of the real scene through a 3D modeling tool.
[0063] S2. Set virtual cameras at corresponding positions in the three-dimensional scene according to the positions of the video image acquisition devices in the real scene, and calibrate the angles between the video image acquisition devices and the virtual cameras.
[0064] S3. Construct a UV mapping table for the three-dimensional scene through the Shader shader, including the following sub-steps:
[0065] S301. Color the U-axis coordinate of the three-dimensional scene through the Shader shader;
[0066] S302. Collect the pixel values of the three-dimensional scene after U-axis coordinate coloring;
[0067] S303. Obtain the U-axis coordinate value from the pixel value of the three-dimensional scene colored by the U-axis coordinate according to the pixel conversion equation system;
[0068] S304. Perform V-axis coordinate coloring on the three-dimensional scene through the Shader shader;
[0069] S305. Collect the pixel value of the three-dimensional scene colored by the V-axis coordinate;
[0070] S306. Obtain the V-axis coordinate value from the pixel value of the three-dimensional scene colored by the V-axis coordinate according to the pixel conversion equation system;
[0071] S307. Perform X-axis coordinate coloring on the three-dimensional scene through the Shader shader;
[0072] S308. Collect the pixel value of the three-dimensional scene colored by the X-axis coordinate;
[0073] S309. Obtain the X-axis coordinate value from the pixel value of the three-dimensional scene colored by the X-axis coordinate according to the pixel conversion equation system;
[0074] S310. Perform X-axis symbol coloring on the three-dimensional scene through the Shader shader;
[0075] S311. Collect the pixel value of the three-dimensional scene colored by the X-axis symbol;
[0076] S312. Obtain the X-axis symbol value from the pixel value of the three-dimensional scene colored by the X-axis symbol according to the pixel conversion equation system;
[0077] S313. Perform Y-axis coordinate coloring on the three-dimensional scene through the Shader shader;
[0078] S314. Collect the pixel value of the three-dimensional scene colored by the Y-axis coordinate;
[0079] S315. Obtain the Y-axis coordinate value from the pixel value of the three-dimensional scene colored by the Y-axis coordinate according to the pixel conversion equation system;
[0080] S316. Perform Y-axis symbol coloring on the three-dimensional scene through the Shader shader;
[0081] S317. Collect the pixel value of the three-dimensional scene colored by the Y-axis symbol;
[0082] S318. Obtain the Y-axis symbol value from the pixel value of the three-dimensional scene colored by the Y-axis symbol according to the pixel conversion equation system;
[0083] S319. Perform Z-axis coordinate coloring on the three-dimensional scene through the Shader shader;
[0084] S320. Collect the pixel values of the three-dimensional scene after Z-axis coordinate coloring;
[0085] S321. Obtain the Z-axis coordinate values from the pixel values of the three-dimensional scene after Z-axis coordinate coloring according to the pixel conversion equation system;
[0086] S322. Perform Z-axis symbol coloring on the three-dimensional scene through a Shader shader;
[0087] S323. Collect the pixel values of the three-dimensional scene after Z-axis symbol coloring;
[0088] S324. Obtain the Z-axis symbol values from the pixel values of the three-dimensional scene after Z-axis symbol coloring according to the pixel conversion equation system;
[0089] S325. Calculate the three-dimensional position of each pixel in the three-dimensional scene according to the X-axis coordinate value, X-axis symbol value, Y-axis coordinate value, Y-axis symbol value, Z-axis coordinate value, and Z-axis symbol value of each pixel in the three-dimensional scene through the three-dimensional coordinate calculation equation system, and construct a UV mapping table representing the UV coordinate - three-dimensional position mapping relationship according to the U-axis coordinate value and V-axis coordinate value.
[0090] In steps S303, S306, S309, S312, S315, S318, S321, and S324, the pixel conversion equation system includes the following equations:
[0091] R = frac(d·1)·255 (1)
[0092] G = frac(d·255)·255 (2)
[0093] B = frac(d·255·255)·255 (3)
[0094] A = frac(d·255·255·255)·255 (4)
[0095] Rlt = Vector(R, G, B, A)·
[0096] Vector(1, 1 / 255, 1 / (255·255), 1 / (255·255·255)) (5)
[0097] Among them, R is the red component, G is the green component, B is the blue component, A is the transparency component, frac() is a function to take the fractional part of the variable in the parentheses, Vector() is a four-dimensional vector function, d is the input value of the pixel conversion equation system, and Rlt is the output value of the pixel conversion equation system.
[0098] The three-dimensional coordinate calculation equation system in step S325 includes the following equations:
[0099] tX = x · sX (6)
[0100] tY = y · sY (7)
[0101] tZ = z · sZ (8)
[0102] Wherein, x is the coordinate value of the X-axis, sX is the symbol value of the X-axis, y is the coordinate value of the Y-axis, sY is the symbol value of the Y-axis, z is the coordinate value of the Z-axis, sZ is the symbol value of the Z-axis, tX is the X coordinate value of the three-dimensional position, tY is the Y coordinate value of the three-dimensional position, and tZ is the Z coordinate value of the three-dimensional position.
[0103] S4. According to the UV mapping table, extract the three-dimensional positions corresponding to the pixel points of the video images captured by each virtual camera, so as to quickly find the three-dimensional positions through the pixel positions of the video images;
[0104] Step S4 includes the following sub-steps:
[0105] S41. Obtain the abscissa I and ordinate J of each pixel point in the video images captured by each virtual camera;
[0106] S42. Obtain the width A and height B of the video image;
[0107] S43. Calculate the U-axis coordinate value and V-axis coordinate value of each pixel point of the video image through the following two formulas:
[0108] u = I / A (9)
[0109] v = J / B (10)
[0110] Wherein, u is the U-axis coordinate value and v is the V-axis coordinate value.
[0111] S44. According to the UV mapping table, obtain the three-dimensional positions of each pixel point of the video image through the U-axis coordinate value and V-axis coordinate value of each pixel point, so as to quickly find the three-dimensional positions through the pixel positions of the video images.
Claims
1. A method for extracting the three-dimensional position of a video image, characterized in that, It includes the following steps: S1. Establish a three-dimensional scene of the real site through a 3D modeling tool; S2. Set virtual cameras at corresponding positions in the three-dimensional scene according to the positions of the video image acquisition devices at the real site, and calibrate the angles between the video image acquisition devices and the virtual cameras; S3. Construct a UV mapping table for the three-dimensional scene through a Shader shader; S4. According to the UV mapping table, extract the three-dimensional positions corresponding to the pixel points of the video images captured by each virtual camera, and realize quickly finding the three-dimensional positions through the pixel positions of the video images; The step S3 includes the following sub-steps: S301. Color the three-dimensional scene with the U-axis coordinate through the Shader shader; S302. Collect the pixel values of the three-dimensional scene after being colored with the U-axis coordinate; S303. Obtain the U-axis coordinate values from the pixel values of the three-dimensional scene colored with the U-axis coordinate according to the pixel conversion equation system; S304. Color the three-dimensional scene with the V-axis coordinate through the Shader shader; S305. Collect the pixel values of the three-dimensional scene after being colored with the V-axis coordinate; S306. Obtain the V-axis coordinate values from the pixel values of the three-dimensional scene colored with the V-axis coordinate according to the pixel conversion equation system; S307. Color the three-dimensional scene with the X-axis coordinate through the Shader shader; S308. Collect the pixel values of the three-dimensional scene after being colored with the X-axis coordinate; S309. Obtain the X-axis coordinate values from the pixel values of the three-dimensional scene colored with the X-axis coordinate according to the pixel conversion equation system; S310. Color the three-dimensional scene with the X-axis symbol through the Shader shader; S311. Collect the pixel values of the three-dimensional scene after being colored with the X-axis symbol; S312. Obtain the X-axis symbol values from the pixel values of the three-dimensional scene colored with the X-axis symbol according to the pixel conversion equation system; S313. Color the three-dimensional scene with the Y-axis coordinate through the Shader shader; S314. Collect the pixel values of the three-dimensional scene after being colored with the Y-axis coordinate; S315. Obtain the Y-axis coordinate values from the pixel values of the three-dimensional scene colored with the Y-axis coordinate according to the pixel conversion equation system; S316. Color the three-dimensional scene with the Y-axis symbol through the Shader shader; S317. Collect the pixel values of the three-dimensional scene after being colored with the Y-axis symbol; S318. Obtain the Y-axis symbol values from the pixel values of the three-dimensional scene colored with the Y-axis symbol according to the pixel conversion equation system; S319. Color the three-dimensional scene with the Z-axis coordinate through the Shader shader; S320. Collect the pixel values of the three-dimensional scene after being colored with the Z-axis coordinate; S321. Obtain the Z-axis coordinate values from the pixel values of the three-dimensional scene colored with the Z-axis coordinate according to the pixel conversion equation system; S322. Color the three-dimensional scene with the Z-axis symbol through the Shader shader; S323. Collect the pixel values of the three-dimensional scene after being colored with the Z-axis symbol; S324. Obtain the Z-axis symbol values from the pixel values of the three-dimensional scene colored with the Z-axis symbol according to the pixel conversion equation system; S325. Based on the X-axis coordinate value, X-axis sign value, Y-axis coordinate value, Y-axis sign value, Z-axis coordinate value, and Z-axis sign value of each pixel in the three-dimensional scene, calculate the three-dimensional position of each pixel in the three-dimensional scene through a three-dimensional coordinate calculation system of equations, and construct a UV mapping table that characterizes the UV coordinate-three-dimensional position mapping relationship according to the U-axis coordinate value and V-axis coordinate value.
2. The method for extracting the three-dimensional position of a video image according to claim 1, characterized in that, The pixel conversion system of equations in the steps S303, S306, S309, S312, S315, S318, S321, and S324 includes the following equations: R = frac(d·1)·255 (1) G = frac(d·255)·255 (2) B = frac(d·255·255)·255 (3) A = frac(d·255·255·255)·255 (4) Rlt = Vector(R, G, B, A)·Vector(1, 1 / 255, 1 / (255·255), 1 / (255·255·255)) (5) Among them, R is the red component, G is the green component, B is the blue component, A is the transparency component, frac() is a function that takes the fractional part of the variable in the parentheses, Vector() is a four-dimensional vector function, d is the input value of the pixel conversion system of equations, and Rlt is the output value of the pixel conversion system of equations.
3. The video image three-dimensional position extraction method according to claim 1, characterized in that, The three-dimensional coordinate calculation system of equations in the step S325 includes the following equations: tX = x·sX (6) tY = y·sY (7) tZ = z·sZ (8) Among them, x is the X-axis coordinate value, sX is the X-axis sign value, y is the Y-axis coordinate value, sY is the Y-axis sign value, z is the Z-axis coordinate value, sZ is the Z-axis sign value, tX is the X coordinate value of the three-dimensional position, tY is the Y coordinate value of the three-dimensional position, and tZ is the Z coordinate value of the three-dimensional position.
4. The video image three-dimensional position extraction method according to claim 1, characterized in that, The step S4 includes the following sub-steps: S41. Obtain the abscissa I and ordinate J of each pixel point in the video image captured by each virtual camera; S42. Obtain the width A and height B of the video image; S43. Calculate the U-axis coordinate value and V-axis coordinate value of each pixel point in the video image through the following two equations: u = I / A (9) v = J / B (10) Among them, u is the U-axis coordinate value and v is the V-axis coordinate value; S44. According to the UV mapping table, obtain the three-dimensional position of each pixel point in the video image through the U-axis coordinate value and V-axis coordinate value of each pixel point, and realize quickly finding the three-dimensional position through the pixel position of the video image.
Citation Information
Patent Citations
3D (three-dimensional) visualization method for coverage range based on quick estimation of attitude of camera
CN103400409A
Planet effect graph generation method
CN108921778A