The trajectory smoothing method of optical indicating device
[technical field]
The present invention relates to a kind of trajectory smoothing method of optical indicating device, be meant the method for level and smooth its output trajectory of usefulness on the indicating devices such as being applied to optical mouse especially.
[background technology]
In various computer peripheral equipments, the mouse person of being to use is one of the computer peripheral equipment of normal use, be mainly used to the computer input unit as a kind of form, be specially adapted to the application on the visual pattern, therefore mouse has become indispensable input tool at present.At present more common mouse is divided into two kinds of idler wheel mouse and optical mouse.Idler wheel mouse uses the physical construction of the roller microcontroller chip of arranging in pairs or groups again to handle displacement signal.The cmos image sensor that the optical mouse utilization has an optical guidance function replaces the physical construction of roller, and the microcontroller chip of arranging in pairs or groups is handled displacement signal.When mouse moves, the displacement of its unit interval can export computing machine in regular turn to, because the displacement of mouse is the result that the image sensor through the physical construction of idler wheel mouse or optical mouse quantizes, but not actual continuous path, therefore, even the track that mouse moves does not all have vertical line segment, might make that in through the process that quantizes vertical line segment occurs, its reason may can't detect for movement angle is too small, error etc. is arranged when perhaps quantizing on both direction because of two-dimensional coordinate, simultaneously because the adjusting of optical mouse light source (as light emitting diode) (is normally adjusted the exposure of next frame image) non-timely according to the eigenwert of previous frame image, and make image not necessarily always be in a good situation; And sensor sampling during picture the influence because of intrinsic noise and random noise make image also may occur degenerating, therefore can cause track local anomaly to occur.
Trajectory diagram when Fig. 1 is mouse movement.Mouse directly as output valve, exports the displacement input value that senses to computing machine in regular turn.As shown in Figure 1, P
0Be starting point, and each displacement input value being the displacement with respect to last position, is input value P in regular turn
1(1,0), input value P
2(0,1), input value P
3(1,0), input value P
4(1,0), input value P
5(1,1), input value P
6(1,1), input value P
7(0,1), input value P
8(1,0), input value P
9(1,0) and input value P
10(0,1).When these input values by directly as output valve, and when exporting computing machine in regular turn, the track that shows on the corresponding calculated machine screen is indentation and have right angle, many places lines just, this is non-to be gratifying output result.
In the existing trajectory smoothing method, because of not keeping or delaying output, each motion vector all deals with, or it is interval only to have defined a maintenance, institute's directed quantity in this interval all is held, and this kind method weak point is to postpone serious, DPI (Dot Per Inch, be the per inch pixel, it is illustrated in and whenever moves 1 inch coordinate quantity that (about 2.54 centimetres) its optical sensor can receive on the physical surface.Such as common resolution is the mouse of 800DPI, and the meaning moves mouse 1 inch in other words, and its optical sensor can receive 800 different coordinate points, just means that also mouse pointer can move 800 pixels on screen) loss arranged.
[summary of the invention]
The object of the invention is to provide a kind of trajectory smoothing method of optical indicating device, utilizes the method to make output trajectory more level and smooth, and can not lose DPI.
For achieving the above object, the trajectory smoothing method of optical indicating device of the present invention comprises the steps:
Obtain and produce new motion vector;
Judge whether mouse has motion;
If no, then output shift quantity is zero and finishes;
If any, then judge whether it is first motion vector;
If first motion vector judges whether it is moving along single shaft again;
In this way along the moving of single shaft, then keep predetermined motion vector output and finish;
If two direction of principal axis all have motion, then output movement vector, and reservation amount is zero and finishes;
If not first motion vector, judge then whether this motion vector is the motion of single shaft direction;
If two direction of principal axis all have motion, then current motion vector is added the motion vector output of reservation, and the reservation amount is zero and finishes;
If, then judge whether to keep motion vector direction last time along the moving of single shaft direction, promptly judge whether with last time the motion vector direction identical;
If with last time the motion vector direction identical, then output movement vector, and reservation amount is constant and finish;
If with last time the motion vector direction inequality, then judge whether with last time motion vector vertical;
As with last time motion vector vertical, then current motion vector is added to keep motion vector output, and reservation amount zero clearing and finishing;
As not with last time motion vector vertical, keep predetermined motion vector and output.
According to above-mentioned principal character, the predetermined motion vector of described reservation is the motion vector that keeps a unit.
According to above-mentioned principal character, this optical indicating device is a mouse.
According to above-mentioned principal character, this optical indicating device finger navigation device.
Compared with prior art, the trajectory smoothing method of optical indicating device provided by the invention is anticipated by the motion vector that mouse is obtained, and so can avoid occurring bigger bending in the movement locus, thereby the track of order output is more level and smooth.
[description of drawings]
Trajectory diagram when Fig. 1 is mouse movement.
Fig. 2 is the process flow diagram of trajectory smoothing method of the present invention.
Fig. 3 is the numerical value that flow process produced of enforcement mouse of the present invention according to Fig. 2.
Trajectory diagram when Fig. 4 moves for implementing mouse of the present invention.
[embodiment]
See also shown in Figure 2ly, be the process flow diagram of trajectory smoothing method of the present invention, this method comprises the steps:
Obtain and produce new motion vector, step S100;
Judge at first whether mouse has motion, step S101;
If no, then output shift quantity is zero and finishes step S102;
If any, judge then whether this motion vector is first motion vector, step S103;
If first motion vector judges whether it is to move step S104 along single shaft again;
Along the moving of single shaft, then keeping predetermined motion vector in this way, is the motion vector of a unit in the present embodiment, and promptly the absolute value of output movement vector subtracts 1 and finish step S105;
If two direction of principal axis all have motion, then output movement vector, and reservation amount is zero and finishes step S106;
If not first motion vector, judge then whether this motion vector is the single shaft motion, step S107;
If two direction of principal axis all have motion, then current motion vector is added the motion vector output of reservation, and the reservation amount is zero and finishes step S108;
If, judge then whether this motion vector keeps motion vector direction last time along the moving of single shaft direction, promptly judge whether with last time the motion vector direction identical, step S109;
If with last time the motion vector direction identical, then output movement vector, and reservation amount is constant and finish step S110;
If with last time the motion vector direction inequality, then judge this motion vector whether with last time motion vector vertical, step S111;
As with last time motion vector vertical, then current motion vector is added to keep motion vector output, and reservation amount zero clearing and finish step S112;
As not with last time motion vector vertical, keep predetermined motion vector, be the motion vector of a unit in the present embodiment, promptly the absolute value of output movement vector subtracts 1, step S113.
Please in conjunction with Fig. 1, Fig. 2, Fig. 3 and shown in Figure 4, wherein Fig. 3 represents to implement the numerical value that flow process produced of mouse of the present invention according to Fig. 2.Wherein calculating process of each line display is the input value of present embodiment as if the input value with Fig. 1, that is, as shown in Figure 1, P
0Be starting point, and each displacement input value being the displacement with respect to last position, is input value P in regular turn
1(1,0), input value P
2(0,1), input value P
3(1,0), input value P
4(1,0), input value P
5(1,1), input value P
6(1,1), input value P
7(0,1), input value P
8(1,0), input value P
9(1,0) and input value P
10(0,1).The relative shift that above-mentioned input value is exported after according to flow processing shown in Figure 2 is (1,1), (1,0), (2,1), (1,1), (1,1), and (1,1) time, output shift quantity is (1,1), (2,1), (4,2), (5,3), (6,4), (7,5) displacement that exports computing machine in regular turn to by mouse is output valve P, and at last
11(1,1), output valve P
12(2,1), output valve P
13(4,2), output valve P
14(5,3), output valve P
15(6,4) and output valve P
16(7,5), so the gained track is by P on the screen
0Point connects P in regular turn
11, P
12, P
13, P
14, P
15And P
16Formed lines (solid line on the figure) are compared with untreated lines (dotted line on the figure), and the turning is less and seem more level and smooth.
Be to describe with mouse in the above-described embodiment, those skilled in the art the present invention fully as can be known also can be applicable to finger navigation device (promptly realizing navigation by the image of gathering finger) or other utilize the indicating device of means of optical navigation technique.