Embodiment
Referring to accompanying drawing, traffic lights based on shape and color characteristic involved in the present invention are detected with recognition methods and are elaborated, present embodiment for red light, amber light and green light according to tactic traffic lights from top to bottom.
Fig. 1 is the process flow diagram of traffic lights show state of the present invention recognition methods.
As shown in Figure 1:
Step 1, collection image S1:
Use variscope spare to gather the coloured image at traffic lights crossing of living in.
Step 2, carry out pre-service S2 to collecting coloured image:
After a two field picture in reading in the successive frame sequence image, image is intercepted processing, get the first half of image; Coloured image is converted to gray level image; Getting the circular radius windows radius and be 5 carries out medium filtering and eliminates noise; Carry out top cap conversion and remove large tracts of land uniform gray level zone in image; Automatically get threshold value to Image Segmentation Using by grey level histogram; Get structural element radius 8, the zone that extracts is corroded and expansion process, the aperture in the Closed Graph picture.
Step 3, extraction class rectangular area S3:
Extract the class rectangle connected region of rectangular degree r between 0.8 ~ 1.0, wherein rectangular degree r=A/A
r, A is the area of connected region, A
rThe area of the minimum boundary rectangle of connected region, select area between 500 ~ 5000 pixels, length breadth ratio is between 2.8 ~ 3.4 and vertical class rectangular area, long limit.
The number S4 of class rectangular area is extracted in step 4, judgement.
Step 5, extract circular luminous zone S5 in the class rectangular area:
When extracting at least one class rectangular area (being that class rectangle number is not 0), the imperial palace of asking for the class rectangular area of extracting in step 3 connects rectangle, as the first rectangle frame (being candidate's traffic lights rectangle frame), record top left corner apex coordinate and the lower right corner apex coordinate of each the first rectangle frame; Seek the class circle regional in the first rectangle frame, extraction circularity c is the class circle zone between 100 ~ 800 pixels in the connected region between 0.6 ~ 1.0 and area, wherein circularity c=F/F
R, F is the area in class circle zone, F
RBe the area of the regional minimum circumscribed circle of class circle, the minimum circumscribed circle that the class circle is regional is as light-emitting zone.
Step 6, determine target traffic lights S6:
Selection contains and only contains round first a regional rectangle frame of above-mentioned class as the second rectangle frame, tries to achieve the regional minimum circumscribed circle of class circle as the traffic lights light-emitting zone, records area A c and the centre coordinate (X of minimum circumscribed circle
C, Y
C), select the second rectangle frame of contained light-emitting zone area A c maximum as the rectangle frame (being the candidate rectangle frame) of target traffic lights.
Step 7, signal S7 photochromic according to light-emitting zone location recognition traffic lights:
Candidate's traffic lights are divided into rectangular area, three of upper, middle and lower, represent respectively three kinds of red, yellow, and green color signal lamp residing zone, Fig. 2 is the schematic diagram of three rectangle frames in traffic lights rectangle frame of the present invention upper, middle and lower, as shown in Figure 2: according to candidate's traffic lights rectangle frame top left corner apex a coordinate (row
1, column
1) and summit, lower right corner b coordinate (row
2, column
2) can try to achieve respectively top left corner apex coordinate and lower right corner apex coordinate, the wherein Height=row of three rectangular areas
2-row
1, Width=column
2-colume
1The c point coordinate is (row1+Height/3, colomn2), the d point coordinate is (row1+2*Height/3, column1), the e point coordinate is (row1+Height/3, colomn1), the f point coordinate is (row1+2*Height/3, column2), the regional extent of top rectangle frame is definite by upper left corner coordinate a and lower right corner coordinate c, and the regional extent of middle part rectangle frame is determined by upper left corner coordinate e and lower right corner coordinate f, the regional extent of bottom rectangle frame is determined by upper left corner coordinate d and lower right corner coordinate b, according to luminous border circular areas centre coordinate (X
C, Y
C) and three rectangular area top left corner apex coordinates and lower right corner apex coordinate can judge which rectangular area the luminous border circular areas of candidate's traffic lights is positioned at, judge that namely which kind of color traffic lights are.
Step 8, when the judged result of S4 is when not extracting the class rectangular area in image, extract light-emitting zone S8 in pretreated image:
Through selecting in pretreated image circularity between 0.6 ~ the 1.0 and class circle zone of region area between 100 ~ 800 pixels, try to achieve minimum circumscribed circle as the first border circular areas, records center coordinate and circumscribed circle area, select area maximum in all first border circular areas as candidate's light-emitting zone.
Step 9, according to the photochromic signal S9 of candidate's light-emitting zone color characteristic identification traffic lights:
The candidate's light-emitting zone that extracts is carried out color notation conversion space, obtain red color component value R, green component values G, the blue component value B of each pixel of candidate's light-emitting zone, carry out RGB and obtain the chromatic component value H of each pixel of candidate's light-emitting zone to the HIS color notation conversion space, if
H
1And
T
1, judge that candidate's light-emitting zone is green light, if
<h
2And
T
2, judge that candidate's light-emitting zone is red light, if h
2<
<h
1And
<t
2, judge that candidate's light-emitting zone is amber light, wherein
,
,
And
Respectively the mean value of chromatic component value H, red color component value R, green component values G and the blue component value B of all pixels in the circular luminous zone, h
1And h
2, t
1And t
2The threshold value of determining according to the actual conditions of described camera and described traffic lights, h
1=80, h
2=30, t
1=200, t
2=80; After the judgement signal lamp color.
Step 10, corresponding show state count value add 1 S10.
Step 11, judge whether count value reaches threshold value S11, when count value corresponding to show state do not reach threshold value (present embodiment gets 8), return to S1.
Step 12, when count value corresponding to show state reaches threshold value, the prompting of output respective quadrature ventilating signal lamp show state, corresponding counter O reset, circulation finishes, and enters next circulation.
Being more than a specific embodiment of the present invention, is not to limit usage range of the present invention, and all equivalences of doing according to the content of the present patent application the scope of the claims change and modify, and all should be technology category of the present invention.