The content of the invention
In order to overcome the drawbacks described above of prior art, the technical problem to be solved is to provide in view of the disappearance of above-mentioned prior art, present invention is primarily targeted at providing a kind of spot imaging method of employing CCD light-sensitive devices, the method has very important meaning to ensureing that laser scanning visual system obtains high-precision measurement result in the environment of very Larger Dynamic scope.
For reaching above-mentioned purpose, the technical scheme is that:
A kind of spot imaging method of CCD light-sensitive devices, it comprises the following steps:
CCD light-sensitive devices obtain the signal of telecommunication to carrying out sensing by hot spot through the optical signalling that optical transform is obtained, and form a Frame after the signal digitized of an array;
Start to postamble direction from frame, ask for the position P points of gray scale maximum in a frame, and the gray value MAX of P points;
Compare MAX and default overexposure threshold value SAT;
If MAX is more than or equal to SAT, the value for respectively taking q location of pixels in P or so centered on P points is compared with default threshold value SECTH;
It is more than or equal to preset value W if greater than the number of pixels of threshold value SECTH, the position of the position more than SECTH of search low order end to the left and right and high order end more than SECTH is distinguished centered on P, D and C is designated as respectively, k/2 pixels are taken to the left by starting point of C, least squares line fitting is done together with C points, the parameter of left side straight line is tried to achieve, and takes k/2 pixels to the left by starting point of D, least squares line fitting is done together with D points, tries to achieve the parameter of straight right;
Straight line through fitting is substituted into threshold value SECTH for setting, starting point m of saturation signal is asked for, terminal n and they the distance between Le;
Ask for obtaining le based on Le;
The estimated location of hot spot imaging is obtained based on le.
Preferably, it also includes:If MAX is less than SAT, the scope that k location of pixels is imaged as laser facula respectively being chosen before and after maximum value position, seeking the algorithm of center of gravity to ask for the center of facula position using linear weighted function, wherein k is the positive integer more than or equal to 1.
Preferably, adopt linear weighted function to seek the algorithm of center of gravity ask for the formula at the center of facula position for:
, wherein, N is the pixel coordinate of the spot center asked for, the precision with sub-pix;Ni is pixel coordinate;B (Ni) is gray value of the pixel at Ni, and line array CCD pixel sequence number i is 1 ~ n.
Preferably, it also includes:Preset value W is less than if greater than the number of pixels of threshold value SECTH, scope that k location of pixels as laser facula be imaged is chosen before and after maximum value position respectively, seek the algorithm of centroid algorithm to ask for the center of facula position using linear weighted function, wherein k is the positive integer more than or equal to 1.
Preferably, adopt linear weighted function to seek the algorithm of centroid algorithm ask for the formula at the center of facula position for:
, wherein, N is the pixel coordinate of the spot center asked for, the precision with sub-pix;Ni is pixel coordinate;B (Ni) is gray value of the pixel at Ni, and line array CCD pixel sequence number i is 1 ~ n.
Preferably, default threshold value SAT, SECTH and W are by testing determination.
Preferably, k is determined in the estimation range that CCD sensors are imaged size according to the laser facula in vision sensor detection range.
In view of the disappearance of above-mentioned prior art, present invention is primarily targeted at the laser spot center computational methods being imaged in the case of a kind of CCD linear array photosensors calculated in laser triangulation of offer are over-exposed, the method obtains high-precision measurement result to guarantee laser scanning visual system in the environment of very Larger Dynamic scope very important meaning.
Specific embodiment
With reference to the description of accompanying drawing and the specific embodiment of the invention, the details of the present invention can be clearly understood.But, the specific embodiment of invention described herein is only used for explaining the purpose of the present invention, and it is limitation of the present invention that can not be understood as by any way.Under the teachings of the present invention, technical staff is contemplated that any possible deformation based on the present invention, and these are regarded as belonging to the scope of the present invention.
The invention discloses a kind of imaging facula position calculating method method of employing CCD light-sensitive devices, it comprises the following steps:
CCD light-sensitive devices obtain the signal of telecommunication to carrying out sensing by hot spot through the optical signalling that optical transform is obtained, and form a Frame after the signal digitized of an array;
Start to postamble direction from frame, ask for the position P points of gray scale maximum in a frame, and the gray value MAX of P points;
Compare MAX and default overexposure threshold value SAT;
If MAX is more than or equal to SAT, the value for respectively taking q location of pixels in P or so centered on P points is compared with default threshold value SECTH;
It is more than or equal to preset value W if greater than the number of pixels of threshold value SECTH, the position of the position more than SECTH of search low order end to the left and right and high order end more than SECTH is distinguished centered on P, D and C is designated as respectively, k/2 pixels are taken to the left by starting point of C, least squares line fitting is done together with C points, the parameter of straight line left side straight line is tried to achieve, and takes k/2 pixels to the left by starting point of D, least squares line fitting is done together with D points, tries to achieve the parameter of straight right;
Straight line through fitting is substituted into threshold value SECTH for setting, starting point m of saturation signal is asked for, terminal n and they the distance between Le.
Ask for obtaining le based on Le;
The physical location of hot spot imaging is obtained based on le.
Fig. 1 shows the hot spot image measuring device of CCD light-sensitive devices in laser triangulation.The laser beam launched by semiconductor laser 1 reaches scanning mirror 3 through transmitting illuminator 2, and scanning mirror 3 is driven by scan module 4 and does oscillatory scanning.The laser facula being radiated on object is through receiving tilting mirror 5, then the signal for forming laser facula through receiving illuminator 6 and the arrival CCD of image-forming assembly 7 light-sensitive devices 8.Wherein scanning mirror 3 and to receive tilting mirror 4 be synchronous, that is, they are mounted on same scan axises and are coplanar.
The block diagram of driving and signal damping circuit of the Fig. 2 for CCD light-sensitive devices, object(Laser facula)It is imaged to form electronic signal in CCD sensors, which is output as CCD video signals.Hardware block diagrams of the Fig. 3 for CCD light-sensitive device Signal sampling and processings.One frame or multiframe CCD video signal after filtering, amplify and A/D conversion after be stored in frame memory, which is processed by MCU.
Fig. 4 is the signal schematic representation when laser facula when the exposure of CCD light-sensitive devices is appropriate.For the position that the hot spot for asking for sub-pixel is imaged, the linear weighted function algorithm or the nonlinear weight algorithm based on gaussian laser distributed model for asking for hot spot center of gravity can be adopted.
Fig. 5 is the signal schematic representation when laser facula when CCD light-sensitive devices are over-exposed.Now if take with expose appropriate when as algorithm if, as a result spot signal position has a larger error, and over-exposed more serious, error is bigger.And in prior art, lack the reasonable processing method and means that can solve the problem that in the case of CCD light-sensitive devices are over-exposed.
Through inventor's repeatedly observation, experiment, research repeatedly, when we can observe that over-exposed by Fig. 5, the imaging of laser facula is trapezoidal as one.We can set up a simplified model such as Fig. 6 according to this and be determined the relation between the accurate location of laser facula and this trapezoidal width of overexposure by actual experiment.
In Fig. 6, the width of saturation signal when Le represents overexposure, h represent actual spot center position, and the width of m points to h points is le.
Here it is one threshold value SECTH of setting to obtain the simplest methods of Le, then calculates the quantity of the pixel around maximum more than SECTH, using it as saturation length Le.But the precision of this method is not high, it is impossible to match with the result calculated when exposing appropriate.In order to obtain more accurate saturation signal width Le, our transitional regions to saturation signal both sides carry out the linear equation that fitting a straight line obtains two trapezoidal sides shown in Fig. 6.Then threshold value SECTH of setting is brought in linear equation, tries to achieve the position m points and n points of the beginning and end of saturation signal, the pixel distance between this 2 points is exactly Le.
After the position of actual hot spot determines, then the position of le also determines that.The actual position of hot spot so obtains.In exposure where appropriate, measuring to facula position, used as the position of actual hot spot imaging, algorithm is using the linear weighted function algorithm for asking for hot spot center of gravity.In order to the meansigma methodss of multiple measurement more accurately, can be taken.
By adjusting the power of time of exposure and laser instrument realizing during the change of light exposure.
Studied through inventor repeatedly and learnt, the relation of the actual Le and le corresponding to Fig. 6 models for measuring when Fig. 7 is typical overexposure.As can be seen that this relation meets linear relationship.We can obtain the parameter of this linear relationship with this.When there is overexposure in vision measurement, the straight line on trapezoidal both sides is first fitted according to the model of Fig. 6, calculates the width of saturated pixel, then according to the relation of Fig. 7 calculates actual facula position.Actual experiment result shows, the facula position error very little of the facula position so obtained and reality.Here two indices are considered:Maximum error and standard deviation.It is that, in the range of 70 pixels, its maximum error is 1.0 pixels, and standard deviation is 0.3 pixel just to start to be saturated to saturation width from signal.Although this result is bigger than measurement error during normal exposure, but it is, in the case of overexposure, to meet basic certainty of measurement and require.
The Processing Algorithm for asking for imaging facula center is set forth below.It is assumed here that the signal of line array CCD sensor passes through A/D conversions, such as pixel 8 of a frame 2048 sampled value is had stored in twoport frame memory.
In one embodiment, comprised the following steps using the spot imaging method of CCD light-sensitive devices:
CCD light-sensitive devices form a Frame to carrying out sensing and obtaining the signal of telecommunication obtaining frame signal through the optical signalling that optical transform is obtained by hot spot, after the signal digitized of an array;
Start to postamble direction from frame, ask for the position P points of gray scale maximum in a frame, and the gray value MAX of P points;
Compare MAX and default overexposure threshold value SAT, in the present embodiment, SAT takes 210;
If MAX is more than or equal to SAT, the value for respectively taking q location of pixels in P or so centered on P points is compared with default threshold value SECTH;
It is more than or equal to preset value W if greater than the number of pixels of threshold value SECTH, the position of the position more than SECTH of search low order end to the left and right and high order end more than SECTH is distinguished centered on P, D and C is designated as respectively, k/2 pixels are taken to the left by starting point of C, least squares line fitting is done together with C points, try to achieve the parameter of left side straight line, k/2 pixels are taken to the right by starting point of D, least squares line fitting is done together with D points, try to achieve the parameter of straight right, k can be imaged the estimation range of size choosing according to the laser facula in vision sensor detection range in CCD sensors, k=9 in the present embodiment, SECTH=180, W=3;
Straight line through fitting is substituted into threshold value SECTH for setting, starting point m of saturation signal is asked for, terminal n and they the distance between Le;
Ask for obtaining le based on Le;
The physical location of hot spot imaging is obtained based on le.
If MAX is less than SAT, the scope that k location of pixels is imaged as laser facula respectively being chosen before and after maximum value position, seeking the algorithm of center of gravity to ask for the center of facula position using linear weighted function, wherein k is the positive integer more than or equal to 1.
Adopt linear weighted function to seek the algorithm of center of gravity ask for the formula at the center of facula position for:
, wherein, N is the pixel coordinate of the spot center asked for, the precision with sub-pix;Ni is pixel coordinate;B (Ni) is gray value of the pixel at Ni, and line array CCD pixel sequence number i is 1 ~ n.
Preset value W is less than if greater than the number of pixels of threshold value SECTH, scope that k location of pixels as laser facula be imaged is chosen before and after maximum value position respectively, same to seek the algorithm of centroid algorithm to ask for the center of facula position using linear weighted function, wherein k is the positive integer more than or equal to 1.
Adopt linear weighted function to seek the algorithm of centroid algorithm ask for the formula at the center of facula position for:
, wherein, N is the pixel coordinate of the spot center asked for, the precision with sub-pix;Ni is pixel coordinate;B (Ni) is gray value of the pixel at Ni, and line array CCD pixel sequence number i is 1 ~ n.
In the above-described embodiment, default threshold value SAT, SECTH and W are by testing determination.K is determined in the estimation range that CCD sensors are imaged size according to the laser facula in vision sensor detection range.
For example, the MAX values when after test of many times, learning that saturation exposes.The determination of SAT is that MAX values when exposing than saturation are a little bit smaller.MAX when such as saturation exposes is 230, takes SAT for MAX-20.SAT is so caused in the trapezoidal upper end of overexposure, but is not maximum.SAT is primarily used to judge that the state of CCD sensors is saturation exposure, or critical in saturation exposure.
SECTH is primarily used to overexposure width according to a preliminary estimate.As shown in Figure 5, it should more a little bit smaller than other overexposure values.Can be seen by Fig. 5, value 190-210 at other overexposure pixels, so taking 180 here.
W represents critical overexposure state, is at this time calculated with the formula of normal exposure and with the result difference very little of overexposure.So intuitively observing, critical state is in less than the saturation exposed width of three pixels.This marginal value can also compare in this point with excessive exposure algorithm and normal exposure method comparison verifying.
Specifically, the processing method of the system approximately as:
1. start to postamble direction from frame, ask for the position of gray scale maximum in a frame, be designated as the gray value MAX of P points, maximum is MAX here.
2. overexposure threshold value SAT for comparing MAX and being previously set, if MAX is less than SAT, then can determine that CCD sensors are correct exposures, then to the 3rd step, otherwise to the 5th step.Here by experiment, SAT easily can determine that we take 210.
3. the scope that respectively k location of pixels of selection is imaged as laser facula before and after maximum value position.Here the laser facula in k basis for selecting vision sensor detection range is imaged the estimation range of size in CCD sensors.We take k=9 in practice.
4. seek the algorithm of center of gravity to ask for the center of facula position using linear weighted function.Formula is as follows: Wherein, N is the pixel coordinate of the spot center asked for, the precision with sub-pix;Ni is pixel coordinate;B (Ni) is gray value of the pixel at Ni, and line array CCD pixel sequence number i is 1-n.So far algorithm terminates.
5. the value for respectively taking q location of pixels in P or so centered on P is compared with threshold value SECTH of second setting.If greater than threshold value SECTH number of pixels be less than preset value W, then explanation in saturation it is critical near, go to the 3rd step, not so continue next step.Here SECTH and W can be determined by experiment.In practice, the A/D of 8 is we used, SECTH takes 180;W takes 3.
6. the position more than SECTH of search low order end and high order end to the left and right is distinguished centered on P, more than the position of SECTH, be designated as D and C respectively.K/2 pixels are taken to the left by starting point of C, and C points do least squares line fitting together, try to achieve the parameter of left side straight line;Equally, k/2 pixels are taken to the left by starting point of D, and D points do least squares line fitting together, try to achieve the parameter of straight right.
7. the left and right fitting a straight line equation of the 6th step is substituted into threshold value SECTH during aforementioned modeling, can be in the hope of the position corresponding to m the and n points in Fig. 6.Fitting a straight line adopts least square fitting, is summarized as follows:Straight line model is linear function model.We use simplest linear formula, write as matrix form, be
Directly give the parametric solution of the formula:
With
Wherein, it is the arithmetic mean of instantaneous value of t values.Following form can also be solved:
Corresponding to our application, there are 5 points on the left side, so n=5.With the coordinate of pixel as variable t, this 5 are worth by grey scale pixel value as y(ti,yi), the wherein positive integer of i=1 to 5.B be can be obtained by the formula brought into above what0And b1Value.So the equation of straight line is by y=b0–b1T is determined that.So SECTH is substituted into the value of y, it is possible to obtain the t values corresponding to SECTH, here it is along the positional value of pixel orientation.In so Fig. 6, m points are determined that.Similarly, the value of n points in Fig. 6 can be obtained.Ask for two point m in Fig. 6, n and they the distance between, corresponding to the Le in Fig. 6.
8. correspondence and the le in Fig. 6 can then be asked for according to aforementioned substitution Le in the linear relationship that Fig. 7 sets up.The physical location of hot spot imaging is exactly that m points position adds le.So far algorithm terminates.
In sum, spot center computational solution precision when the application can solve the problems, such as that CCD linear array photosensor devices are over-exposed in laser triangulation is low.
Each embodiment in this specification is described by the way of progressive, and what each embodiment was stressed is the difference with other embodiment, between each embodiment identical similar part mutually referring to.
Above-described embodiment technology design only to illustrate the invention and feature, its object is to allow person skilled in the art will appreciate that present disclosure and implement according to this, can not be limited the scope of the invention with this.All equivalence changes made according to spirit of the invention or modification, should all be included within the scope of the present invention.