CN101488229A - PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method - Google Patents

PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method Download PDF

Info

Publication number
CN101488229A
CN101488229A CNA2009100251210A CN200910025121A CN101488229A CN 101488229 A CN101488229 A CN 101488229A CN A2009100251210 A CNA2009100251210 A CN A2009100251210A CN 200910025121 A CN200910025121 A CN 200910025121A CN 101488229 A CN101488229 A CN 101488229A
Authority
CN
China
Prior art keywords
dimensional
function
stereo
api
matrix
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CNA2009100251210A
Other languages
Chinese (zh)
Other versions
CN101488229B (en
Inventor
闾国年
温永宁
盛业华
吴明光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changshu Zijin Intellectual Property Service Co.,Ltd.
Original Assignee
Nanjing Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Normal University filed Critical Nanjing Normal University
Priority to CN2009100251210A priority Critical patent/CN101488229B/en
Publication of CN101488229A publication Critical patent/CN101488229A/en
Application granted granted Critical
Publication of CN101488229B publication Critical patent/CN101488229B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention relates to an implanted actual three-dimensional rendering method oriented to a PCI three-dimensional analysis module, comprising: adopting implanted rendering data interception technology between calling of 3D API adopted by the PCI three-dimensional analysis module and display of a display card to capture an original single-channel color signal, a depth signal, a three-dimensional scene transformation matrix and a projection transformation matrix; analyzing the information to reconstruct grid three-dimensional data; based on the stereoscopic vision principle, self-adaptively retransforming the scene to two different view point positions so as to form a binocular vision stereopair for stereoscopic display, and driving the display card to carry out stereoscopic output on the binocular vision stereopair; and utilizing polarization, red-green and blinking type glasses and the like to carry out actual three-dimensional display and observation. The method can realize the actual three-dimensional scene display for the current PCI three-dimensional analysis module under the condition of not changing programs and operation modes.

Description

Implantation type true three-dimensional stereo rendering method towards PCI three dimensional analysis module
Technical field
The present invention relates to the three-dimensional visualization technique field, be specifically related to a kind of implantation type true three-dimensional stereo rendering method towards PCI three dimensional analysis module software.
Background technology
Along with development of computer, stereo display has become fields such as environmental simulation, simulated training and planning and design technological means commonly used, even beginning combines the generation three-dimensional film with film, computer game etc. and true 3d gaming incorporates daily life.Satellite image is as a kind of important spatial data, can produce 3-D effect true to nature with the stack demonstration of DEM, PCI is the remote sensing analysis process software that Canadian Apollo company releases, three dimensional analysis module wherein can realize that the fusion of satellite image and landform shows, carries out three-dimensional flight simulation.
Realize that in three-dimensional applications stereoscopic vision is a kind of trend, on single display equipment, observe three-dimensional scenery, the image that images of left and right eyes is seen independently need be separated separately, make right and left eyes see that different images passes through the physiological action formation stereoscopic vision of brain by specific external device then.Traditional stereo display needs the equipment of specialty to carry out stereo display, comprises the video card of supporting left and right sides buffer memory and supports the stereoscopic display device that binary channels shows.Based on above-mentioned technology, produced widely popular virtual reality technology, obtained in fields such as machine emulation, battlefield simulations using widely.But, owing to need professional equipment, with high costs, also limited the application of stereo display technique, so the application of stereo display can not obtain promoting, a large amount of three-dimensional programs still adopts the single channel technology to show, lack stereoscopic sensation, lost the due stereo display characteristic of three-dimensional program.Simultaneously, because stereo display needs specialised hardware, special art of programming, also caused a large amount of programs when exploitation, not consider the stereo display characteristic, in program, do not realize supporting the function of stereo display, even make these programs can not show solid having on the hardware of three-dimensional display function.These programs have occupied the overwhelming majority of present 3-D display program, PCI three dimensional analysis module does not break through above-mentioned restriction yet, and it is in modeling process, and the user still can only see single pass perspective three dimensional, very three-dimensional stereo display can not be realized, best effect can not be reached.
Summary of the invention
Problem to be solved by this invention is to overcome the deficiency that PCI three dimensional analysis module software exists in 3-D display, realize that the real tri-dimension that former software is not added modification shows.Core of the present invention is to utilize the ultimate principle of three-dimensional rendering, by color data and depth data in the interception video card result frame image, resolve the projective transformation matrix that generates the result frame image, the ultimate principle that applying three-dimensional is played up and the three-dimensional scenic of reconstructing grid, on this scene basis, use principle of stereoscopic vision, generate stereogram, based on different stereo display patterns, drive video card and carry out solid output.
The technical foundation that the present invention relies on is about the basic model of three-dimensional rendering in the computer graphics, be the basic model of the three-dimensional rendering of the 3D API that uses of PCI three dimensional analysis module software (current under Windows, use OpenGL), comprise the transformation pipeline, Z buffer zone algorithm on three-dimensional rendering streamline, summit etc.Realize that according to being OpenGL API and video card both all are based on this basic model and carry out work.The present invention makes this computer software realize the three-dimensional true 3-D display and the observation of binocular vision under the situation of not changing PCI three dimensional analysis module source code, binary code or computer hardware structure.
The ultimate principle that Computerized three-dimensional shows is with after three-dimensional scenic process geometric transformation and photo-irradiation treatment and the rasterizing, generates a width of cloth two-dimensional grid image and exports on output device.Comprise a series of three dimensional object in the three-dimensional scenic, three dimensional object is to be combined by the geometric graphic element (comprising some line and triangle) that a series of summits constitute.The summit is one and comprises three-dimensional space position and the corresponding coordinate points of playing up parameter thereof.At first vertex data is carried out perspective grid conversion and photo-irradiation treatment.In the coordinate transform stage, the summit of describing geometry of objects is transformed under the coordinate system that viewpoint is the center, carries out color and brightness that illumination calculation determines that each summit should have again.The basic display unit of computer graphics is a pixel, and these geometric objects are tiled into pixel, and it is medium to be shown that these pixels are sent to frame buffer at last, as shown in Figure 2.
In three-dimensional picture is played up, exist a series of coordinate transform, at last the coordinate transform of object itself is become the pixel coordinate on the two-dimensional screen.These coordinate transforms all with the previous step transformation results as output, constitute the streamline of an apex coordinate conversion, as shown in Figure 3.The coordinate of all three dimensional objects has all been arrived under the same coordinate system by unified, forms normalized coordinate through projection and cutting, forms image pixel by the rasterizing conversion.
Z buffer zone algorithm claims depth buffered algorithm again.Because the two dimensional surface coordinate can corresponding unlimited a plurality of three-dimensional coordinates under perspective projection.So what the geometric object of rasterizing had comprised each pixel correspondence is called the parameter of depth value to viewpoint, if the depth value of rasterizing geometric object pixel is less than original pixel, just replace the value of origin-location with the value of this pixel, this has just guaranteed that always nearest apart from viewpoint pixel is saved.
At above principle, realize that the technical scheme of the object of the invention is:
Towards the implantation type true three-dimensional stereo rendering method of PCI three dimensional analysis module, this method may further comprise the steps:
The 3D API that step (1) is used at PCI three dimensional analysis module monitors and plays up data interception;
Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
The concrete available the following step of method of the present invention realizes, the following step in no particular order:
A. the function of 3-D display environment is created in monitoring, in this function, add system's detection function function of calling 3D API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, stereo display pattern in the display environment of change original start, on the hardware of supporting stereo display, open real tri-dimension and show support, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display.
B. monitoring beginning one frame is drawn function, and the adding code obtains the viewport size when the pre-plot frame in this function, is that stereogram is created interim buffer zone according to the pixel format of playing up.
C. monitoring changes current drafting matrix function, in this function, add code to obtain of the change of three-dimensional applications software, by the projection type of matrix parameter identification scene rendering, when being perspective projection to current drafting matrix, write down this matrix, as the key parameter of three-dimensional scenic reconstruct;
D. monitor the function that frame buffer is outputed to display device, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on step c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel; According to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
In the described step (1) monitoring of 3D API with play up data interception and further comprise: utilize API interception technology, obtain the output of 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of 3D API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
3D API interception is meant and utilizes computer programming, the 3D api function that PCI three dimensional analysis module is used calls to be monitored, and the data of playing up that 3D API produces are tackled and insert self-defined code therein, reach the purpose that original API is monitored or realizes again.API tackles technology maturation and is widely used, as screen word-selecting software, anti-viral software, network firewall or the like.The 3D API of indication of the present invention plays up the some crucial 3D api function that interception is meant the interception specific function.
Also further comprise the concrete steps that realize the interception of 3D api function at it in the described step (1): at the 3D API (OpenGL) of PCI three dimensional analysis module use, inject or/and the Hook Function technology is write specific hook procedure by code, in the data load stage of three-dimensional visualization program, 3D API hook procedure is loaded in the process of three-dimensional visualization program, thus interception and monitoring 3D API Calls.The crucial function of the 3D API that indication of the present invention need be tackled is as follows:
(21) 3D API creates the function of 3-D display environment;
(22) 3D API begins the function of a frame scene rendering;
(23) 3D API changes the current function of playing up matrix;
(24) 3D API finishes the function of a frame scene rendering;
(25) 3D API will play up data and output to function on the current screen.
Described step (2) further comprises utilizes 3D API to output to color and depth data in the video card frame buffer, and the projective parameter that obtains in conjunction with interception 3D API Calls is resolved the three-dimensional spatial information that generates color image and depth data.Promptly, by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter (viewpoint position, hither plane, far plane) and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space.It specifically can comprise following steps:
I. the identification of perspective projection transformation matrix.In the render process of a frame scene, three-dimensional applications software may repeatedly be changed projective transformation matrix, has only perspective transformation matrix just can produce the perspective three dimensional effect.Be without loss of generality, suppose that the perspective projection transformation matrix is consistent in the render process of a frame, perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix.
II. setting up viewpoint is the three dimensional space coordinate system (being called for short eye coordinates system) of true origin.The perspective projection transformation matrix of intercepting and capturing with step I is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, the Y direction unanimity, hither plane is positioned on the scale of Z axle of hither plane value correspondence.The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2].In this coordinate system, (X, Y Z) can be tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer.Can get: X ' equals width/2*X/Z; Y ' equals height/2*Y/Z; Z ' equals (z-zNear)/z*zFar/ (zFar-zNear), and wherein Z ' is corresponding to the value in the depth buffer.
III. the reconstruct of rasterizing three-dimensional scenic data.If the width of viewport is width ', highly is height ' to be obtained by OpenGL API related function.By the proportionate relationship of viewport and the hither plane coordinate P of three-dimensional rendering two field picture pixel " ' (X " ' arbitrarily as can be known, Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn, yn, zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2.Value Z ' in the corresponding depth buffer, by Step II as can be known, corresponding eye coordinates system Z value down is Z ' * (zFar-zNear)/zFar+zNear, can get the coordinate P of pixel under eye coordinates system (X, Y, Z), wherein X equals xNear/zNear*Z, and Y equals yNear/zNear*Z.
By calling color buffer district function and the depth buffer function in the video card of reading of OpenGL API, utilize coordinate system and the above-mentioned relation set up in the Step II, can obtain the eye coordinates system three-dimensional coordinate of all pixels down.All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering, is playing up under the visual angle arbitrarily by the three-dimensional flow waterline on this surface.
" setting two different viewpoint positions and generate stereogram " in the described step (3) is the three-dimensional scenic that utilizes step (2) reconstruct, generates two width of cloth images, forms stereogram.The present invention proposes the stereo display model based on the three-dimensional scenic of " voxel ", so-called voxel is meant the three-dimensional coordinate of each pixel of the three-dimensional scenic of step (2) reconstruct and its corresponding view space composition sequence [(X together, Y, Z), (R, G, B)], a voxel space of formation.At each pixel in this space,, calculate its location of pixels point in new viewpoint according to the perspective transform principle.
Generate stereogram and can adopt following two kinds of methods:
Method one. call 3D API, play up the contextual data that obtains in the step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
Method two. adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space.Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.Wherein:
The viewpoint horizontal-shift is meant the change amount D of the new viewpoint original viewpoint of distance on X-direction x
The viewpoint vertical shift is meant the change amount D of the new viewpoint original viewpoint of distance on Z-direction z
Image pixel is offset, and is meant the additional offset D of the image pixel horizontal direction of generation Pixel
Then under another eye coordinates system, (the coordinate X that pixel Z) is marked under the left viewpoint is Width ' * (X-Dx)/(Z-Dz)+D for X, Y to primitive frame image mid point P Pixel, Y is Height ' * Y/ (Z-Dz).This pixel is under for right eye coordinates being, coordinate calculates according to the method described above, but Dx, Dz gets negative sign.
Each color of pixel is copied to the target location.Thereby two viewpoints are all used this method obtain stereogram.This method has without graphics pipeline, and program composition is simple, optimizes advantages such as easy.
" carry out true three-dimensional observation " in the described step (4) and be meant stereogram that step (3) is generated, by display device output and carry out stereoscopy at different stereoscopy equipment.The stereogram that the present invention generates is carried out true 3-D display in the following way:
X. the binocular solid of video card support shows.As supporting under the OpenGL API ring border of stereo display, creating the stereo display pattern that the equipment handle stage starts OpenGL API, about being transported to respectively, the stereogram that generates in two buffer zones, realizes stereo display.
Y. on the video card of not supporting stereo display, stereogram is synthesized a width of cloth red and green complementary color stereo-picture, and an image from the stereogram of the left and right sides extracts red channel, extracts green and blue channel in another image, the passage that extracts is merged, form the stereo-picture of a complementary colors.And send original image buffer back to and carry out stereo display and observation.
Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
The present invention is intended to solve the problem that PCI three dimensional analysis modular program can not be supported stereo display, relies on ripe code interception technical intercept to carry out layout again in PCI three dimensional analysis module for calling of 3D API.By the monitoring projection matrix, obtain the key parameter of inverse three-dimensional scenic, by color image and the depth image of drawing,, and pixel value is mapped on the position of correspondence by counter its three-dimensional coordinate of asking of pixel, form stereogram.Carry out stereo display by various display modes, the present invention also provides a feasible approach for the direct three-dimensional of existing a large amount of three-dimensional programs.The present invention has following characteristic:
(1) solved the problem that to carry out stereo display in PCI three dimensional analysis module, promoted mutual and user experience in PCI three dimensional analysis module.
(2) the algorithm novelty of Shi Xianing is redistributed the formation stereogram by color image data in the frame buffer zone and depth data process, and algorithm principle is simple, and programming realizes convenient.
(3) made full use of existing technical resource,, had good adaptability, do not had specific (special) requirements for video card owing to develop based on the OpenGL API of industrial standard.Support plurality of display modes, can realize stereo display under the display environment arbitrarily.
Description of drawings
The method flow diagram of Fig. 1 embodiment of the invention 1
The basic model of the three-dimensional rendering that Fig. 2 the present invention adopts
The coordinate transform streamline of the three-dimensional picture that Fig. 3 the present invention adopts
The perspective projection of Fig. 4 embodiment of the invention 1 and perspective transformation matrix
Fig. 5 embodiment of the invention 1 be the coordinate system at center with the viewpoint
The quick generation method figure of the stereogram of Fig. 6 embodiment of the invention 1
Embodiment
Below in conjunction with drawings and Examples the present invention is described in further details.
Embodiment 1
As shown in Figures 2 and 3 owing to all use OpenGL API as three-dimensional rendering API in modelling phase PCI three dimensional analysis module, so present embodiment based on OpenGL API as objective for implementation, operating system platform is implemented for Windows XP.
The interception of OpenGL API is developed based on Micor soft Detours SDK with monitoring.Detours is the kit that a cover that Microsoft provides carries out the API Calls interception under the windows platform, supports all platforms of Win32.
As shown in Figure 1, towards the implantation type true three-dimensional stereo rendering method of PCI three dimensional analysis module, this method may further comprise the steps:
The OpenGL API that step (1) is used at PCI three dimensional analysis module monitors and plays up data interception;
Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
In the step (1) interception of OpenGL API with obtain the scene rendering data and further comprise: utilize 3D API interception technology, obtain 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of 3D API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
Step (2) further comprises utilizes OpenGL API to output to color and depth data in the video card frame buffer, and the projective parameter that obtains in conjunction with interception OpenGL API Calls is resolved the three-dimensional spatial information that generates color image and depth data.It further comprises following steps:
I. the identification of perspective projection transformation matrix.In the render process of a frame scene, three-dimensional applications software may repeatedly be changed projective transformation matrix, has only perspective transformation matrix just can produce the perspective three dimensional effect.Be without loss of generality, suppose that the perspective projection transformation matrix is consistent in the render process of a frame.Every controlled variable of perspective projection is seen shown in the accompanying drawing 4 with corresponding matrix relationship.Perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix.
II. setting up viewpoint is the three dimensional space coordinate system (being called for short eye coordinates system) of true origin.The perspective projection transformation matrix of intercepting and capturing with a is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, the Y direction unanimity, hither plane is positioned on the scale of Z axle of hither plane value correspondence.The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2].In this coordinate system, (X, Y Z) can be tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer, as shown in Figure 5.Can get: X ' equals width/2*X/Z; Y ' equals height/2*Y/Z; Z ' equals (z-zNear)/z*zFar/ (zFar-zNear), and wherein Z ' is corresponding to the value in the depth buffer.
III. the reconstruct of rasterizing three-dimensional scenic data.If the width of viewport is width ', highly is height ' to be obtained by OpenGL API related function.By the proportionate relationship of viewport and the hither plane coordinate P of three-dimensional rendering two field picture pixel " ' (X " ' arbitrarily as can be known, Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn, yn, zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2.Value Z ' in the corresponding depth buffer, by b as can be known, corresponding eye coordinates system Z value down is Z ' * (zFar-zNear)/zFar+zNear, can get the coordinate P of pixel under eye coordinates system (X, Y, Z), wherein X equals xNear/zNear*Z, and Y equals yNear/zNear*Z.
By calling color buffer district function and the depth buffer function in the video card of reading of OpenGL API, utilize coordinate system and the above-mentioned relation set up in the Step II, can obtain the eye coordinates system three-dimensional coordinate of all pixels down.All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering, is playing up under the visual angle arbitrarily by the three-dimensional flow waterline on this surface.
Step (3) is utilized the three-dimensional scenic of step (2) reconstruct, generates two width of cloth images, forms stereogram.Generate stereogram and can adopt following two kinds of methods:
Method one. call 3D API, play up the contextual data that obtains in the step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
Method two. adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space.Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.Wherein:
The viewpoint horizontal-shift is meant the change amount D of the new viewpoint original viewpoint of distance on X-direction x
The viewpoint vertical shift is meant the change amount D of the new viewpoint original viewpoint of distance on Z-direction z
Image pixel is offset, and is meant the additional offset D of the visual pixel level direction of generation Pixel
Then under another eye coordinates system, (the coordinate X that pixel Z) is marked under the left viewpoint is Width ' * (X-Dx)/(Z-Dz)+D for X, Y to primitive frame image mid point P Pixel, Y is Height ' * Y/ (Z-Dz).This pixel is under for right eye coordinates being, coordinate calculates according to the method described above, but Dx, Dz gets negative sign.
Each color of pixel is copied to the target location.Thereby two viewpoints are all used this method obtain stereogram.This method has without graphics pipeline, and program composition is simple, optimizes advantages such as easy.
The stereogram that step (4) generates step (3) is by display device output and carry out stereoscopy.The stereogram that the present invention generates is carried out true 3-D display in the following way:
X. the binocular solid of video card support shows.As supporting under the OpenGL environment of stereo display, creating the stereo display pattern that the equipment handle stage starts OpenGL, about being transported to respectively, the stereogram that generates in two buffer zones, realizes stereo display.Or
Y. on the video card of not supporting stereo display, stereogram is synthesized a width of cloth red and green complementary color stereo-picture, and an image from the stereogram of the left and right sides extracts red channel, extracts green and blue channel in another image, the passage that extracts is merged, form the stereo-picture of a complementary colors.And send original image buffer back to and carry out stereo display and observation.Or
Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
Embodiment 2
A kind of implantation type true three-dimensional stereo rendering method towards PCI three dimensional analysis module comprises the interception with minor function:
A. create the function of 3-D display environment, monitor this function, in the monitoring function, add system's detection function function of calling 3DOpenGL API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, the stereo display pattern in the display environment of change original start is opened real tri-dimension and is shown support on the hardware of supporting stereo display, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display.
B. begin a frame and draw function, monitor this function, the adding code obtains the viewport size when the pre-plot frame in the monitoring function, is that stereogram is created interim buffer zone according to the pixel format of playing up.
D. frame buffer is outputed to the function of display device, monitor this function, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel;
E. the projection matrix information of obtaining based on c, the parameters of perspective projection in the inverse 3 D rendering, according to these parameters, rebuild the three-dimensional scenic of rasterizing, according to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
Following implementation process is the concrete software decoding process of said method.
1. based on Detours API, under Windows XP platform based on Visual Studio 2005 set up based on based on the Win32 DLL engineering StereoDriver_PCI_OpenGL of C Plus Plus as the interception code skeleton.
2. define a data structure OpenGL_Stereo in StereoDriver_PCI_OpenGL, this data structure comprises following content:
1) Windows drawing context variable hDC, type HDC;
2) OpenGL rendering context variable hGLRC, type HGLRC;
3) whether the current hardware of record supports the variable IsStereoSupport of stereo display, type bool;
4) the wide high variable width of record viewport, height, type int;
5) the variable ColorBuffer of buffer memory color data, type GLbyte*;
6) the variables D epthBuffer of buffer memory depth data, type GLfloat;
7) the variable MatrixMode of the current transformation matrix pattern of record, type GLMatrixMode
8) the variable Matrix of the current perspective projection matrix of record, type GLfloat[4] [4]
9) the chained list gOpenGL_Stereos that creates an overall situation preserves the pointer of OpenGL_Stereo structure.
10) the OpenGL_Stereo pointer ActiveOpenGL_Stereo of an overall situation of establishment is initialized as NULL.
3. realize monitoring based on Detours API as minor function:
1)wglCreateContext
WglCreateContext creates the rendering context of a corresponding OpenGL according to the setting of application program.Create monitoring function My_wglCreateContext, in wglCreateContext, be achieved as follows function:
Resolve the parameter of wglCreateContext, judge whether user program uses the PFD_STEREO mark to start the binary channels solid and play up support, plays up support if user program starts solid, illustrate that then user program support solid itself plays up.
If user program is not activated solid and plays up support, show that then user program do not support solid to play up, whether the inquiry user starts that implanted is three-dimensional to be supported.
If the user selects to enable and implants is three-dimensional the support, create the OpenGL_Stereo structure, and be kept in the global listings that comprises the OpenGLStereo structured fingers, and initialization.Use wglChoosePixelFormat function and PF_STEREO mark to inquire about current video card and whether support stereo display.If support stereo display then the IsStereoSupport of OpenGLStereo is set to true, otherwise be set to false.
Use original wglCreateContext to create HGLRC, and in OpenGLStereo, write down corresponding HDC and HGLRC, the OpenGLStereo structure is joined among the gOpenGL_Stereos.
2)wglMakeCurrent
WglMakeCurrent selects one as current active in some OpenGL rendering contexts, generally begin and finish the drafting of a frame after wglMakeCurrent.Create monitoring function My_wglMakeCurrent, in My_wglMakeCurrent, be achieved as follows function: when HDC parameter and HGLRC parameter during for NULL, the OpenGL_Stereo structure of from gOpenGL_Stereos, searching corresponding hDC and hGLRC with these two parameters, and assignment is given the ActiveOpenGL_Stereo variable.If two parameters are NULL, be NULL then with the ActiveOpenGL_Stereo assignment.
Call original wglMakeCurrent.
3)glViewport
GlViewport is set to assigned address and size with the viewport of the OpenGL rendering context of current active.Create monitoring function My_glViewport, in My_glViewport, be achieved as follows function:
If ActiveOpenGL_Stere is not empty, then judge the wide height of new viewport whether with ActiveOpenGL_Stereo in width, height equates.If original ColorBuffer and DepthBuffer internal memory among the unequal release OpenGL_Stereo; Wide high color buffer area ColorBuffer and the depth buffer district DepthBuffer of creating according to viewport; Write down new width and height.
Call original glViewport.
4)glMatrixMode
GlMatrixMode is provided with the active matrix model of current active OpenGL rendering context.Create monitoring function My_glMatrixMode, in My_glMatrixMode, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, then the MatrixMode of ActiveOpenGL_Stere is set to the parameter of glMatrixMode.
Call original glMatrixMode.
5)glLoadMatrixd,glLoadMatrixf
GlLoadMatrix is provided with matrix for movable OpenGL plays up current matrix pattern up and down.Create monitoring function My_glMLoadMatrix, in My_glLoadMatrix, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, and its variable MatrixMode equals GL_PROJECTION, and the m variable that then writes down this function is in the Matrix of ActiveOpenGL_Stere.
Call original glLoadMatrix function.
6)SwapBuffers
This function outputs to the frame that OpenGL plays up on the display device from video memory.Create monitoring function My_SwapBuffers, in this function, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, call the glReadPixels function, from the color buffer district, read the ColorBuffer variable of color with GL_RGB to ActiveOpenGL_Stereo; Call the glReadPixels function with the GL_DEPTH_COMPONENT parameter, read depth value in the DepthBuffer of ActiveOpenGL_Stereo.
From the Matrix variable of ActiveOpenGL_Stereo, obtain the width width of the hither plane of perspective projection, height height, and the zNear of hither plane and far plane zFar.
According to the width ViewPortWidth and the ViewPortHeight of the viewport that writes down among the ActiveOpenGL_Stereo, create interim color buffer district, ColorBufferLeft and ColorBufferRight.
From being provided with, the user obtains viewpoint skew Dx, depth shift Dz and pixel-shift Dpixel.Set up a circulation,, take out corresponding pixel coordinate iX, the depth value among the DepthBuffer of iY and color RGB and correspondence each ColorBuffer pixel.The method of utilizing the present invention to design, and the coordinate P in the eye coordinates system of pixel correspondence (X, Y, Z).With Dx, Dz, Dpixel are parameter to left eye.The quick stereo picture that uses the present invention's design calculates the pixel coordinate PLeft of P correspondence to generating algorithm.With-Dx ,-Dz ,-Dpixel are parameter to right eye, and the quick stereo picture that uses the present invention's design calculates the right pixel coordinate Pright of P correspondence to generating algorithm.Give the PLeft position of ColorBufferLeft and the Pright position of ColorBufferRight with the color difference assignment of current pixel.
Whether the IsStereoSupport that judges ActiveOpenGL_Stere is true.If be true, call glDrawPixels and respectively the content among ColorBufferLeft and the ColorBufferRight is copied among GL_BACK_LEFT and the GL_BACK_RIGT.Otherwise with the G among the ColorBufferRight, B passage assignment is to the G of ColorBufferLeft respective pixel, and the B passage gets on, and forms a red green solid, and the content of ColorBufferLeft is copied among the GL_BACK.
Call original SwapBuffer.
4. compiling StereoDriver_PCI_OpenGL engineering generates the StereoDriver_PCI_OpenGL.DLL file.
5. with the withdll.Exe order line startup corresponding program of StereoDriver_PCI_OpenGL.DLL file by detoursSDK.

Claims (10)

  1. Towards the implantation type true three-dimensional stereo rendering method of PCI three dimensional analysis module, it is characterized in that 1, this method may further comprise the steps:
    The 3D API that step (1) is used at PCI three dimensional analysis module monitors and plays up data interception;
    Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
    Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
    Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
  2. 2, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, described true-three-dimensional stereo rendering method further comprises the following steps, the following step in no particular order:
    A. the function of 3-D display environment is created in monitoring, in this function, add system's detection function function of calling 3D API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, stereo display pattern in the display environment of change original start, on the hardware of supporting stereo display, open real tri-dimension and show support, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display;
    B. monitoring begins the function that a frame is drawn, and the adding code obtains the viewport size when the pre-plot frame in this function, is that stereogram is created interim buffer zone according to the pixel format of playing up;
    C. monitoring changes the function of current drafting matrix, in this function, add code to obtain of the change of three-dimensional applications software, by the projection type of matrix parameter identification scene rendering, when being perspective projection to current drafting matrix, write down this matrix, as the key parameter of three-dimensional scenic reconstruct;
    D. monitor the function that frame buffer is outputed to display device, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on step c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel; According to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
  3. 3, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, in the described step (1) monitoring of 3D API with play up data interception and further comprise: utilize API interception technology, obtain the output of 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of 3D API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
  4. 4, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, also further comprise the concrete steps that realize the interception of 3D api function at it in the described step (1): inject or/and the Hook Function technology is write specific hook procedure by code, in the data load stage of three-dimensional visualization program, 3D API hook procedure is loaded in the process of three-dimensional visualization program, thus interception and monitoring 3D API Calls.
  5. 5, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, described step (2) further comprises the following steps: by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space.
  6. 6, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, described step (2) further comprises following steps:
    I. the identification of perspective projection transformation matrix: suppose that the perspective projection transformation matrix is consistent in the render process of a frame, perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix;
    II. setting up viewpoint is the three dimensional space coordinate system of true origin: the perspective projection transformation matrix of intercepting and capturing with step I is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, Y direction unanimity, hither plane are positioned on the scale of Z axle of hither plane value correspondence; The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2]; In this coordinate system, (X, Y Z) are tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer, X '=width/2*X/Z; Y '=height/2*Y/Z; Z '=(z-zNear)/z*zFar/ (zFar-zNear), wherein Z ' is corresponding to the value in the depth buffer;
    III. the reconstruct of rasterizing three-dimensional scenic data: the width of establishing viewport is width ', highly for height ', the coordinate P of any three-dimensional rendering two field picture pixel " ' (X " ', Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn; yn; zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2; Value Z ' in the corresponding depth buffer, corresponding eye coordinates system is Z=Z ' * (zFar-zNear)/zFar+zNear down, the coordinate of pixel under eye coordinates system be P (X, Y, Z), X=xNear/zNear*Z wherein, Y=yNear/zNear*Z; All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering.
  7. 7, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that the method that generates space image in the described step (3) is: call 3D API, play up the contextual data that obtains in the described step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
  8. 8, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, the method that generates space image in the described step (3) is: adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space; Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.
  9. 9, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, at different demonstrations and scope, carries out stereo display and observation in the described step (4), comprising:
    X. on the equipment of supporting stereo display, stereogram is outputed to two passages about video card respectively, carry out stereo display; Or
    Y. on the equipment of not supporting stereo display, in stereogram, an image extracts red channel, and another image extracts green and blue channel, and the passage that extracts is merged, and forms the stereo-picture of a complementary colors, and supports mycyscope to observe; Or
    Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
  10. 10, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, the 3D api function of described interception comprises:
    (21) 3D API creates the function of 3-D display environment;
    (22) 3D API begins the function of a frame scene rendering;
    (23) 3D API changes the current function of playing up matrix;
    (24) 3D API finishes the function of a frame scene rendering;
    (25) 3D API will play up data and output to function on the current screen.
CN2009100251210A 2009-02-24 2009-02-24 PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method Active CN101488229B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2009100251210A CN101488229B (en) 2009-02-24 2009-02-24 PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009100251210A CN101488229B (en) 2009-02-24 2009-02-24 PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method

Publications (2)

Publication Number Publication Date
CN101488229A true CN101488229A (en) 2009-07-22
CN101488229B CN101488229B (en) 2011-04-27

Family

ID=40891110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009100251210A Active CN101488229B (en) 2009-02-24 2009-02-24 PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method

Country Status (1)

Country Link
CN (1) CN101488229B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106504188A (en) * 2016-11-23 2017-03-15 北京视觉智能科技有限公司 The generation method of the eye-observation image presented for stereoscopic vision and device
CN110880161A (en) * 2019-11-21 2020-03-13 大庆思特传媒科技有限公司 Depth image splicing and fusing method and system for multi-host multi-depth camera
CN111638870A (en) * 2020-05-14 2020-09-08 民生科技有限责任公司 Front-end development base platform based on acts and reduce
CN117056994A (en) * 2023-08-14 2023-11-14 新天绿色能源股份有限公司 Data processing system for big data modeling
CN117056994B (en) * 2023-08-14 2024-05-17 新天绿色能源股份有限公司 Data processing system for big data modeling

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106504188A (en) * 2016-11-23 2017-03-15 北京视觉智能科技有限公司 The generation method of the eye-observation image presented for stereoscopic vision and device
CN106504188B (en) * 2016-11-23 2018-10-23 北京清影机器视觉技术有限公司 Generation method and device for the eye-observation image that stereoscopic vision is presented
CN110880161A (en) * 2019-11-21 2020-03-13 大庆思特传媒科技有限公司 Depth image splicing and fusing method and system for multi-host multi-depth camera
CN111638870A (en) * 2020-05-14 2020-09-08 民生科技有限责任公司 Front-end development base platform based on acts and reduce
CN111638870B (en) * 2020-05-14 2023-07-04 民生科技有限责任公司 Front-end development basic platform based on reaction and reduce
CN117056994A (en) * 2023-08-14 2023-11-14 新天绿色能源股份有限公司 Data processing system for big data modeling
CN117056994B (en) * 2023-08-14 2024-05-17 新天绿色能源股份有限公司 Data processing system for big data modeling

Also Published As

Publication number Publication date
CN101488229B (en) 2011-04-27

Similar Documents

Publication Publication Date Title
CN101477700B (en) Real tri-dimension display method oriented to Google Earth and Sketch Up
CN101477701B (en) Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX
CN101477702B (en) Built-in real tri-dimension driving method for computer display card
CN102834849B (en) Carry out the image displaying device of the description of three-dimensional view picture, image drawing method, image depiction program
CN101635061B (en) Adaptive three-dimensional rendering method based on mechanism of human-eye stereoscopic vision
JP2008090617A (en) Device, method and program for creating three-dimensional image
CN101540056B (en) Implanted true-three-dimensional stereo rendering method facing to ERDAS Virtual GIS
CN101521828B (en) Implanted type true three-dimensional rendering method oriented to ESRI three-dimensional GIS module
CN102819855A (en) Method and device for generating two-dimensional images
Gimeno et al. Multiuser augmented reality system for indoor exhibitions
CN101511034A (en) Truly three-dimensional stereo display method facing Skyline
RU2295772C1 (en) Method for generation of texture in real time scale and device for its realization
CN101488229B (en) PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method
CN101482978B (en) ENVI/IDL oriented implantation type true three-dimensional stereo rendering method
CN101488232B (en) Implanted true three-dimension volumetric display method oriented to C Tech software
CN101488230B (en) VirtualEarth oriented ture three-dimensional stereo display method
CN101561935B (en) GoCAD software-oriented implanted true three-dimensional display method
CN116958344A (en) Animation generation method and device for virtual image, computer equipment and storage medium
CN101561936B (en) GeoGlobe-oriented true three-dimensional stereoscopic display method
CN101482977B (en) Microstation oriented implantation type true three-dimensional stereo display method
CN101488231B (en) Creator software oriented implantation type true three-dimensional stereo display method
WO2020236460A1 (en) Blended mode three dimensional display systems and methods
Tao A VR/AR-based display system for arts and crafts museum
WO2011093555A1 (en) Method for generating video frames for producing 3d images
Schmidt Blended Spaces: Perception and Interaction in Projection-Based Spatial Augmented Reality Environments

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: CHANGSHU NJNU DEVELOPMENT RESEARCH INSTITUTE CO.,

Free format text: FORMER OWNER: NANJING NORMAL UNIVERSITY

Effective date: 20120720

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 210097 NANJING, JIANGSU PROVINCE TO: 215500 SUZHOU, JIANGSU PROVINCE

TR01 Transfer of patent right

Effective date of registration: 20120720

Address after: 215500 Changshou City South East Economic Development Zone, Jiangsu, Jin Road, No. 8

Patentee after: Changshu Nanjing Normal University Development Research Academy Institute Co., Ltd.

Address before: 210097 Nanjing Road, Jiangsu, Nanjing 122

Patentee before: Nanjing Normal University

TR01 Transfer of patent right

Effective date of registration: 20201210

Address after: Building 3, No.88, Xianshi Road, high tech Zone, Changshu City, Suzhou City, Jiangsu Province

Patentee after: Changshu Zijin Intellectual Property Service Co.,Ltd.

Address before: 215500 8 Jindu Road, Changshou City Southeast Economic Development Zone, Jiangsu

Patentee before: CHANGSHU NANJING NORMAL UNIVERSITY DEVELOPMENT RESEARCH INSTITUTE Co.,Ltd.

TR01 Transfer of patent right