Summary of the invention
The present invention is directed to projector in the existing spherical display technique planar rectangular image that receives is directly projected to the problem that causes obvious distortion on the ball curtain through fish eye lens, provide a kind of projector the spherical high-efficient treatment method that shows and rotate output image, the image frame for the treatment of projection in the computing machine is carried out deformation process before exporting to projector, so that the image of projector's output is circular, can solve the problem of anamorphose, can also on the ball curtain, rotate around arbitrary axis, the spherical display effect of raising projection on the ball curtain, and can improve the efficient of spherical demonstration rotation by the efficient processing to image rotating.
Technical scheme of the present invention is as follows:
The spherical high-efficient treatment method that shows and rotate output image of a kind of projector, it is characterized in that, the planar rectangular image for the treatment of projection is shown that with projector's sphere the image of output is as target image simultaneously as source images, take Cartesian coordinates as Foundation source images coordinate system with the target image coordinate system, and be that the basis increases by three coordinate axis vertical with the target image coordinate system to set up the spherical coordinate of target image with the target image coordinate, simultaneously target image is divided into a plurality of grids, described each grid inside comprises two and above pixel; According to fish-eye light path characteristic, first the pixel coordinate of the grid vertex of target image is transferred to the three-dimensional coordinate under the spherical coordinate, again described three-dimensional coordinate is rotated conversion, and the three-dimensional coordinate after the rotational transform is converted to coordinate under the polar coordinate system, then obtain the pixel coordinate of source images according to the coordinate under the polar coordinate system, the angle of the coordinate under the polar coordinate system of described three-dimensional coordinate conversion and radius be the coordinate of the change in coordinate axis direction of corresponding source images coordinate system respectively; Again with the pixel coordinate of the source images that the obtains texture coordinate as the corresponding grid vertex of target image, and with source images as texture mapping, the color of the pixel of target image is played up output according to grid vertex and corresponding texture coordinate and combined with texture pinup picture by the graphic process unit of video card.
The step that the pixel coordinate of described grid vertex with target image transfers the three-dimensional coordinate under the spherical coordinate to is: first the pixel coordinate of the grid vertex of target image being transferred to the coordinate under the polar coordinate system, is three-dimensional coordinate under the spherical coordinate by the coordinate conversion under the polar coordinate system again.
It is that grid vertex by target image is at the three-dimensional coordinate of grid vertex under spherical coordinate of the target image before the multiplication relationship of the rotation matrix that arbitrary axis rotates obtains rotating under the three-dimensional coordinate under the spherical coordinate and the spherical coordinate that described three-dimensional coordinate is rotated conversion.
After three-dimensional coordinate after the described rotational transform is converted to coordinate under the polar coordinate system, according in the three-dimensional coordinate situation under the spherical coordinate angle of the coordinate under the polar coordinate system of described three-dimensional coordinate conversion being carried out pre-service before the target image rotation.
After being converted to coordinate under the polar coordinate system, the three-dimensional coordinate after the described rotational transform is converted to again the two dimensional surface coordinate, with the position of pixel under the target image coordinate system of the grid vertex of determining the target image before the rotation.
The pixel coordinate of described source images all is [0,1] at the coordinate range of two coordinate axis of source images coordinate system, and the pixel coordinate of the described source images that obtains is the normalization coordinate; The true origin of described source images coordinate system is positioned at the upper left corner of source images; The pixel coordinate of described target image all is [1,1] at the coordinate range of two coordinate axis of target image coordinate system, and the true origin of described target image is positioned at the center of target image.
The pixel coordinate of the grid vertex of described target image transfers the angle of the coordinate under the polar coordinate system to
Be intermediate value, the scope of described intermediate value is [0, π], described intermediate value
Obtain after treatment the computing angle (θ) under the polar coordinate system, the scope of described computing angle be [0,2 π), according to the different quadrant at the pixel place of the grid vertex of target image by
Obtain the value of θ:
Be three-dimensional coordinate under the spherical coordinate by the coordinate conversion under the polar coordinate system again.
The grid that described target image is divided is by waiting longitude and latitude to carry out the mesh of vertices of five equilibrium.
Technique effect of the present invention is as follows:
The spherical high-efficient treatment method that shows and rotate output image of the projector that the present invention relates to, the planar rectangular image (source images) for the treatment of projection deformation process can be carried out before exporting to projector so that projector exports circular image (target image), and the efficient processing of the spherical rotation that shows of projector can be realized.The method is specifically by setting up respectively the source images coordinate system, target image coordinate system and spherical coordinate and the grid of setting up target image, carry out the conversion of series according to fish-eye light path characteristic: first the pixel coordinate of the grid vertex of target image is transferred to the three-dimensional coordinate under the spherical coordinate, again three-dimensional coordinate is rotated conversion, and the three-dimensional coordinate after the rotational transform is converted to coordinate under the polar coordinate system, the angle of the coordinate under the polar coordinate system of three-dimensional coordinate conversion and radius be the coordinate of the change in coordinate axis direction of corresponding source images coordinate system respectively, so can obtain again the pixel coordinate of source images according to the coordinate under the polar coordinate system, namely set up the pixel coordinate corresponding relation of source images with the grid vertex that rotates front target image, again with grid vertex in the target image at pixel coordinate corresponding to source images as texture coordinate, with source images as texture mapping, utilize graphic process unit to process, the color of the pixel of target image according to grid vertex and corresponding source image pixels coordinate (being texture coordinate) thereof and in conjunction with source images as texture mapping, graphic process unit by video card is played up output, so that the image of projector's output is circular, avoided the planar rectangular image of projector's output is directly projected to the problem that causes obvious anamorphose on the ball curtain through fish eye lens, the spherical circular image of output that shows of projector that processing is obtained projects on the ball curtain through fish eye lens, reduce anamorphose, carry out sphere demonstration and rotation processing by grid vertex being adopted polar coordinate transform technology and three-dimensional rotation converter technique, grid vertex and inner pixel adopt the video card Rendering, realize the spherical efficient processing that shows and rotate output image of projector, and can on the ball curtain, rotate around arbitrary axis, reduce the spherical calculation process amount that shows rotational transform, improved spherical display effect and the spherical efficient that shows rotation of image projection on the ball curtain of projector's output.
Embodiment
The present invention will be described below in conjunction with accompanying drawing.
The present invention relates to the spherical high-efficient treatment method that shows and rotate output image of a kind of projector, its process flow diagram as shown in Figure 2.The planar rectangular image for the treatment of projection is shown that with projector's sphere the image of output is as target image simultaneously as source images, take Cartesian coordinates as Foundation source images coordinate system with the target image coordinate system, and be that the basis increases by three coordinate axis vertical with the target image coordinate system to set up the spherical coordinate of target image with the target image coordinate, simultaneously target image is divided into a plurality of grids, each grid inside comprises two and above pixel; According to fish-eye light path characteristic, first the pixel coordinate of the grid vertex of target image is transferred to the three-dimensional coordinate under the spherical coordinate, again described three-dimensional coordinate is rotated conversion, and the three-dimensional coordinate after the rotational transform is converted to coordinate under the polar coordinate system, then obtain the pixel coordinate of source images according to the coordinate under the polar coordinate system, the angle of the coordinate under the polar coordinate system of three-dimensional coordinate conversion and radius be the coordinate of the horizontal and vertical change in coordinate axis direction of corresponding source images coordinate system respectively; Can set up the pixel coordinate corresponding relation of source images and the grid vertex that rotates front target image by above-mentioned polar coordinate transform and three-dimensional rotation conversion, as long as with grid vertex in the target image at pixel coordinate corresponding to source images as texture coordinate, with source images as texture mapping, utilize graphic process unit to process, the color of the pixel of target image according to grid vertex and the corresponding source images coordinate of grid vertex and in conjunction with source images as texture mapping, graphic process unit by video card is played up output, just the planar rectangular image for the treatment of projection can be carried out deformation process and export postrotational circular image, finish the spherical efficient processing that shows and rotate the output circular image of projector.
Projector of the present invention is spherical to be shown and the high-efficient treatment method of rotation output image can carry out deformation process with the picture of planar rectangular image for the treatment of the original image (can be video or picture) of projection before output, circular so that be input to the image of projector, the image that is projector's output also is circular, and can on via the ball curtain under the fish eye lens projection, rotate around arbitrary axis, namely the arbitrary axis around the spherical coordinate of setting up rotates.Rotate around arbitrary axis and to refer to that on the ball surface any one point and the axis of the centre of sphere are rotated, because it is three-dimensional rotating around arbitrary axis, and the circular picture (being target image) of the spherical original rectangle picture (being source images) that changes and output all is two-dimentional, the present invention is spherical to be shown and the high-efficient treatment method of rotation output only carries out sphere to the pixel of the grid vertex set up and shows the rotational transform processing, reduce the spherical calculation process amount that shows rotational transform, the sphere of the pixel of grid vertex is shown that rotational transform processes that to take two dimension is exported the picture coordinate transform be the coordinate that spherical coordinate is fastened, and then spherical coordinate carried out the three-dimensional rotation conversion, the last two-dimensional coordinate that again three-dimensional coordinate after the conversion is converted to source images, thereby the final arbitrary axis rotation of target image in the ball curtain shows that realizes output.Shown and the fish-eye optical path analysis of rotation can obtain spherically showing that anamorphose and the spherical rotation that shows utilize respectively polar coordinate transform technology and three-dimensional rotation converter technique, the video card GPU Rendering that the pixel of grid vertex and grid inside adopts by sphere.The concrete steps of disposal route of the present invention are as follows:
Steps A, will treat that the planar rectangular image of projection is as source images first, simultaneously with the spherical circular image that shows output of projector as target image, take Cartesian coordinates set up respectively as the basis as shown in Figure 3 the source images coordinate system and target image coordinate system as shown in Figure 4.Computing machine among Fig. 3 treats that the original planar rectangular image transitions of projection is the target image that projector shows the circle as shown in Figure 4 of output.Also need to set up spherical coordinate and target image need to be divided into a plurality of grids.Setting up spherical coordinate and be with the target image coordinate is that the basis increases by three the coordinate axis Z axis vertical with the target image coordinate system to set up the spherical coordinate of target image, as shown in Figure 5, the circular image that shows output for projector is spherical is rotated the spherical coordinate of setting up around any axle center, under the ball and directly over line as Z axis (can be regarded as is the line of the South Pole and the arctic), the equatorial plane is the XY plane of target-based coordinate system.The method that target image is divided a plurality of grids can be by waiting longitude and latitude to carry out the mesh of vertices of five equilibrium, and as shown in Figure 6, each grid inside comprises two and above pixel, and can be different according to the size of the fineness situation mesh of vertices of calculation process.
For so that Unitary coordinate, when the definition coordinate range, the pixel coordinate of source images all is [0 at the coordinate range of two coordinate axis of source images coordinate system, 1], namely the source images coordinate x scope in the source coordinate system shown in Figure 3 is [0,1], the y scope is [0,1], wherein the y coordinate is from top to bottom, and the true origin of source images is positioned at the upper left corner of source images.The pixel coordinate of target image all is [1 at the coordinate range of two coordinate axis of target image coordinate system, 1], be that target image coordinate x scope in the target-based coordinate system shown in Figure 4 is [1,1], the coordinate range of y direction also is [1,1], the true origin of target image is positioned at the center of target image.The radius of the ball after the normalization is unit 1 in spherical coordinate shown in Figure 5 simultaneously.
Step B, according to fish-eye light path characteristic, transfer the pixel coordinate of the grid vertex of target image under the spherical coordinate three-dimensional coordinate.The coordinate of the pixel of the grid vertex of hypothetical target image under the target image coordinate system is Pt2d(dstX, dstY) can be first transfers the pixel coordinate of the grid vertex of target image under the polar coordinate system coordinate, is three-dimensional coordinate under the spherical coordinate by the coordinate conversion under the polar coordinate system again.Specifically be divided into:
B1, with Pt
2d(dstX, dstY) transfers coordinate under the polar coordinate system to by cartesian coordinate system
Wherein R is the radius under the polar coordinate system,
Scope be [0, π] because the scope of the angle under the required polar coordinate system be [0,2 π), therefore think
Be intermediate value, can be with this intermediate value
Obtain after treatment the computing angle θ under the polar coordinate system, the scope of computing angle be [0,2 π), according to the different quadrant at the pixel place of the grid vertex of target image by
Obtain the value of θ:
B2, for R 1 point beyond the polar coordinates unit circle, in source images, do not have corresponding point, specifically can be filled to black or do not process.For R<=1 situation, be converted to three-dimensional coordinate Pt under the spherical coordinate, Pt=(Pt by polar coordinatesx, Pty, Ptz):
Pt=(sin(R·π)·cos(θ),sin(R·π)·sin(θ),cos(R·π)) (3)
Process conveniently for subsequent calculations, three-dimensional coordinate Pt can be treated to the four-dimensional coordinate vector of following form:
Pt=(sin(R·π)·cos(θ),sin(R·π)·sin(θ),cos(R·π),1) (4)
Step C, during around the rotation of any axle center, described three-dimensional coordinate is rotated conversion at target image, namely Pt rotates around arbitrary axis, supposes around axle (Ac, Ay, Az), the anglec of rotation is φ, then three dimensions around the rotation matrix of arbitrary axis A reverse rotation angle φ is:
The formula of C and S representative is as follows in the formula (5):
Grid vertex by target image is at the three-dimensional coordinate Pt ' of grid vertex under spherical coordinate of the target image before the multiplication relationship of the rotation matrix M that arbitrary axis rotates obtains rotating under the three-dimensional coordinate Pt under the spherical coordinate and the spherical coordinate, wherein Pt '=(Pt 'x, Pt 'y, Pt 'z).Namely obtain the position of the front Pt ' of Pt point rotation by rotation matrix M:
Pt′=Pt·M (7)
Step D, the three-dimensional coordinate Pt ' after the rotational transform is converted to coordinate Pt ' under the polar coordinate systemR θ(R', θ '),
After the three-dimensional coordinate after the rotational transform is converted to coordinate under the polar coordinate system, can also be according in the three-dimensional coordinate situation under the spherical coordinate angle of the coordinate under the polar coordinate system of described three-dimensional coordinate conversion being carried out pre-service before the target image rotation, make θ ' angular distribution [0,2 π) in the scope.Some special circumstances below namely when rotational transform, processing:
Step e, can be again with Pt ' behind step DR θ(R', θ ') is converted to the two dimensional surface coordinate, to determine the position Pt ' of pixel under the target image coordinate system of the target image that rotation is front2d:
Pt′2d=(R'·cos(θ′),R'·sin(θ′)) (10)
Step F, according to the coordinate Pt ' under the polar coordinate systemR θ(R', θ ') obtains the pixel coordinate of corresponding source images, polar angle θ ' of the directions X corresponding three-dimensional coordinate conversion of source images, polar radius R of Y-direction corresponding three-dimensional coordinate conversion ', computing formula is:
Step G, utilize the graphic process unit of video card to process based on directx or opengl, with the source images coordinate srcX that formula (11) obtains, srcY is as the corresponding grid vertex Pt of target image2dTexture coordinate, and with source images (the original planar rectangular image for the treatment of projection) as texture mapping.
The color of the pixel of step H, target image (being the pixel of each grid vertex and each grid inside) is played up output according to grid vertex and the corresponding texture coordinate of grid vertex and combined with texture pinup picture by the graphic process unit of video card.The pixel color of target image is utilized the output of video card Hardware Render based on directx or opengl, because this mode is utilized video card GPU(graphic process unit) carry out conversion, so speed is very fast.Just the planar rectangular image for the treatment of projection can be carried out deformation process and export postrotational circular image, finally finish the spherical efficient processing that shows and rotate the output circular image of projector.
As treat projection in the computing machine be the picture of planar rectangular image shown in Figure 1 the time, by the spherical high-efficient treatment method that shows and rotate output image of projector of the present invention, the picture of planar rectangular image shown in Figure 1 is carried out the high performance deforming processing before output, so that projector's output circular image as shown in Figure 7, this circular image projects on the ball curtain through fish eye lens, can reduce anamorphose, and can on the ball curtain, rotate around arbitrary axis, improved the spherical display effect of image projection on the ball curtain of projector's output.The high-efficient treatment method of output image of the present invention, not that each pixel to the target image of projector output is rotated conversion (the calculation process amount that each pixel is rotated conversion is too large), and be based on directx or opengl sets up a series of grid to target image, then only the pixel of the grid vertex set up is carried out sphere and show the rotational transform processing, and the texture coordinate that corresponding original image is set carries out texture mapping (texture coordinate refers to coordinate position corresponding in source images), pixel color in grid vertex and the grid is utilized the output of video card Hardware Render based on directx or opengl, can reduce the spherical calculation process amount that shows rotational transform, improve the spherical efficient that shows rotation.
What specify is, the mode of target image being divided a plurality of grids in the embodiment steps A is by waiting longitude and latitude to carry out the mesh of vertices as shown in Figure 6 of five equilibrium, after the efficient processing of the spherical demonstration of projector and rotational transform, obtain the texture coordinate of the corresponding original image in each summit, this moment the apex coordinate invariant position, texture coordinate changes with the rotation that sphere shows.
Target image is divided a plurality of grids wait the longitude and latitude mode except above-mentioned, can also take other mode modes, as first matrixing being done on the summit of the longitude and latitude of the five equilibrium in the aforesaid way, obtain new apex coordinate Pt '2d(the two dimensional surface coordinate in the formula (10) is for determining the position of pixel under the target image coordinate system of the target image that rotation is front) is with the Pt ' after the conversion2dAs mesh of vertices, this moment apex coordinate Pt '2dChange with rotation, texture coordinate corresponding to the summit of grid is constant.Grid is divided and is not limited to above dual mode.
Should be pointed out that the above embodiment can make the invention of those skilled in the art's comprehend, but do not limit the present invention in any way creation.Therefore; although this instructions has been described in detail the invention with reference to drawings and Examples; but; those skilled in the art are to be understood that; still can make amendment or be equal to replacement the invention; in a word, all do not break away from technical scheme and the improvement thereof of the spirit and scope of the invention, and it all should be encompassed in the middle of the protection domain of the invention patent.