Summary of the invention
For the deficiencies in the prior art, the present invention proposes a kind of distance attention device of automotive safety based on binocular stereo vision and method, reaches the poor environment practicality such as the visual condition that reduces costs, improves the tunnel at night, plays the purpose that spacing is warned, reduced traffic accident.
A kind of distance attention device of automotive safety based on binocular stereo vision, comprise buzzer phone and keyboard, also comprises LED display after LED display in car, car, front side binocular camera shooting head, rear side binocular camera shooting head and central processing unit, wherein:
Front side binocular camera shooting head: be used to gathering the image in this automobile head the place ahead;
Rear side binocular camera shooting head: be used to gathering the image at this automobile tail rear;
Central processing unit: for front side binocular camera shooting head and rear side binocular camera shooting head are demarcated, four parameters of relative distance between the focal length of relative distance, rear side binocular camera shooting head and rear side binocular camera shooting head between the focal length of acquisition front side binocular camera shooting head, front side binocular camera shooting head; And the correct image to gathering, the image slices vegetarian refreshments is mated, obtain the parallax of each pixel on image; According to the parallax of pixel on above-mentioned four parameters and image, obtain distance between this automobile and front truck and distance with the rear car;
LED display in car: for according to user's request, safety distance being set;
LED display after car: keep a safe distance be used to pointing out the rear car personnel.
Three road input ends of described central processing unit connect respectively the mouth of the front side binocular camera shooting head that is positioned over automobile head, the rear side binocular camera shooting head mouth that is positioned over automobile tail and the mouth of keyboard; Three road mouths of central processing unit connect respectively the input end that is positioned over the buzzer phone in car, be positioned over the input end of LED display after the car of car rear seat windscreen below and be positioned over LED display input end in the car in car.
The method that employing is warned based on the automotive safety distance attention device of binocular stereo vision comprises the following steps:
Step 1, employing central processing unit are demarcated front side binocular camera shooting head and rear side binocular camera shooting head respectively, and then obtain four parameters of relative distance between the focal length of relative distance, rear side binocular camera shooting head between the focal length, front side binocular camera shooting head of front side binocular camera shooting head and rear side binocular camera shooting head, and preserve;
Step 2, employing front side binocular camera shooting head gather the image in this automobile head the place ahead, adopt rear side binocular camera shooting head to gather the image at this automobile tail rear;
Step 3, adopt the correct image of polar curve correcting mode to above-mentioned collection, and then obtain a certain measured point and correspond to respectively two polar curves that are corrected pixel place on image;
Absolute value and the matching process of step 4, employing pixel gray scale difference mate two corresponding pixel points on two image polar curves, and then obtain the parallax between above-mentioned two pixels;
Step 5, repeating step 3 are to step 4 until obtain the parallax of all pixels on image;
Step 6, according to the parallax of four parameters that obtain in step 1 and pixel, obtain between this automobile and front automobile distance and and the rear automobile between distance;
Step 7, get with the front automobile distance value in minimum distance as the distance value of final and front automobile; Get with rear automobile distance value in minimum distance as the distance value of final and rear automobile;
Step 8, the required safety distance value of setting according to the user, the distance value of judgement and front automobile whether in the safety distance scope, if, return to execution step 2, otherwise DSP sends a signal to buzzer phone, realize reporting to the police; Whether judgement and the distance value of rear automobile be in the safety distance scope, if return to execution step 2, otherwise DSP sends a signal to LED display after car, realizes the prompting to the rear car personnel.
Step 6 described according in step 1, obtaining four parameters and the parallax of pixel, obtain between this automobile and front automobile distance and and the rear automobile between distance;
Calculate and front automobile between as follows apart from the Z formula:
Wherein, f is the focal length of front side binocular camera shooting head; D is relative distance between the binocular camera shooting head of front side; x
lFor the abscissa value of pixel in image in the binocular camera shooting head of front side, l means left side left; x
rFor the abscissa value of pixel in another image in the binocular camera shooting head of front side, r means right side right;
Calculate and the rear automobile between as follows apart from Z ' formula:
Wherein, f ' is the focal length of rear side binocular camera shooting head; D ' is relative distance between rear side binocular camera shooting head; X '
lFor the abscissa value of pixel in image in rear side binocular camera shooting head, l means left side left; X '
rFor the abscissa value of pixel in another image in rear side binocular camera shooting head, r means right side right.
Advantage of the present invention:
By head binocular camera shooting unit, obtain the image of two width front side vehicles, according to calibration result with to this matching result to image, can obtain the minor increment of Ben Che and front truck, this lowest distance value compares with the safety distance by keyboard to set up, if be less than safety distance, buzzer warning in car, point out Ben Che driver to slow down and go slowly, and maintains safe distance; By afterbody binocular camera shooting unit, obtain the image of two width car front vehicle, according to calibration result with to this matching result to image, can obtain the minor increment of Ben Che and rear car, this lowest distance value compares with the safety distance by keyboard to set up, if be less than safety distance, the LED of tailstock section shows information warning, and prompting rear car driver is slowed down and gone slowly, and maintains safe distance; Thereby patent of the present invention not only guaranteed the safety of this car and front truck, and for rear car, information warning is arranged equally.For avoiding or reducing traffic accident, ensure that numerous drivers and friend's passenger the security of the lives and property is significant.With existing other vehicle ranging methods, compare, binocular stereo vision range finding tool equipment has very large price advantage aspect cost; The stereoscopy passive ranging method can be caught the graphicinformation of automobile, can obtain more quantity of information.In addition in conjunction with camera, auto iris and AWB technology, can under the poor condition of the visual conditions such as night, tunnel, apply.Thereby the present invention has broad prospects in the automobile safety distance fields of measurement.
The specific embodiment
Below in conjunction with accompanying drawing, an embodiment of the present invention is described further.
As shown in Figure 1, a kind of distance attention device of automotive safety based on binocular stereo vision, comprise buzzer phone and keyboard, also comprise LED display after LED display in car, car, front side binocular camera shooting head (comprising automobile left side of head camera and automobile right side of head camera), rear side binocular camera shooting head (comprising automobile tail left side camera and automobile tail right side camera) and central processing unit, wherein: front side binocular camera shooting head is for gathering the image in this automobile head the place ahead; Rear side binocular camera shooting head is for gathering the image at this automobile tail rear; Central processing unit is used for front side binocular camera shooting head and rear side binocular camera shooting head are demarcated, four parameters of relative distance between the focal length of relative distance, rear side binocular camera shooting head and rear side binocular camera shooting head between the focal length of acquisition front side binocular camera shooting head, front side binocular camera shooting head; And the correct image to gathering, the image slices vegetarian refreshments is mated, obtain the parallax of each pixel on image; According to the parallax of pixel on above-mentioned four parameters and image, obtain distance between this automobile and front truck and distance with the rear car; In car, LED display is for arranging safety distance according to user's request; After car, LED display is for pointing out the rear car personnel to keep a safe distance.
As shown in Figure 2, in car, LED display 4, keyboard 5, DSP and peripheral circuit 1 are arranged on instrument desk.In car, buzzer phone 3 is installed on the bearing circle below.In front side binocular camera shooting head 2, the camera of two same models is parallel to be fixed on headstock section bonnet.After car, LED display 6 is installed on tailstock section windshield.In rear side binocular camera shooting head 7, the camera of two same models is parallel to be fixed on the afterbody case cover.Three road input ends of described central processing unit connect respectively the mouth of the front side binocular camera shooting head that is positioned over automobile head, the rear side binocular camera shooting head mouth that is positioned over automobile tail and the mouth of keyboard; Three road mouths of central processing unit connect respectively the input end that is positioned over the buzzer phone in car, be positioned over the input end of LED display after the car of car rear seat windscreen below and be positioned over LED display input end in the car in car.
In the embodiment of the present invention, front side binocular camera shooting head and rear side binocular camera shooting head all adopt the CCD camera that four models are IRIT-N370S; The image obtained due to CCD is the image of analog signal, and DSP can not directly read analog signal, therefore analog signal need to be decoded as to digital signal.As shown in Figure 3, in the embodiment of the present invention, the inner decoding chip adopted of central processing unit is SAA7113.A slice SAA7113 chip, can be decoded into the analog picture signal that two-way CCD camera is sent here the standardized digital signal that DSP identifies; In the embodiment of the present invention, the dsp chip model that central processor adopts is TMS320DM642; Because data volume in image processing process is very large, and this DSP on-chip memory finite capacity, therefore can not meet memory requirement in image processing process.In the embodiment of the present invention, the TMS320DM642 chip core utilizes EMIFA bus expansion external memory storage FLASH and SDRAM.In the embodiment of the present invention, having expanded two sizes is that the 32MB model is the SDRAM of HY57V283220T-H, and the FLASH memory device, when power down, can wrap significant data and the program of depositing, and the embodiment of the present invention has been expanded the FLASH memory device of a slice AM29LV033C model.
In the embodiment of the present invention, as shown in Figure 4 and Figure 5, after the SAA7113 chip decoding be connected with automobile head camera, digital signal is transported to TMS320DM642 by the VP0 mouth.After the SAA7113 chip decoding be connected with the automobile tail camera, digital signal is transported to TMS320DM642 by VP1.In Fig. 4, the power supply of SAA7113 is divided into digital power (VCC) and analog power (VCCA), and its size is+3.3V, and pin 10,3,42 connects analog power ((VCCA); Pin 18,34,29,33 connects digital power (VCC).After pin 44 connects a 1k resistance, connect digital power (VCC).In figure, the corresponding ground wire of SAA7113 also is divided into digitally and in analog.Pin 11,2,41 and 6 connects in analog, and pin 16,28,30,35,37,8 connects digitally.Pin 26 connects digitally after connecing the resistance of a 3.3k.The input clock of SAA7113 chip is provided by the external active crystal oscillator, and big or small 24.576MHz, by pin 1 input.Pin 17 is connected with the VP0CLK0 pin of TMS320DM642 in Fig. 5, and the capable locking system clock by the 27MHz of pin 17 output, send to the catch clock of the VP0CLK0 pin of TMS320DM642 in Fig. 5 as video port.Pin 23,24 passes through I
2The C bus directly is connected with SCLO, the SDAO pin of TMS320DM642 chip in Fig. 5.After video analog signal connect a 18k resistance, the 47nF electric capacity of connecting, be input to the SAA7113 chip by pin 1.After video analog signal connects a 18k resistance, connect a 5.6k resistance, be connected in analog.Pin 4,9 is connected respectively after a 47nF electric capacity, is connected in analog.Decoded digital signal is by VP0[7:0] output, pin VP0D9, VP0D8, VP0D7, VP0D6, VP0D5, VP0D4, VP0D3 and the VP0D2 of TMS320DM642 chip in pin 12,13,14,15,19,20,21,22 difference map interlinkings 5.
The I/O interface resource of TMS320DM642 is limited, and the present invention needs LED display and buzzer phone in LED display after external connection keyboard, car, car, therefore need more I/O interface.In the embodiment of the present invention, adopt the CPLD chip to expand the I/O interface of TMS320DM642, the chip model of selecting is the EPM240T100I5N that ALTERA company produces.As shown in Figure 6, this chip is comprised of 100 pins, has expanded greatly the I/O interface.In patent of the present invention, after keyboard, car, LED display, the interior LED display of car directly are not connected with the I/O of DSP with buzzer phone, but are connected with the I/O after the CPLD expansion.
TMS320DM642 realized with being connected by external interface of CPLD, with Fig. 6 pin, was connected as follows in conjunction with Fig. 5.Pin AED0, the AED1 of dsp chip, AED2, AED3, AED4, AED5, AED6, AED7, EXT_INTER4, ACEI, ASWE are connected with the pin 1,2,3,4,5,6,7,8,27,28,29 of CPLD respectively.Pin AEA3, the AEA4 of dsp chip, AEA5, AEA6, AEA7, AEA8, AEA9, AEA10 are connected with the pin 15,16,17,18,19,20,21,26 of CPLD respectively.
In the embodiment of the present invention, keyboard is the rank scanning formula keyboard of 4x4, as shown in Figure 7, is comprised of 4 lines and 4 alignments, on each point of crossing, a button is set, totally 16 buttons.4 lines of rank scanning formula keyboard are connected with the pin 68,69,70,71 of CPLD respectively.4 alignments of rank scanning formula keyboard are connected with the pin 72,73,74,75 of CPLD respectively.
As shown in Figure 8, an end of the straight polarity of buzzer phone is connected to above the 5V power supply circuit of buzzer phone, and the other end is connected to the collector terminal of aerotron, transistor emitter ground connection, and base stage is connected with the pin 33 of CPLD after connecing the resistance of a 4.7k.Aerotron is selected the positive-negative-positive aerotron.
What in car, LED display adopted is that model is 1602 LCD, and physical circuit connects as shown in Figure 9.1602 pin 4,5,6,7,8,9,10,11,12,13,14 is connected with the pin 86,87,89,85,84,83,82,81,78,77,76 of CPLD respectively.1602, are connected with the LCD VCC of supply module respectively after the pull-up resistor of a 4.7k in parallel with every connection lead of CPLD.1602 pins 1 are connected with pin 3 after connecing the resistance of a 1k, and pin 2 is connected with the LCD VCC of supply module respectively with pin 15, pin 16 ground connection.
The LED dot matrix of the 8x8 that the afterbody LED display adopts, physical circuit connects as shown in figure 10. LED display pin 9,14,8,12,1,7,2,5 connects respectively the emitter of 8 positive-negative-positive aerotrons, base stage corresponding to aerotron, after the resistance of a 4.7k of series connection, is connected with the pin 86,87,89,91,92,95,96,97 of CPLD respectively.After the collecting electrode of 8 aerotrons connects together, be connected with the 3.3V supply module. LED display pin 13,3,4,10,6,11,15,16 has been connected respectively after the resistance of 100 Ω, with the pin 85,84,83,82,76,77,78,81 of CPLD, is connected respectively.
Figure 11 is parallel Binocular Stereo Vision System range finding illustraton of model.As shown in figure 11, the parallel placement of two cameras, camera coordinate system and left side camera photocentre point O
lOverlap, the focal length of pick up camera is f, the photocentre O of left and right cameras
lWith O
rSpacing is b (parallax range).(x
Cl, y
Cl, z
Cl) for take the system of axes that the left side camera photocentre sets up as initial point, (x
Cr, y
Cr, z
Cr) for take the system of axes that right side pick up camera photocentre sets up as initial point, (u, v) is the pixel coordinate system with the foundation of image center.P(x
w, y
w, z
w) be the object point in world coordinate system in reality scene, (x
w, y
w, z
w) be the position coordinate of P in the reality scene system of axes, some p
lWith a p
rBe respectively object point P (x
w, y
w, z
w) imaging point on left image and right image.X
lAnd x
rFor the abscissa of image coordinate system middle left and right image imaging point, y
lAnd y
rFor the ordinate of image coordinate system middle left and right image imaging point, parallax is d=x
l-x
r.According to Similar Principle of Triangle, can obtain the three-dimensional coordinate of spatial point under camera coordinate system suc as formula (3):
Wherein, (x
c, y
c, z
c) be exactly space mid point P (x
w, y
w, z
w) coordinate figure in camera coordinate system; z
cFor the depth value of required object point, required target range namely.
According to formula (3), can find out, as long as ask for parallax value according to the matching point of the correspondence in the image of left and right, just can utilize parallax range, focal length to obtain the coordinate of the three dimensional space point that object point is corresponding, just can obtain target range z
c.
The method that employing is warned based on the automotive safety distance attention device of binocular stereo vision as shown in figure 12, comprises the following steps:
Step 1, employing central processing unit are demarcated front side binocular camera shooting head and rear side binocular camera shooting head respectively, and then obtain four parameters of relative distance between the focal length of relative distance, rear side binocular camera shooting head between the focal length, front side binocular camera shooting head of front side binocular camera shooting head and rear side binocular camera shooting head, and preserve;
In the embodiment of the present invention, employing be that the plane reference method that Zhang Zhengyou proposes is carried out camera calibration, the purpose that shooting is demarcated is the inside and outside parameter that obtains pick up camera, demarcating steps is as follows:
Step 1-1, print mark chessboard calibration plate.The scaling board that the embodiment of the present invention adopts is the gridiron pattern of angle point several 6 * 4, and the gridiron pattern size is 15mm * 15mm;
Step 1-2, build the binocular stereo vision unit, the left and right camera is taken scaling board at synchronization, preserves a pair of picture.After conversion scaling board angle and distance, repeat to take 12 times, preserve 12 pairs of pictures;
Step 1-3, respectively left and right photogra head is obtained to 12 pairs of images and carry out the monocular demarcation.Figure 13 is that monocular-camera is demarcated diagram of circuit.Idiographic flow is as follows:
The number of step 1-3-1, setting image to be calibrated is 12, sets chessboard angle point several 6 * 4;
Step 1-3-2, obtain a pending picture;
Step 1-3-3, carry out image characteristic point and obtain, comprise the extraction angle point, angular-point sub-pixelization and draw angle point;
Step 1-3-3, judge whether to obtain the characteristic point information of 12 width images; If be less than the characteristic point information of 12 width images, repeating step 1-3-2 and step 1-3-3; If obtained the characteristic point information of 12 width images, performed step 1-3-4;
Step 1-3-4, operation calibration algorithm, and preserve the calibration result mistake;
Step 1-4,12 pairs of left and right image is carried out respectively to the monocular demarcation, after obtaining calibration result; Can ask for accordingly the outer parameter of two pick up cameras, namely the position relationship of two cameras; Principle is suc as formula (4):
Wherein, R
l(rotating vector), t
l(translation vector) and R
r(rotating vector), t
r(rotating vector) means respectively the relative position of the monocular demarcation right camera coordinate system of rear left and world coordinate system.Rotation amount R and translational movement T mean the relative position relation between two pick up cameras.
Step 2, employing front side binocular camera shooting head gather the image in this automobile head the place ahead, adopt rear side binocular camera shooting head to gather the image at this automobile tail rear;
Step 3, adopt the correct image of polar curve correcting mode to above-mentioned collection, and then obtain a certain measured point and correspond to respectively two polar curves that are corrected pixel place on image, and image is carried out to filtering;
Before Stereo matching, in order to improve matching precision, reduce match time, reduce camera and move up and down the impact on matching algorithm, image rectification is a step very important before Stereo matching.The image rectification principle as shown in figure 14.
In Figure 14, P
lAnd P
rFor the imaging point of spatial point, O
lAnd O
rFor the left and right cameras coordinate origin.Point P, O
lAnd O
rForm triangular facet, and form intersection l with the left and right image
l, l
r, be polar curve.Wherein, l
lBe called P
rCorresponding polar curve, l
rFor P
lCorresponding polar curve, l
lAnd l
rEach other to polar curve.On triangular facet, get 1 P', this subpoint on the image of left and right is respectively P '
lAnd P
r, and P '
lAnd P
rAll, on polar curve, adopt the method, when coupling, the search coverage of matching point is narrowed down to the one dimension straight line by two bit planes, reduced search time, improved matching precision.
Step 4, adopting absolute value and the coupling of SAD(pixel gray scale difference) method mates two corresponding pixel points on two image polar curves, and then obtains the parallax between above-mentioned two pixels;
The purpose of Stereo matching is to obtain parallax, and asks the process of parallax can be considered as the process of template matches.In a pair of image of catching at the same time, take in left-side images centered by point to be matched and set up a size and be (2m+1) * (2n+1) window.In image right, with onesize window search, finding a corresponding point of the most similar window is exactly optimal match point along corresponding polar curve.
The similarity measure function that the embodiment of the present invention is chosen is the poor absolute value of pixel grey scale and SAD.It is little that it has calculated amount, fireballing advantage.The expression formula of SAD (pixel grey scale poor absolute value and) algorithm is formula (5):
Wherein, in formula, d is parallax, I
l(.) is the grey scale pixel value to be matched in left figure, I
r(.) is the grey scale pixel value of the matching point in right figure.The pixel number of i for moving along image transverse axis x, the pixel number of j for moving along image longitudinal axis y.Take in left-side images centered by point to be matched and set up a size and be (2m+1) * (2n+1) window, is (2m+1) total number of the capable pixel of this window, (2n+1) total number of this window column pixel.
Step 5, repeating step 3 are to step 4 until obtain the parallax of all pixels on image;
Step 6, according to the parallax of four parameters that obtain in step 1 and pixel, obtain between this automobile and front automobile distance and and the rear automobile between distance;
Calculate and front automobile between as follows apart from the Z formula:
Wherein, f is the focal length of front side binocular camera shooting head; D is relative distance between the binocular camera shooting head of front side; x
lFor the abscissa value of pixel in image in the binocular camera shooting head of front side, l means left side left; x
rFor the abscissa value of pixel in another image in the binocular camera shooting head of front side, r means right side right;
Calculate and the rear automobile between as follows apart from Z ' formula:
Wherein, f ' is the focal length of rear side binocular camera shooting head; D ' is relative distance between rear side binocular camera shooting head; X '
lFor the abscissa value of pixel in image in rear side binocular camera shooting head, l means left side left; X '
rFor the abscissa value of pixel in another image in rear side binocular camera shooting head, r means right side right;
Step 7, get and front automobile between in distance value minimum distance as the distance value of final and front automobile; Get and the rear automobile between in distance value minimum distance as the distance value of final and rear automobile;
Step 8, the required safety distance value of setting according to the user, the distance value of judgement and front automobile whether in the safety distance scope, if, return to execution step 2, otherwise DSP sends a signal to buzzer phone, realize reporting to the police; Whether judgement and the distance value of rear automobile be in the safety distance scope, if return to execution step 2, otherwise DSP sends a signal to LED display after car, realizes the prompting to the rear car personnel.
The factor that affects vehicle stopping distance has a lot, as the speed of a motor vehicle, road conditions, weather, load-carrying and driver's speed of response etc.Generally, safety distance can be selected to be consistent with speed of a motor vehicle milimeter number.For example, 40 kilometers speed of a motor vehicle keep 40 meters, and 60 kilometers speed of a motor vehicle keep 60 meters, if the speed of a motor vehicle higher than 100 kilometers, safety distance will remain on 150 to 200 meters.Thereby safety distance also is not quite similar under different conditions, need to carry out constantly to set the safety distance occurrence according to current various influence factors.
By keyboard to set up safety distance numerical value, in the embodiment of the present invention, safety distance is 40 meters, utilizes keyboard input 40, and information is passed to central process unit DSP; DSP storage safe range information, and this value is sent to LED display demonstration occurrence in car; As DSP memory allocated space storage security distance, be the value of 40 meters correspondences, this value compares for the distance value (comprising the distance value of Ben Che and front truck and the distance value of Ben Che and rear car) with actual measurement, to be confirmed whether to be less than safety distance.In order to confirm the whether input error of safety distance setting value, this value is delivered to LED display in car and show.
Central process unit DSP calculates the minor increment of front truck and this car according to the binocular stereo vision range measurement principle, and the memory allocated space, preserves this distance values.Whether the front truck that judgement calculates and the distance value of this car are less than the safety distance value by keyboard to set up, if the distance value calculated is less than the safety distance value, DSP sends actuating signal to buzzer phone in car, buzzer phone sounding in car, with caution Ben Che driver, slow down and go slowly, maintain safe distance.
Central process unit DSP calculates the minor increment of rear car and this car according to the binocular stereo vision range measurement principle, and the memory allocated space, preserves this distance values.Whether the rear car that judgement calculates and the distance value of this car are less than the safety distance value by keyboard to set up.If the distance value calculated is less than the safety distance value, DSP sends actuating signal to the afterbody LED display, and the afterbody LED display shows information warning: slow down and go slowly, maintain safe distance.With driver's deceleration after warning this, go slowly, maintain safe distance.