A kind of picture charge pattern method and the augmented reality implementation method using this method
Technical field
The present invention relates to calculator visual effect fields, and in particular to a kind of picture charge pattern method and the expansion using this method
Increase real border implementation method.
Background technique
Augmented reality technology, that is, AR, full name is Augmented Reality, by the visual effect of virtual world, audio and sky
Between the information such as information be integrated into the technology of true environment information, augmented reality technology not only shows the information of true environment, also together
When virtual information is shown, be complementary to one another by two kinds of information, superposition, user allowed to can get richer sense whereby
Information is known, in general, the electronic device for carrying augmented reality technology, which can pass through the pick-up lens being configured thereon that, captures true environment
Image, and calculate position, the angle of captured image in real time, while plus respective virtual image, the purpose is to show
Virtual world information is covered in actual environment information on screen, allows user through the information of captured image and virtual world
It is interacted.
Augmented reality technology is mainly used in the mobile devices such as smart phone, tablet computer now, in recent years due to void
The development of quasi- reality (Virtual Reality, VR) technology, also starts augmented reality technology being applied to intelligent helmet, intelligence
In the wearable devices such as glasses.Through the rendering of 3D rendering animation, the broadcasting of multimedia video, audio, augmented reality technology quilt
It is widely used in the fields such as video game, broadcasting media and education.
Augmented reality technology is using the scene in virtual special efficacy enhancing true environment, the mesh that needs are demonstrated or are highlighted
It is more lively and specific to mark things, brings the strong distinct visual effect of user.Existing Augmented Reality application is that have with one
The image of abundant details renders true lively threedimensional model as marker, through display screen on the image.Its image
Tracking is to identify matched algorithm based on template, and precision only reaches pixel i.e. integer levels.When the 2D-3D pose square with prediction
Battle array is floating type element interaction after the pixel, and obtained result will be reduced into integer grade.Therefore it causes a little in small model
Interior error is enclosed, and then influences the result that present frame calculates 2D-3D position auto―control.Its visual effect is in virtual three-dimensional model
When moving with the movement of marker, virtual three-dimensional model appears in shake or motor reaction in picture and lags behind mark
The case where object.The phenomenon will affect the displaying of augmented reality special efficacy, influence the visual experience of user.
Summary of the invention
The present invention provides a kind of picture charge pattern method and the augmented reality implementation method using this method, solves picture and trembles
The case where dynamic and motor reaction lags behind marker.
The present invention is achieved through the following technical solutions:
A kind of picture charge pattern method, comprising the following steps:
A1, blip object is obtained;
A2, the initial position auto―control for calculating blip object;
A3, the next frame data for reading in blip object, predicted using template matching, Markov model motion state,
The method of Kalman filtering algorithm enters tracking execution thread, with the new position auto―control of determination;
A4, corresponding evolution is carried out to image according to new position auto―control;
A5, using the step of A3 to A4 until blip object disappear.
This method is improved in existing picture charge pattern method, moves shape using template matching, Markov model
State is predicted, the method for Kalman filtering algorithm tracks execution thread, and effective solution float and motor reaction lag behind mark
The case where will object.
A kind of augmented reality implementation method based on picture charge pattern, comprising the following steps:
1) blip object, is generated;
2) augmented reality system, is initialized;
3) real scene image, is obtained;
4) blip object, is detected and matched, the initial position auto―control of blip object is obtained;
5) 3D engine animation effect, is rendered;
6) it, is initially entered using the method for template matching, the prediction of Markov model motion state, Kalman filtering algorithm
Execution thread is tracked, determines the new position auto―control of blip object;
7) augmented reality animation effect, is updated according to new position auto―control;
8) it, repeats 5) to 7) until blip object is disappeared in screen, reacquires real scene image or expanded real
Border system stops operating.
Further, using the method for template matching specifically: augmented reality system will according to the position auto―control of previous frame
The point of tracking group is projected to screen, does template matching in a certain range near point, for example the pros of the point 15*15 pixel
The matching in shape region, judge templet is determined by the normalized-cross-correlation function of template all pixels value.
Further, using the method for Kalman filtering algorithm specifically: to number frame position auto―control and present frame before
Position auto―control be filtered, number frame position auto―control before is weighted, the new pose that present frame is acquired later
Matrix does optimum estimation processing.
Further, the method predicted using Markov model motion state specifically:
Predict the motion state of blip object;
Filtering parameter is adjusted in real time according to motion state.
Further, the motion state of blip object is predicted method particularly includes:
After the Point Set of tracking group is matched by way of template matching, calculates point and concentrate each point in the coordinate of present frame
With the coordinate distance of former frame, motion state is judged according to this distance.
Generate blip object method include:
Choose image;
The diminution for carrying out different scale to image with the method for linear interpolation, establishes figure layer tower, makes augmented reality system
The marker of sizes in the image of camera acquisition can be matched to;
Generate the point of tracking group;
Generate the characteristic point and description of match group.
Compared with prior art, the present invention having the following advantages and benefits:
1, picture charge pattern method of the invention is using template matching, the prediction of Markov model motion state, Kalman's filter
The case where method of wave algorithm tracks execution thread, and effective solution float and motor reaction lag behind marker.
2, above-mentioned picture charge pattern method is applied to augmented reality by the present invention, effective solution virtual three-dimensional model with
Marker appears in the case where shake or motor reaction lag behind marker in picture during exercise, enhances user experience.
Detailed description of the invention
Attached drawing described herein is used to provide to further understand the embodiment of the present invention, constitutes one of the application
Point, do not constitute the restriction to the embodiment of the present invention.In the accompanying drawings:
Fig. 1 be target point in this state next frame possibly into motion state diagram.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below with reference to embodiment and attached drawing, to this
Invention is described in further detail, and exemplary embodiment of the invention and its explanation for explaining only the invention, are not made
For limitation of the invention.
Embodiment 1
A kind of picture charge pattern method, comprising the following steps:
A1, blip object is obtained;
A2, the initial position auto―control for calculating blip object;
A3, the next frame data for reading in blip object, predicted using template matching, Markov model motion state,
The method of Kalman filtering algorithm enters tracking execution thread, with the new position auto―control of determination;
A4, corresponding evolution is carried out to image according to new position auto―control;
A5, using the step of A3 to A4 until blip object disappear.
This picture charge pattern method may be used in many very Multiple systems.Below with augmented reality systematic difference to this
The detailed step of method is illustrated.
Embodiment 2
A kind of augmented reality implementation method based on picture charge pattern, comprising the following steps:
1) blip object, is generated;
2) augmented reality system, is initialized;
3) real scene image, is obtained;
4) blip object, is detected and matched, the initial position auto―control of blip object is obtained;
5) 3D engine animation effect, is rendered;
6) tracking execution thread, is opened, determines the new position auto―control of blip object;
7) augmented reality animation effect, is updated according to new position auto―control;
8) it, repeats 5) to 7) until blip object is disappeared in screen, reacquires real scene image or expanded real
Border system stops operating.
Specifically, in step 2), augmented reality system can be realized in the equipment with camera, for example mobile phone, flat
Plate computer, intelligent glasses or helmet etc..Initialization augmented reality system mainly include two aspect: the calibration of 1. cameras and just
Beginningization, for obtaining real scene image, initialization camera is referred specifically to the internal intrinsic ginseng such as the focal length of camera and deformation
Number is read into memory;2. augmented reality system reads the local data pre-stored that realization technology needs, including blip
Object file, the information of 3D model.
Step 3) obtains the image of a real scene by camera.
Whether contain blip object in detection image, if there is process to continue, otherwise reacquires image and detection.
Establish screen coordinate of the blip object in camera and pose coordinate of the blip object in real scene
2D-3D position auto―control, determine placement position of the 3D model in screen, size, and it is every it is one-dimensional on rotation angle, so
The 3D model with animation is drawn with 3D engine afterwards.
Pose coordinate of the point of tracking group in real scene is projected to according to 2D-3D position auto―control to the two dimension on screen
Coordinate system.
It is predicted using template matching, Markov model motion state, the method for Kalman filtering algorithm starts tracking and holds
Line journey determines the simultaneously new position auto―control of optimization aim marker.
Specifically, using the method for Kalman filtering algorithm specifically: number frame position auto―control before is weighted, it
Optimum estimation processing is done to the new position auto―control that present frame acquires afterwards.It there is provision of an aluminium foil parameter, to number before
The position auto―control of frame position auto―control and present frame is filtered.When the parameter is larger, closer to the 2D-3D pose square of present frame
The weight that battle array obtains is bigger, caused by the result is that the 2D-3D position auto―control of present frame updates rapidly, but put there are pixels for position
The deviation of grade, reflection is exactly that augmented reality special efficacy is shaken on the screen.Otherwise the parameter is smaller, and weight is relatively evenly distributed in
Before count frames 2D-3D position auto―control on, caused by the result is that the 2D-3D position auto―control of present frame need a bit of time return
Return to optimal solution, reflection is exactly that the motion state of augmented reality special efficacy lags behind image change on the screen.When marker is quick
When movement, shake can visually be ignored, but the movement for needing big filtering parameter that Augmented Reality special efficacy is made to keep up with marker
State.When marker low-speed motion or it is static when, hysteresis effect is unobvious, but small filtering parameter is needed to make Augmented Reality special efficacy
Display is not shaken steadily more.Therefore need to be adjusted filtering parameter according to the motion state of blip object, so that amplification
The shake of real border special efficacy visually is preferably minimized with lag.
Specifically, the method for using the prediction of Markov model motion state to the method that filtering parameter is adjusted.It is first
First, the motion state of blip object is predicted;Filtering parameter is adjusted in real time further according to motion state.The motion mode of object may
Property is divided into four kinds of states, and static, acceleration, maximum speed, deceleration can be indicated with serial number 0,1,2,3 respectively in the implementation.Predict mesh
Mark marker can be used in the motion state method of present frame: after the Point Set of tracking group is matched by the matched mode of model,
Calculating point concentrates each point in the coordinate of present frame and the coordinate distance of former frame, and will obtain distance votes, between 0 and threshold
Value one is then included in the set that motion state is 0, i.e., static;For distance between threshold value one and threshold value two, then being included in motion state is 1
Or 3 set;The set that motion state is 2 is second included in greater than threshold value.It takes and is counted into the most collection of number and is combined into marker
Current motion state.The combination of four continuous states between nearly five frame is taken, marker can be carried out to different combinations and integrally transported
The judgement and prediction of dynamic property, assign present frame one suitable filtering algorithm parameter.
See Fig. 1, point arrow indicate point in this state next frame possibly into motion state.Such as o'clock under 0 state,
Next frame possibly into state be 0 or 1.
Assuming that the marker combinations of states of first three frame and present frame is 0000, then the state estimation of marker is quiet
Only, then need to set a lesser filter parameter come prevent 3D model shake.
Assuming that the marker combinations of states of first three frame and present frame is 2222, then the state estimation of marker is high speed
Movement, then need to set a biggish filter parameter come prevent 3D model sport lag.
The algorithm all sets corresponding filter parameter to different number combinations to guarantee the aobvious of Augmented Reality special efficacy
Show effect, simultaneously as only considered the state of four frame images, therefore the noise generated is ignored, such as 2121 this shapes
State repeatedly the case where.
Embodiment 3
The present embodiment refines step 1) on the basis of embodiment 2, specifically includes the following steps:
An image is chosen, in order to reach stable augmented reality effect, the pixel quantity of image cannot be too low, and image is not
Can be too simple and dull, ideally there are enough characteristic points;
The diminution for carrying out different scale to image with the method for linear interpolation, establishes figure layer tower, makes augmented reality system
The marker of sizes in the image of camera acquisition can be matched to;
The point for generating tracking group does x, gradient on the direction y to the angle point extracted again later first to image zooming-out angle point
Calculating, leave point of the angle point of maximum 20% quantity of gradient as tracking group;
The characteristic point and description of match group are generated, image does feature point extraction and generates corresponding description, for examining
It surveys and matches.
Above-described specific embodiment has carried out further the purpose of the present invention, technical scheme and beneficial effects
It is described in detail, it should be understood that being not intended to limit the present invention the foregoing is merely a specific embodiment of the invention
Protection scope, all within the spirits and principles of the present invention, any modification, equivalent substitution, improvement and etc. done should all include
Within protection scope of the present invention.