A kind of camera simple calibrating method and device extracting two vanishing points based on A4 paper
Technical field
The present invention relates to camera calibration more particularly to it is a kind of based on A4 paper extract two vanishing points camera simple calibrating method and
Device belongs to computer vision field.
Background technique
Popular non-metric camera application, which generally requires, demarcates camera parameter.Camera calibration experienced from needs
Traditional scaling method of accuracy flag object does the active vision scaling method of special exercise to control camera, then arrives based on image certainly
The development course of the self-calibrating method of body feature.In traditional scaling method, it is used widely based on tessellated method, still
Calibration result is influenced by X-comers detection accuracy, and there are the deficiencies of inconvenient to carry, cumbersome vulnerable to interference and template construct;Base
In active vision scaling method without place calibration object, but require control camera do accurate peculair motion, for can not essence
Really the occasion of control camera is not applicable;Camera Self-Calibration method does not need that specific control condition is arranged, only according to multiple image
Relationship direct solution camera parameter between corresponding points mainly includes Camera Self-Calibration based on vanishing point, based on plane or solid
The Camera Self-Calibration of template and self-calibration based on natural scene.
Most of camera calibration methods can only be implemented by professional person, and for ordinary populace, there are ease of use issues.
Therefore it " can gather materials on the spot ", is user friendly, camera simple calibrating method that noise immunity is strong is for popular non-metric camera
Using being undoubtedly of great significance.
The self-calibrating method of camera is because the features such as its simple and flexible and strong applicability, is concerned, wherein being demarcated based on vanishing point
Self-calibrating method due to restrictive condition it is less, it is in widespread attention and further investigation.Self-calibration side commonly based on vanishing point
Method needs to obtain the vanishing point in three directions in scene, this is often difficult to reach requirement in practical applications;By calculating multiple images
In the vanishing points of two orthogonal directions reduce constraint condition the method that carries out camera calibration, but calculated result extracts vanishing point
Accuracy it is more sensitive.Therefore, the accuracy that the easy availability of marker and vanishing point extract is the method needs based on vanishing point
The critical issue focused on solving.
Since A4 paper is easily obtained, and inherently there are two pairs of parallel edges, is suitably applied the self-calibration side based on vanishing point
Method, but in complex environment, when according to A4 paper image zooming-out sides aligned parallel line and then extracting vanishing point, it is easy to be illuminated by the light and makes an uproar with background
The influence of sound.Therefore, research has the camera simple calibrating method based on A4 paper of stronger noise immunity, for popular non-amount
Camera applications are surveyed, undoubtedly there is important theory significance and application value.
Summary of the invention
Goal of the invention: in view of the deficiencies of the prior art, it is an object of that present invention to provide one kind to extract two vanishing points based on A4 paper
Camera simple calibrating method and device, can be used for popular non-metric camera application, have it is simple easily implement, noise immunity is strong etc.
Advantage.
Technical solution: for achieving the above object, a kind of camera extracting two vanishing points based on A4 paper of the present invention
Simple calibrating method includes the following steps:
(1) image comprising A4 paper of camera acquisition is obtained, and obtains the grayscale image after filtering and noise reduction after being pre-processed;
(2) edge extracting is carried out to grayscale image and obtains edge image;
(3) edge image is scanned, finds and is used as boundary starting point at 0 to 1 mutation or 1 to 0 mutation, and from the starting found
Point starts to search for, using the longest boundary that can be searched as A4 paper profile point set;
(4) A4 paper profile point set is divided by 4 classes using spectrum multiple manifold clustering method, and least square method is respectively adopted to this
4 point sets carry out the fitting of straight line, obtain 4 straight lines;
(5) 6 intersection points of 4 straight lines of gained are sought, 2 intersection points by coordinate not in image range are considered as vanishing point;
(6) step (1) to (5) are repeated and extracts the vanishing point in multiple different shooting angles A4 paper image, calculated based on vanishing point
The intrinsic parameter of camera out.
In preferred embodiments, the pretreatment of image includes that the RGB image that will acquire is converted in the step (1)
Grayscale image, and median filter process is carried out to grayscale image.
In preferred embodiments, edge extracting, tool are carried out to grayscale image using Canny operator in the step (2)
Body includes:
(2.1) Gaussian Blur processing is carried out to image;
(2.2) gradient intensity of each pixel and direction in image are calculated;
(2.3) gradient intensity of pixel each in image is compared with the gradient put along positive and negative gradient direction, such as
The gradient intensity of fruit current point is maximum, then is reserved for marginal point;
(2.4) high and low two threshold values are set and are reserved for marginal point if the gradient magnitude of pixel has been more than high threshold,
If being lower than Low threshold, it is excluded, if fallen between, 8 pixels around the pixel is checked, if there is being higher than
High threshold, then it is left marginal point.
In preferred embodiments, A4 paper contour extraction method specifically includes in the step (3):
(3.1) scan binary map, find starting point of the pixel that is mutated from 0 to 1 of pixel value as outer boundary, pixel value from
Starting point of the pixel of 1 to 0 mutation as hole boundary;
(3.2) boundary is continued searching since the starting point found, borderline pixel is marked, in this process
Middle one unique ID of distribution gives newfound boundary, and referred to as NBD, NBD is set as 1 when initial, and one new boundary of every discovery adds
1, it is based on the longest principle of A4 paper profile, extracts the profile point set of A4 paper.
In preferred embodiments, camera is calculated by extracting the vanishing point of at least 5 A4 paper images in the step (5)
Internal reference states matrix, specifically: remember that the vanishing point of extraction indicates are as follows: System of linear equations is established according to Vanishing Point TheorySolving equations obtain matrix
It then will by square-root methodIt is decomposed intoAgain the result of decomposition is inverted to obtainFinally obtain camera intrinsic parameter
MatrixWherein subscript T indicates transposition, the 3rd row the 3rd column in 33 representing matrix of subscript.
On the other hand, a kind of camera simple calibrating device extracting two vanishing points based on A4 paper of the present invention, comprising:
Pretreatment unit for obtaining the image comprising A4 paper of camera acquisition, and obtains filtering and goes after being pre-processed
Grayscale image after making an uproar;
Edge extracting unit obtains edge image for carrying out edge extracting to grayscale image;
Contours extract unit is found and is used as boundary starting point at 0 to 1 mutation or 1 to 0 mutation for scanning edge image,
And searched for since the starting point found, using the longest boundary that can be searched as A4 paper profile point set;
Line fitting unit for A4 paper profile point set to be divided into 4 classes using spectrum multiple manifold clustering method, and is respectively adopted
Least square method carries out the fitting of straight line to this 4 point sets, obtains 4 straight lines;
Vanishing point extraction unit, 2 friendships for seeking 6 intersection points of 4 straight lines of gained, by coordinate not in image range
Point is considered as vanishing point;
And camera calibration unit, it is calculated for the vanishing point in multiple different shooting angles A4 paper image based on extraction
The intrinsic parameter of camera out.
Based on identical design, invention additionally discloses a kind of computing device, including memory, processor and it is stored in storage
On device and the computer program that can run on a processor, the computer program realize the base when being loaded on processor
The camera simple calibrating method of two vanishing points is extracted in A4 paper
The utility model has the advantages that the method provided by the invention extracted two vanishing points based on A4 paper and carry out camera simple calibrating, utilizes
The characteristics of A4 paper edge is mutually orthogonal parallel lines, by carrying out edge detection, contours extract to the image for including A4 paper
And straight line fitting, the vanishing point of plane of delineation both direction is calculated, and then the camera calibration method based on two vanishing points calculates phase
The intrinsic parameter of machine.This method is simply easily implemented, and has preferable noise immunity, can effectively eliminate background noise influence, quasi-
The parallel lines information in image is really extracted, accurate vanishing point is obtained.The camera internal reference being calculated meets accuracy requirement, can use
In popular non-metric camera application.
Detailed description of the invention
Fig. 1 is that vanishing point extracts flow chart in the embodiment of the present invention.
Fig. 2 is edge detection effect picture in the embodiment of the present invention, wherein (a) is original image, it (b) is edge detection results figure.
Fig. 3 is the A4 paper edge effect picture extracted in the embodiment of the present invention.
Fig. 4 is SMMC algorithm Clustering Effect figure in the embodiment of the present invention.
Fig. 5 is straight line fitting effect picture in the embodiment of the present invention.
Specific embodiment
In the following with reference to the drawings and specific embodiments, the present invention will be further described.
As shown in Figure 1, a kind of camera simple calibrating method that two vanishing points are extracted based on A4 paper disclosed by the embodiments of the present invention,
Mainly include the following steps:
Step 1: image preprocessing
(a) it is converted into grayscale image: grayscale image is converted by the RGB image comprising A4 paper that camera obtains first, after convenient
Continuous image procossing.
(b) median filter process: 3 × 3 median filter process is carried out to obtained grayscale image, background is weakened with this and is made an uproar
Sound reduces influence of the noise to result is extracted.
Step 2:Canny operator A4 paper edge is extracted
(a) Gaussian Blur is handled: convolution is carried out using one 5 × 5 Gauss collecting image, smoothed image is reached with this,
Noise is filtered out, the purpose of edge detection performance is improved.
(b) gradient magnitude and direction are calculated: calculating the gradient intensity of each pixel and direction in image.
(c) non-maxima suppression: for each pixel in image, by the gradient intensity of current point and along positive negative gradient
The gradient put on direction compares, if the gradient intensity of current point is the largest, is retained as marginal point.
(d) dual threshold detection and hysteresis threshold: setting ratio is that the high threshold of 2:1 or 3:1 and Low threshold further extract
Edge.If the gradient magnitude of a certain pixel has been more than high threshold, which is left edge pixel;If being lower than low threshold
Value, then the pixel, which is suppressed, excludes;If 8 neighborhood territory pixels of the pixel are checked between two threshold values, if 8 neighborhoods
There is the gradient magnitude of pixel to be higher than high threshold in range, be then left edge pixel, otherwise inhibits to exclude.Final detection effect
As shown in Figure 2.
Step 3: contours extract
(a) find boundary starting point: the bianry image of input only has 0 and 1 two kind of value, and outer boundary indicates that pixel value is 1
Connected region, the connected region that hole boundary representation pixel value is 0.Binary map is scanned, the pixel that pixel value is mutated from 0 to 1 is found
As the starting point of outer boundary, starting point of the pixel that pixel value is mutated from 1 to 0 as hole boundary.
(b) it searches for boundary: continuing searching boundary since the starting point found, borderline pixel is marked,
A unique ID is distributed during this to newfound boundary, referred to as NBD, NBD is set as 1 when initial, and every discovery one is new
Boundary add 1.Based on the longest principle of A4 paper profile, the profile point set of A4 paper is extracted.The profile extracted is as shown in Figure 3.
Step 4: straight line fitting
(a) spectrum multiple manifold cluster: using the method for spectrum multiple manifold cluster (SMMC), by the mixing point set on 4 sides of A4 paper point
For four classes, classifying quality is as shown in Figure 4.
(b) straight line fitting: after profile point set is clustered by side, one point set of each line correspondences, using least square
Method carries out the fitting of straight line to these point sets, and Fig. 5 is the result of fitting.
Step 5: extracting vanishing point
(a) according to 4 straight lines fitted, available 6 intersection points of straight line intersection intersection between lines: are calculated.
(b) coordinate judges: 4 are A4 paper angle points in 6 intersection points, and 2 are vanishing points, usually not due to the image for calibration
Biggish inclination angle is had, vanishing point is not generally possible to appear in image range, therefore according to the coordinate of point whether in image range
Inside determine which two intersection point is vanishing point.
Step 6: camera calibration
The A4 paper image that at least 5 different perspectivess are shot using camera, extracts its image vanishing point respectively, indicates are as follows:System of linear equations is established based on Vanishing Point TheorySolving equations obtain matrixIt then will by square-root methodIt is decomposed intoAgain the result of decomposition is inverted to obtain
At this timeAn invariant is differed with camera Intrinsic Matrix K, since the last one element of K is 1, so camera intrinsic parameter
Matrix
Based on identical inventive concept, a kind of camera extracting two vanishing points based on A4 paper disclosed in another embodiment of the present invention
Simple calibrating device, comprising: pretreatment unit, for obtaining the image comprising A4 paper of camera acquisition, and after being pre-processed
Grayscale image after obtaining filtering and noise reduction;Edge extracting unit obtains edge image for carrying out edge extracting to grayscale image;Profile
Extraction unit is found for scanning edge image and is used as boundary starting point at 0 to 1 mutation or 1 to 0 mutation, and from finding
Initial point starts to search for, using the longest boundary that can be searched as A4 paper profile point set;Straight line computing unit, for using spectrum multithread
A4 paper profile point set is divided into 4 classes by shape clustering method, and least square method is respectively adopted and intends this 4 point sets progress straight lines
It closes, obtains 4 straight lines;Vanishing point extraction unit, for seeking 6 intersection points of 4 straight lines of gained, by coordinate not in image range
2 intersection points be considered as vanishing point;And camera calibration unit, in multiple different shooting angles A4 paper image based on extraction
Vanishing point calculate the intrinsic parameter of camera.
Based on identical inventive concept, invention additionally discloses a kind of computing device, including memory, processor and it is stored in
On memory and the computer program that can run on a processor, the computer program is realized above-mentioned when being loaded on processor
Based on A4 paper extract two vanishing points camera simple calibrating method.