The depth extraction and passive ranging method of optimization based on monocular vision
Technical field
The present invention relates to ground close-range photogrammetry field, especially a kind of single camera vision system lower pinhole camera it is passive
Distance measuring method.
Background technique
Object ranging and positioning based on image, are broadly divided into two methods of initiative range measurement and passive ranging[1].Actively
Ranging is to install laser ranging system on machine (such as camera) to carry out ranging[2-4].Passive ranging is by machine vision to two
Object depth information is calculated in dimension word image, then calculates target according to image pixel information and camera imaging principle
Object distance[5-6].Machine vision ranging is broadly divided into monocular vision ranging, two class of binocular distance measurement[7-9].In ranging process,
Committed step is the acquisition of object depth information, and the depth information acquisition method of early stage is mainly binocular stereo vision and phase
Machine motion information needs multiple image to complete the acquisition of image depth information[10-16].Compared with binocular distance measurement, monocular is surveyed
Stringent hardware condition, more competitive superiority are not needed away from Image Acquisition.
In the prior art, there are many methods for the object Depth Information Acquistion of single camera vision system.Such as use corresponding points mark
Method is determined to obtain the depth information of target to be measured[17-19].Document [17] has studied a kind of robot mesh based on monocular vision
Position distance measuring method is demarcated, this method is usually to obtain the inside and outside parameter of camera by camera calibration, solves figure in conjunction with projection model
As the transformational relation between coordinate system and world coordinate system, to calculate object depth information.Unfortunately, the method needs
The target image of different direction is acquired, and accurately records respective coordinates of each point in world coordinate system and image coordinate system,
Stated accuracy is affected for measurement accuracy.
Document [20] puts object of reference on road surface and measures its distance, selects suitable mathematical model, fitting object of reference away from
From the corresponding relationship between pixel, this relationship extract real-time depth information is recycled.Unfortunately, the method essence of document [20]
Degree will receive the influence of telemeasurement error and error of fitting.
Document [21] devises a kind of vertical target image, and the angle point data by detecting the image establish image ordinate
Mapping relations between pixel value and actual measurement angle combine known vehicle-mounted monocular camera height to obtain figure using this relationship
The vehicle-mounted depth information as in.Since different cameral equipment inner parameter has differences, for the camera apparatus of different model, the party
Method needs to resurvey target image information, establishes camera depth information extraction model, and different in-vehicle cameras are due to camera lens system
The reasons such as work and assembly, so that camera pitch angle can also have differences, therefore the method versatility of document [21] is poor.
In addition, the method for document [21] is using vertical target research perpendicular picture point imaging angle and ordinate pixel value
Between relationship, and by this be applied to horizontal plane on object distance measurement so that range accuracy is relatively low, because of camera water
It is flat not exactly the same with vertical direction Distortion Law.Application No. is 201710849961.3 patent applications, disclose one kind and change
Into the camera calibration model and distortion correction model suitable for intelligent sliding moved end camera (hereinafter referred to as: improved with non-thread
The peg model of sex distortion item), this method can help to correct scaling board picture, the inside and outside parameter of camera of higher precision is obtained,
Unfortunately, this method does not expand in the nonlinear distortion correction and the measurement of object to testing image.
Bibliography:
[1] He Ruofei, Tian Xuetao, Liu Hongjuan wait unmanned plane target localization method of the based on Monte Carlo Kalman filtering
[J] Northwestern Polytechnical University journal, 2017,35 (3): 435-441.
[2] Lin F, Dong X, Chen B M, et al.A Robust Real-Time Embedded Vision
System on an Unmanned Rotorcraft for Ground Target Following[J].IEEE Trans on
Industrial Electronics, 2012,59 (2): 1038-1049.
[3] Zhang Wanlin, Hu Zhengliang, Zhu Jianjun wait one of the comprehensive view instrument of individual soldier target position calculation method [J]
Electronic measurement technique, 2014,37 (11): 1-3.
[4] Sun Junling, Sun Guangmin, Ma Pengge wait laser eyepiece of the based on symmetrical wavelet noise reduction and asymmetric Gauss curve fitting
Position [J] Chinese laser, 2017,44 (6): 178-185.
[5] Shi Jie, Li Yin child, Qi Guoqing, passive tracking algorithm [J] China under waiting not exclusively to measure based on machine vision
Middle University of Science and Technology's journal, 2017,45 (6): 33-37.
[6] Xu Cheng, yellow grand celebration, a kind of passive target positioning of the numerous small drone of clanging or clanking sound in hole and precision analysis [J] instrument instrument
Table journal, 2015,36 (5): 1115-1122.
[7] Li Kehong, Jiang Lingmin, Gong Yong justice .2 are tieed up to 3 d image/Video Quality Metric image depth extracting method and are summarized
[J] Journal of Image and Graphics, 2014,19 (10): 1393-1406.
[8] Wang Hao, Xu Zhiwen, Xie Kun, wait binocular range-measurement system [J] Jilin University journal of the based on OpenCV, and 2014,
32 (2): 188-194.
[9] Sun W, Chen L, Hu B, et a1.Binocular vision-based position
determination algorithm and system[C]//Proceedings of the 2012 International
Conference on Computer Distributed Control and Intelligent Environmental
Monitoring.Piscataway:IEEE Computer Society, 2012:170-173.
[10]Ikeuchi K.Determining a depth map using a dual photometric stereo
[J] .The International Journal of Robotics Research, 1987,6 (1): 15-31.
[11] Shao M, Simehony T, Chellappa R.New algorithms from reconstruction
of a 3-d depth map from one or more images[C]//Proceedings of CVPR’88.Ann
Arbor:IEEE, 1988:530-535.
[12] Matthies L, Kanade T, Szeliski R.Kalman filter-based algorithms for
estimating depth from image sequences[J].International Journal of Computer
Vision, 1989,3 (3): 209-238.
[13] Mathies L, Szeliski R, Kanade T.Incremental estimation of dense
Depth maps from image sequence [C] //Proceedings of CVPR ' 88.Ann Arbor:IEEE,
1988:366-374.
[14] Mori T, Yamamoto M.A dynamic depth extraction method [C] //
Proceedings of Third International Conference on Computer Vision.Osaka:IEEE,
1990∶672-676.
[15] Inoue H, Tachikawa T, Inaba M.Robot vision system with a
Correlation chip for real-time tracking, optical flow and depth map generation
[C] //Proceeding of Robotics and Automation.Nice:IEEE, 1992:1621-1626.
[16] Tree image distance measuring method [J] the agricultural mechanics of Hu Tianxiang, Zheng Jiaqiang, Zhou Hongping based on binocular vision
Report, 2010,41 (11): 158-162.
[17] Yu Naigong, Huang Can, Lin Jia are calculated based on robot target positioning distance measuring technique study [J] of monocular vision
Machine measurement and control, 2012,20 (10): 2654-2660.
[18] ranging research [J] the robot in Wu Gang, Tang Zhen people's monocular formula autonomous robot vision guided navigation, 2010,
32 (6): 828-832.
[19] Lu Weiwei, Xiao Zhitao, Lei Meilin study [J] with distance measuring method based on the front vehicles detection of monocular vision
Video Applications and engineering, 2011,35 (1): 125-128.
[20] Wu C F, Lin C J, Lee C Y, et al.Applying a functional neurofuzzy
network to real-time lane detection and front-vehicle distance measurement
[J] .IEEE Transactions on Systems, Man and Cybernetics-Part C:Applications and
Reviews, 2012,42 (4): 577-589.
[21] yellow cloudling, peak, Xu Guoyan wait monocular depth information extraction [J] of based on single width vertical target image
BJ University of Aeronautics & Astronautics's journal, 2015,41 (4): 649-655.
Summary of the invention
The object of the present invention is to provide a kind of depth extraction of optimization based on monocular vision and passive ranging methods, can
The camera different suitable for parameters such as field angle, focal length, image resolution ratios improves range accuracy, is object in machine vision
Measurement and real scene three-dimensional reconstruction provide support.
To achieve the above object, the present invention adopts the following technical scheme:
A kind of depth extraction and passive ranging method of the optimization based on monocular vision, it is characterised in that including walking as follows
It is rapid:
Step 1: demarcating mobile phone camera, obtains camera internal parameter and image resolution ratio
Using Zhang Zhengyou calibration method, and the improved peg model with nonlinear distortion variable is introduced to camera internal parameter
It is corrected
The physical size size as pixel each in plane is set first as dx*dy, and image coordinate system (x, y) origin is in picture
Coordinate in plain coordinate system (u, v) is (u0, v0), (x, y) is the normalized coordinate of picture point in real image, any picture in image
Element meets following relationship in two coordinate systems:
fx、fyFor the normalization focal length in x-axis and y-axis, any point P in camera coordinates systemc(Xc, Yc, Zc) project to image
It is (x on coordinate systemc, yc, f), it is f with initial point distance that image coordinate system plane is vertical with optical axis z-axis, according to similar triangles original
Reason it follows that
Introduce the improved peg model with nonlinear distortion variable, including the diameter as caused by lens shape defect
To distortion and since there are tangential distortion caused by different degrees of bias, radial distortion mathematical models for optical system are as follows:
Wherein r2=x2+y2, (x ', y ') it is sat for the normalization of the ideal linearity camera coordinates system without distortion term after correction
Scale value, radial distortion value is related with the position of picture point in the picture, and the radial distortion value at image border is larger,
Tangential distortion mathematical model are as follows:
It wherein include k1、k2、k3、p1、p2Totally 5 kilrrfactors obtain distortion correction Function Modules by formula (3), (4)
Type is as follows:
There are following relationships for conversion from world coordinate transformation to camera coordinates:
Pc=R (PW- C)=RPW+T (6)
Convolution (1)~(6), may be expressed as: with homogeneous coordinates and matrix form
Mint、MextIt is the inside and outside parameter matrix of camera calibration respectively, wherein camera internal parameter includes image center pixel
Value u0、v0, fx、fyFor in x-axis and y-axis normalization focal length, by Java combination OpenCV realize mobile phone camera calibration, acquisition
Inner parameter described in mobile phone camera, camera lens distortion parameter and image resolution ratio vmax、umax;
Step 2: depth extraction model is established
Abstract function is set according to the linear relationship between object imaging angle α and ordinate pixel value v, establishes and contains mesh
Mark tri- object imaging angle α, ordinate pixel value v and camera rotation angle β parameter space relational models, i.e. α=F (v, β),
Under equipment and camera the rotation angle of different model, subject ordinate pixel value and imaging angle are in pole
Significant negative linear correlation, and the slope of the linear relationship and intercept are different, therefore set:
α=F (v, β)=av+b (17)
Wherein parameter a, b is related with camera model and camera rotation angle,
When α is minimized α=αminWhen=90- θ-β, θ is the half at camera vertical field of view angle, i.e. subject projects
When to picture lowermost end, v=vmax(vmaxFor camera CMOS or ccd image sensor column coordinate valid pixel number), substitute into formula
(17) it can obtain:
90- β-θ=avmax+b (18)
Work as αminWhen+2 90 ° of θ >, i.e. θ > β, camera upward angle of visibility is higher than horizontal line at this time, and ground level unlimited distance, α is unlimited
Close to 90 °, v is substantially equal to v at this time0-tanβ*fy, fyFor the focal length of camera under pixel unit, β is negative value, that is, camera inverse time
When needle rotates also similarly, therefore, substituting into formula (17) can obtain:
90=a (v0-tanβ·fy)+b (19)
Work as αminWhen+2 90 ° of θ <, i.e. θ < β, camera upward angle of visibility is lower than horizontal line, ground level unlimited distance object at this time
Imaging angle α is maximized, αmax=αminWhen+- 2 θ=90- β+θ, i.e., when subject projects to picture highest point, v=0,
Substitution formula (17) can obtain:
90- β+θ=b (20)
According to pinhole camera aufbauprinciple, the tangent value of the camera vertical field of view angle θ of half is schemed equal to camera CMOS or CCD
As the half of sensor side length is divided by camera focus, therefore θ can be calculated:
L in formula (21)CMOSFor the side length of camera CMOS or ccd image sensor, convolution (18)~(21), F (α, β)
Are as follows:
δ is camera nonlinear distortion variable error in formula (10), in conjunction with mobile phone camera shooting height h, according to trigonometric function
Establish mobile phone camera depth extraction model:
Step 3: by the Image Acquisition to target to be measured, target point pixel value u, v are obtained;
It further include the nonlinear distortion correction to target to be measured image in the image acquisition step to target to be measured
And pretreatment, it may be assumed that
Image Acquisition is carried out by mobile phone camera, establishes perspective geometry model, wherein f is camera focus, and θ is that camera is vertical
The half of field angle, h are that camera is taken pictures highly, and β is rotation angle of the camera along camera coordinates system ox axis, and camera rotates clockwise β
Value is positive, and is negative counterclockwise, and β value is obtained by camera internal gravity sensor, and α is object imaging angle;
In conjunction with the camera lens distortion parameter that step 1 camera calibration obtains, to radial distortion existing for image and tangential abnormal
Become error and carries out nonlinear distortion correction;Ideal linearity normalized coordinate value (x, y) after correction is substituted into formula (1), asks calculation
Image each point pixel coordinate value after correcting out, by the method for bilinear interpolation to pixel value after correction carry out interpolation processing to
Image after being corrected;The image after correction is pre-processed using computer vision and image processing techniques, including image
Binaryzation, morphological image operation and the detection of object contour edge, obtain the edge of object, and then calculate object and ground
The geometric center point pixel value (u, v) at the edge of face contact;
Step 4: the camera internal parameter and target point pixel value and combining camera depth extraction obtained using above-mentioned steps
Model calculates object to be measured object image and takes up an official post meaning point to the distance between mobile phone camera L
The size relation between angle beta and the camera vertical field of view angle θ of half is rotated according to camera, selects corresponding depth
Model is extracted, step 1 is asked to the camera internal parametric image central point pixel value v of calculation0, normalized focal length f in y-axisyAnd
Image resolution ratio vmaxAnd step 3 asks the target to be measured ordinate pixel value v of calculation, camera rotation angle beta and mobile phone camera to clap
Take the photograph height h and substitute into the depth extraction model, calculate target point depth value D, calculate target point to optical axis direction it is vertical away from
From Tx:
According to formula (11)~(12), arbitrary point can be calculated on image to the distance between shooting camera L:
Compared with prior art, the beneficial effects of the present invention are: due to the adoption of the above technical scheme,
(1) compared with other monocular vision passive ranging methods, this method does not need large scene calibration place, avoids number
Error caused by according to being fitted;
(2) the depth extraction model established has equipment interoperability, and camera rotation angle is introduced model, for different shaped
Number camera, it is only necessary to for the first time by camera calibration obtain camera internal parameter after, any picture point on single picture can be calculated
Depth;
(3) verified, using this method when distance is to carry out short distance ranging in 0.5~2.6m, depth value measurement is flat
Equal relative error is 0.937%, and when distance is 3~10m, measurement relative error is 1.71%.Therefore, using this method ranging
Measurement accuracy with higher.
Detailed description of the invention
Fig. 1 is distance measuring method flow diagram of the invention;
Fig. 2 is novel target schematic diagram;
Fig. 3 is Corner Detection Algorithm implementation process schematic diagram;
Fig. 4 is that camera upward angle of visibility is higher than horizontal line shooting geometrical model schematic diagram;
Fig. 5 is camera upward angle of visibility lower than horizontal line shooting geometrical model schematic diagram;
Fig. 6 is camera shooting perspective geometry mould signal type;
Fig. 7 is each coordinate system schematic diagram in pin-hole model;
Fig. 8 is camera stereo imaging system schematic illustration;
Fig. 9 is the relation schematic diagram between three kinds of model device object ordinate pixel values and imaging angle;
Figure 10 is the relation schematic diagram between different cameral rotation angle object ordinate pixel value and actual imaging angle.
Specific embodiment
In order to be more clear technical solution of the present invention, below in conjunction with attached drawing 1 to 10, the present invention is carried out specifically
It is bright.It should be understood that specific embodiment described in this specification is not intended to limit just for the sake of explaining the present invention
Determine protection scope of the present invention.
The present invention is the depth extraction and passive ranging method of a kind of optimization based on monocular vision, is included the following steps:
One, mobile phone camera is demarcated, obtains camera internal parameter and image resolution ratio.The calibration uses Zhang Zhengyou
Standardization, and introduce the improved peg model with nonlinear distortion variable and camera internal parameter is corrected.
The physical size size as pixel each in plane is set first as dx*dy (unit: mm), image coordinate system (x,
Y) coordinate of the origin in pixel coordinate system (u, v) is (u0, v0), (x, y) is the normalized coordinate of picture point in real image, figure
Any pixel meets following relationship in two coordinate systems as in:
fx、fyFor the normalization focal length in x-axis and y-axis, any point P in camera coordinates systemc(Xc, Yc, Zc) project to image
It is (x on coordinate systemc, yc, f), it is f with initial point distance that image coordinate system plane is vertical with optical axis z-axis, according to similar triangles original
Reason it follows that
Introduce the improved peg model with nonlinear distortion variable, including the diameter as caused by lens shape defect
To distortion and since there are tangential distortion caused by different degrees of bias, radial distortion mathematical models for optical system are as follows:
Wherein r2=x2+y2, (x ', y ') it is sat for the normalization of the ideal linearity camera coordinates system without distortion term after correction
Scale value, radial distortion value is related with the position of picture point in the picture, and the radial distortion value at image border is larger,
Tangential distortion model mathematical model are as follows:
It wherein include k1、k2、k3、p1、p2Totally 5 kilrrfactors obtain distortion correction Function Modules by formula (3), (4)
Type is as follows:
There are following relationships for conversion from world coordinate transformation to camera coordinates:
Pc=R (PW- C)=RPW+T (6)
Convolution (1)~(6), may be expressed as: with homogeneous coordinates and matrix form
Mint、MextIt is the inside and outside parameter matrix of camera calibration respectively, wherein camera internal parameter includes image center pixel
Value u0、v0, fx、fyFor in x-axis and y-axis normalization focal length, by Java combination OpenCV realize mobile phone camera calibration, acquisition
Inner parameter described in mobile phone camera, camera lens distortion parameter and image resolution ratio vmax、umax;
Two, it by the acquisition to novel target image, establishes camera depth and extracts model.Existing target is that length and width are equal
Black and white chessboard case marker target.The difference of modulation of the invention and existing target is, setting target is apart from camera nearest
One row's grid size is d*d mm, and the width of subsequent every row's grid is to fix, and the previous row's value added of the latter parallelism of length is
X in following formulaiFor the actual range of i-th of angle point to camera, yiFor the length of each grid, then adjacent square length
Difference DELTA diAre as follows:
If the relationship between the computational length and actual range of each grid is f (x), can be obtained according to formula (8):
Through Pearson correlation analysis, it is between length and actual range extremely significant linear relationship (p < 0.01),
Correlation coefficient r be equal to 0.975, by least square method can in the hope of calculate f (x) derivative f ' (x),
Therefore, when a target row grid size nearest apart from camera is d*d mm (the survey when range of d takes 30~60mm
Accuracy of measurement highest) when, subsequent every row's width fixes, length incrementFor d*f ' (x) mm, novel target as shown in Fig. 2,
There are the angles that perspective transform phenomenon makes Harris and Shi-Tomasi etc. common when object on shooting level ground
Point detection algorithm robustness is poor, and can also detect mistake when camera is larger along camera coordinates system ox axis rotated counterclockwise by angle
It loses, therefore the checkerboard angle point detection process based on growth of the propositions such as present invention combination Andreas Geiger and OpenCV are mentioned
The cornerSubPix () function of confession carries out the detection of sub-pixel corner location, and the algorithm robustness is high, larger to distortion degree
Picture extraction effect it is preferable,
The implementation process of Corner Detection Algorithm as shown in figure 3, the above-mentioned modulation of the present invention sub-pixel angle point grid
Step are as follows:
1) angle point is found according to the similarity parameter of pixel each in image and template on the image, positions target angle point position
It sets;
Two different angle point templates are defined first, and a kind of for the angle point parallel with reference axis, another kind is for rotating
45 ° of angle point, each template are made of 4 filtering cores { A, B, C, E }, with carrying out convolution operation with image later;Then sharp
The similarity of each inflection point and angle point is calculated with the two angle point templates:
WhereinIndicate that convolution kernel X (X=A, B, C, E) and template i (i=1,2) are responded in the convolution of some pixel,
WithIt indicates the similarity of two kinds of possible inflection points of template i, calculates the available angle of similarity of each pixel in image
Point similar diagram;It is handled using non-maxima suppression algorithm angle steel joint pixel map to obtain candidate point;Then it is counted with gradient
Method verify these candidate points in the nxn neighborhood of a local, first local area grayscale image carries out sobel filtering, then counts
Weighting direction histogram (32bins) is calculated, finds two therein main mode γ with meanshift algorithm1And γ2;According to
The direction at edge, for desired gradient intensityConstruct a template T.(* indicates cross-correlation operation symbol)
Then product with angle point similarity is judged just to obtain initial angle point with threshold value as angle point score value.
2) the position and direction progress sub-pixel of angle steel joint finely extracts;
Sub-pixel Corner character is carried out with the cornerSubPix () function in OpenCV, by Corner character to sub- picture
Element, to obtain the other Corner Detection effect of sub-pixel;To refine edge direction vector, it is minimized according to image gradient value
Standard deviation rate:
WhereinIt is adjacent pixel collection, the gradient value m with module ii=
[cos(γi)sin(γi)]TMatch.(ask calculation scheme according to document Geiger A, Moosmann F, Caret
al.Automatic camera and range sensor calibration using a single shot[C]//
Robotics and Automation (ICRA), 2012IEEE International Conference on.IEEE, 2012:
3936-3943.)
3) it is finally label angle point and exports its subpixel coordinate, gridiron pattern is grown and rebuild according to energy function, marks
Remember angle point, exports sub-pixel angular coordinate;
According to document " Geiger A, Moosmann F, Caret al.Automatic camera and range
Sensor calibration using a single shot [C] //Robotics and Automation (ICRA),
2012IEEE International Conference on.IEEE, the method that 2012:3936-3943. " is provided optimize energy
Function rebuilds gridiron pattern and marks angle point, energy growth function formula are as follows:
E (x, y)=Ecorners(y)+Estruct(x, y) (16)
Wherein, EcornersIt is the negative value of current chessboard angle point sum, EstructIt is of two adjacent corner points and prediction angle point
With degree;Angle point pixel value is exported by OpenCV.
Linear correlative analysis is carried out to image objects angle, ordinate pixel value using SPSS 22, exports Pearson phase
Relationship number, verified, under equipment and camera the rotation angle of different model, object ordinate pixel value is in actual imaging angle
Extremely significant negative correlativing relation (p < 0.01), in addition, the present invention is also vertical to object under different device models and camera rotation angle
The slope difference of linear function carries out significance test between coordinate pixel value and imaging angle, the results showed that, distinct device type
Number and camera rotation angle under between object ordinate pixel value and imaging angle linear function heteropolar significant (the p < of slope differences
0.01), illustrating the equipment and camera rotation angle of different model, depth extraction model is different,
Abstract function is set according to the linear relationship between object imaging angle α and ordinate pixel value v, establishes and contains mesh
Mark tri- object imaging angle α, ordinate pixel value v and camera rotation angle β parameter space relational models, i.e. α=F (v, β),
Under equipment and camera the rotation angle of different model, subject ordinate pixel value and imaging angle are in pole
Significant negative linear correlation, and the slope of the linear relationship and intercept are different, therefore set:
α=F (v, β)=av+b (17)
Wherein parameter a, b is related with camera model and camera rotation angle,
When α is minimized α=αminWhen=90- θ-β, θ is the half at camera vertical field of view angle, i.e. subject projects
When to picture lowermost end, v=vmax(vmaxFor camera CMOS or ccd image sensor column coordinate valid pixel number), substitute into formula
(17) it can obtain:
90- β-θ=avmax+b (18)
Work as αminWhen+2 90 ° of θ >, i.e. θ > β, camera upward angle of visibility is higher than horizontal line at this time, and camera shoots perspective geometry model
Such as Fig. 4, ground level unlimited distance, α is infinitely close to 90 °, and v is substantially equal to v at this time0-tanβ*fy, fyFor phase under pixel unit
The focal length of machine, when β rotates counterclockwise for negative value, that is, camera also similarly, therefore, substituting into formula (17) can obtain:
90=a (v0-tanβ·fy)+b (19)
Work as αminWhen+2 90 ° of θ <, i.e. θ < β, camera upward angle of visibility is lower than horizontal line at this time, and camera shoots perspective geometry model
If Fig. 5, ground level unlimited distance object imaging angle α are maximized, αmax=αminWhen+2 θ=90- β+θ, i.e. subject
When body projects to picture highest point, v=0, substituting into formula (17) can be obtained:
90- β+θ=b (20)
According to pinhole camera aufbauprinciple, the tangent value of the camera vertical field of view angle θ of half is schemed equal to camera CMOS or CCD
As the half of sensor side length is divided by camera focus, therefore θ can be calculated:
L in formula (21)CMOSFor the side length of camera CMOS or ccd image sensor, convolution (18)~(21), F (α, β)
Are as follows:
δ is camera nonlinear distortion variable error in formula (10), in conjunction with mobile phone camera shooting height h, according to trigonometric function
Principle establishes mobile phone camera depth extraction model:
Three, by the Image Acquisition to target to be measured, target point pixel value u, v are obtained.Figure is carried out by mobile phone camera
As acquisition, perspective geometry model such as Fig. 6 is established, wherein f is camera focus, and θ is the half at camera vertical field of view angle, and h is camera
It takes pictures highly, β is rotation angle of the camera along camera coordinates system ox axis, and camera rotates clockwise β value and is positive, is negative counterclockwise, β value
It is obtained by camera internal gravity sensor, α is object imaging angle;The camera lens obtained in conjunction with first step camera calibration
Distortion parameter carries out nonlinear distortion correction to radial distortion existing for image and tangential distortion error;By the ideal after correction
Linear normalization coordinate value (x, y) substitutes into formula (1), image each point pixel coordinate value after asking calculating to correct, by bilinearity
Image after slotting method corrects pixel value progress interpolation processing after correction;Using computer vision and image procossing
Technology pre-processes the image after correction, including image binaryzation, morphological image operation and the inspection of object contour edge
It surveys, obtains the edge of object, and then calculate the geometric center point pixel value (u, v) at the edge of object and ground face contact.
Four, the camera internal parameter and target point pixel value and combining camera depth extraction mould of above-mentioned steps acquisition are utilized
Type calculates object to be measured object image and takes up an official post meaning point to the distance between mobile phone camera L.Angle beta and half are rotated according to camera
Camera vertical field of view angle θ between size relation, select corresponding depth model, ask the camera internal of calculation to join above-mentioned steps
Number image center pixel value v0, normalized focal length f in y-axisyAnd image resolution ratio vmaxAnd above-mentioned steps ask the to be measured of calculation
Object ordinate pixel value v, camera rotation angle beta and mobile phone camera shooting height h substitute into the depth extraction model, calculate
Target point depth value D,
Fig. 7 is camera stereo imaging system schematic diagram, and midpoint P is camera position, and the straight line and image where point A, B are flat
Face is parallel, and coordinate of the A under camera coordinates system is (X, Y, Z), and the coordinate of point B is (X+Tx, Y, Z), project to plane of delineation A '
(xl, yl)、B’(xr, yr) on, it can be obtained according to formula (2):
In conjunction with formula (1) and formula (22), the two o'clock A ' that Y value is identical and depth Z is equal, the horizontal parallax of B ' can be derived
D:
It is thus known that camera focus f, image center coordinate (u0, v0) and as pixel each in plane in the direction of the x axis
Physical size size dx, in conjunction with depth extraction model, calculate target point to optical axis direction vertical range Tx:
In pin-hole model, the transformational relation between each coordinate system of camera is as shown in figure 8, calculating target point depth value D
And its vertical range T to optical axis directionxOn the basis of, according to formula (11)~(12), arbitrary point on image can be calculated
To shooting the distance between camera L:
Embodiment 1
Below by taking millet 3 (MI 3) mobile phone as an example, the depth for illustrating the optimization of the invention based on monocular vision is mentioned
It takes and passive ranging method.
One, mobile phone camera is demarcated, obtains camera internal parameter and image resolution ratio
Use ranks number be 8*9 size be 20*20 gridiron pattern scaling board as the experimental material of camera calibration, lead to
The scaling board picture that 3 mobile phone camera of millet acquires 20 different angles is crossed, using OpenCV according to above-mentioned improved with non-thread
The camera calibration model of sex distortion item demarcates millet 3 (MI 3) mobile phone camera,
Scaling board picture is read using fin () function first, and obtains the image of the first picture by .cols .rows
Resolution ratio;Then sub-pixel angle point in scaling board picture is extracted by find4QuadCornerSubpix () function, be used in combination
DrawChessboardCorners () function marks angle point;CalibrateCamera () function is called to demarcate camera,
It is used for obtained camera interior and exterior parameter to carry out projection again to the three-dimensional point in space calculating, obtains new subpoint, calculate
Error between new subpoint and old subpoint;Camera internal reference matrix and distortion parameter are exported and save,
Calibration gained camera internal parameter are as follows: fx=3486.5637, u0=1569.0383, fy=3497.4652, v0=
2107.9899, image resolution ratio is 3120 × 4208, camera lens distortion parameter are as follows: [0.0981, -0.1678,0.0003, -
0.0025,0.0975],
Two, it by the acquisition to novel target image, establishes camera depth and extracts model
The initial experiment material that the present invention uses traditional gridiron pattern scaling board of 45*45mm to design as target, to calculate
The difference of adjacent square length, the present invention devise 6 groups of experiments, extract traditional X-comers that grid size is 45*45mm
Value, and ask calculate adjacent corner points between the actual physics distance that is represented under world coordinate system of unit pixel, to guarantee to indulge between angle point
Coordinate pixel value difference is roughly equal, the length y of each gridiValue it is as shown in table 1,
The calculating width of each grid of table 1
Table 1 Computing width of each grid
Through Pearson correlation analysis, it is between length and actual range extremely significant linear relationship (p < 0.01),
Correlation coefficient r is equal to 0.975, can be in the hope of derivative f ' (x)=0.262 of calculating f (x), therefore, when the mark by least square method
When a range row grid size nearest from camera is 45*45mm, then every row's width is fixed, width value added Δ d is
11.79mm,
The angle point of the novel target is extracted by the Robust Algorithm of Image Corner Extraction in specific implementation step,
The present invention choose respectively millet, Huawei, tri- kinds of different models of iPhone smart phone as image capture device,
Camera rotates angle beta={ -10 °, 0 °, 10 °, 20 °, 30 ° }.Data are acquired using the Corner Detection Algorithm, and to its relationship
Carry out Function Fitting, Fig. 9 be β=10 ° when three kinds of different models smart phone ordinate pixel value and image objects angle it
Between relationship, Figure 10 is that different cameral rotates relationship between ordinate pixel value and image objects angle under angle,
The camera apparatus and camera of different model rotate angle, with the increase of ordinate pixel value, image objects angle
Taper off trend, and the difference of device model and camera rotation angle makes that different lines are presented between pixel value and imaging angle
Property functional relation, using SPSS 22 to image objects angle, ordinate pixel value carry out Linear correlative analysis, export Pearson
Correlation coefficient r is as shown in table 2.
2 object ordinate pixel value of table and imaging angle related coefficient
Table 2 Pearson correlation coefficient of image ordinate pixel
values and actual imaging angles
Note: * * indicates extremely significant (p < 0.01).
Note:**represents very significant correlation (p < 0.01)
Verified, equipment and camera with model rotate under angle, and object ordinate pixel value is in actual imaging angle
Extremely significant negative correlativing relation (p < 0.01), correlation coefficient r are greater than 0.99.In addition, the present invention is also to different device model and phase
The slope difference that machine rotates linear function between object ordinate pixel value and imaging angle under angle carries out significance test.Knot
Fruit show distinct device model and camera rotation angle under between object ordinate pixel value and imaging angle linear function it is oblique
Rate difference is extremely significant (p < 0.01), illustrates the equipment and camera rotation angle of different model, depth extraction model is not
Together.
3 mobile phone camera inner parameter of millet is substituted into formula (10) by the depth extraction model according to specific embodiment
::
The specific depth extraction model of the equipment is obtained according to trigonometric function principle according to trigonometric function principle are as follows:
Three, by the Image Acquisition to target to be measured, target point pixel value u, v are obtained.
Use (MI 3) camera of millet mobile phone 3 as picture collection equipment, carries out picture collection by camera trivets, and
The height h for measuring camera to ground is equal to 305mm, and camera rotation angle β is equal to 0 °,
Nonlinear distortion correction is carried out to radial distortion existing for image and tangential distortion error;
The camera lens distortion parameter obtained according to first step camera calibration: [0.0981, -0.1678,0.0003, -
0.0025,0.0975], ideal linearity normalized coordinate value after correcting is calculated according to formula (5):
Image each point pixel coordinate value after correcting is calculated in conjunction with formula (1) and (2), is handled and is rectified by bilinear interpolation
Image after just;
The present invention measures its depth and distance by taking the cuboid box being placed on level ground as an example, first to acquisition
Image carries out binary conversion treatment, then carries out edge detection to cuboid box using Canny operator, extracts object profile.
Extracting cuboid box bottom margin central point pixel value is (1851.23,3490).
Four, the camera internal parameter and target point pixel value and combining camera depth extraction mould of above-mentioned steps acquisition are utilized
Type calculates object to be measured object image and takes up an official post meaning point to the distance between mobile phone camera L.
Camera internal parameter, camera are taken pictures height h, rotation angle beta and cuboid box bottom margin central point is vertical sits
Mark pixel value v, which substitutes into formula (24), can calculate the object actual imaging angle equal to 69.58 °.According to trigonometric function original
Reason calculates target point depth value D (unit: mm):
D=305*tan 69.58 °=819.21 (27)
By parameter fx, u0, D and cuboid box bottom margin central point abscissa pixel value u substitute into formula (12) and can count
Vertical range T of the calculation object geometric center point to optical axis directionx:
Therefore, which reaches shooting camera in the distance L of floor projection point are as follows:
By tape measuring, distance of the cuboid box apart from camera floor projection point is 827mm, therefore uses the present invention
Carry out ranging, relative error 0.62%.