Embodiment:
As shown in Figure 5, the present invention comprises the following steps for vision-based detection and the control method of Notebook Battery automatic Composition:
Respectively directly over production line station A and battery draw-in groove K
3and K
4cCD camera C is installed directly over centre
1with CCD camera C
2, on the torsion platform B of parallel and production line, six battery draw-in groove K are set
1, K
2, K
3, K
4, K
5, K
6, the centre bottom of six battery draw-in grooves is offered rectangle hole, places respectively the white visible light source irradiating, battery draw-in groove K below each battery draw-in groove upward
1and K
2connect as one battery draw-in groove K
3and K
4connect as one battery draw-in groove K
5and K
6connect as one, at draw-in groove K
3the lower left corner arranges a turning axle Z perpendicular to reversing platform B
1, at K
4the upper right corner arranges a turning axle Z perpendicular to reversing platform B
2, K
2and K
3through turning axle Z
1be connected, make K
1, K
2can be around Z
1be rotated counterclockwise 180 degree, K
4and K
5through turning axle Z
2be connected, K
5, K
6can be around Z
2be rotated counterclockwise 180 degree.Concrete layout as shown in Figure 1-Figure 3.
CCD camera C
1be responsible for the collection of Notebook Battery image on production line, CCD camera C
2be responsible for reversing the collection of upper 6 draw-in grooves of platform B and center white visible images thereof, mechanical arm J
1with mechanical arm J
2end is respectively with cuboid groove shape magnetic chuck X
1and X
2, mechanical arm J
1be responsible for a batteries after production line captures and be put in the draw-in groove reversing on platform mechanical arm J
2after being responsible for six batteries on torsion retrotorsion platform B to capture together, be placed in the battery case of notebook, battery case is placed on and reverses the other tooling platform V of platform B above, and later step is as follows:
Step 1: utilize CCD camera C
1take pictures and extract centre coordinate and the directional information of the Notebook Battery at station A place on production line, and control mechanical arm J
1capture battery
(1) adopt a kind of improved Roberts edge algorithms to detect the edge of notebook cell image
First, with CCD camera C
1taking the image of production line station A place Notebook Battery, is initial point O at the lower-left point of image
1set up rectangular coordinate system iO
1j, adopts 3 * 3 whole image of detection window traversal, in 8 connected pixel neighborhoods, and difference calculated level direction, vertical direction, the Grad in 135 degree directions and 45 degree directions, wherein, the Grad in horizontal direction is: P
0[i, j]=| I
1[i-1, j]-I
1[i+1, j] |, the Grad in vertical direction is: P
90[i, j]=| I
1[i, j-1]-I
1[i, j+1] |, the Grad in 135 degree directions is: P
135[i, j]=| 2 * (I
1[i-1, j-1]-I
1[i+1, j+1]) |, the Grad in 45 degree directions is: P
45[i, j]=| 2 * (I
1[i+1, j-1]-I
1[i-1, j+1]), I in formula
1the gray-scale value of capable, the j row pixel of i in the original image that [i, j] representative gathers, i=0,1,2 ..., 398, or 399, j=0,1,2 ..., 298, or 299,
Secondly, calculate total Grad M[i in 8 connected pixel neighborhoods, j], M[i, j]=P
0[i, j]+P
90[i, j]+P
135[i, j]+P
45[i, j], and itself and the threshold tau of setting are compared, obtain the gray-scale value C[i of binaryzation back edge image, j],
Wherein, the selected threshold that τ is marginal point, and τ=6,
(2) pass through the polar angle θ of the column axis of the above-mentioned station A of Hough transformation calculations place Notebook Battery
As shown in Figure 4, Figure 5, first, will be with O
1for the rectangular coordinate system of initial point changes into O
1for the polar coordinate system of initial point, establishing ρ is utmost point footpath, and α is polar angle, and ρ and α are natural number, and ρ equals 0,1 ..., 498, or 499, α equals 0,1 ..., 178, or 179, a discrete parameter space between its maximal value and minimum value, set up respectively;
Secondly, set up the totalizer N[ρ of a two-dimensional array] [α], in juxtaposition array, each element is 0;
Then, each marginal point in edge image C [i, j], the pixel that edge image gray-scale value is 1, does Hough conversion, calculates this corresponding curve in polar coordinate system, and adds 1 on corresponding totalizer, i.e. N[ρ] [α]=N[ρ] [α]+1,
Finally, find out the local maximum of the totalizer of collinear point on correspondence (x, y) coordinate system, this value provides the parameter (ρ of collinear point straight line on (x, y) coordinate plane
0, α
0), α
0be the polar angle of the straight line that collinear point are maximum, because the length of two crest line HR of battery and GP is the longest, therefore, the line segment that collinear point are maximum must be in HR or GP, again because HR is parallel with GP, again with battery post body axis L
1l
2parallel, therefore, battery post body axis L
1l
2polar angle θ=α
0,
(3) coordinate conversion
By original coordinate system iO
1any point coordinate in j [i, j] is transformed into i ' O in new coordinate system
1j ', and calculate its new coordinate figure [i ', j '], specific formula for calculation is as follows:
First, when
time, by original coordinate system iO
1j is around an O
1be rotated counterclockwise
angle is set up new for O
1rectangular coordinate system i ' O for initial point
1j ',
,
Wherein, i ', j ' is respectively coordinate system i ' O
1the horizontal stroke of j ' mid point, ordinate value, and i ', j ' is natural number, i '=-399 ,-398 ... 0,1,2 ..., 398, or 399, j '=-299 ,-298 ..., 0,1,2 ..., 298, or 299, and the horizontal ordinate i of point equals at 0 o'clock,
when the horizontal ordinate i of point is not equal to 0,
When
time, by original coordinate system iO
1j is around an O
1be rotated counterclockwise
angle is set up new for O
1rectangular coordinate system i ' O for initial point
1j ',
,
(4) calculate above-mentioned station A place Notebook Battery center point coordinate
First, at original coordinate system iO
1in j, the image gathering is carried out to Threshold segmentation binary conversion treatment, obtain the gray-scale value B of binary image
1[i, j],
i
1[i, j] is the gray-scale value of the original image of collection, and T is the binarization segmentation threshold value of barrier and background, T=210, I
1the gray-scale value of capable, the j row pixel of i in the original image that [i, j] representative gathers, i=0,1,2 ..., 398, or 399, j=0,1,2 ..., 298, or 299, and the point that binaryzation in coordinate system is not processed is all set to 0,
Then, by the gray-scale value B of image after binaryzation
1[i, j], at coordinate system i ' O
1in j ', respectively to projection on i ' axle and j ' axle, determine the coordinate J of battery central point on i ' axle and j ' axle
x' and J
y', concrete steps are as follows:
1) by the gray-scale value B of image after binaryzation
1[i, j], to projection on i ' axle, calculates the gray-scale value sum that each parallel with j ' axle lists all pixels, and result of calculation is stored in respectively to array F
1in [f], when
time,
Wherein
M
1=300 * cos θ, n
1=300 * cos θ, and r
1, m
1, n
1adopt respectively rounding-off method to round numerical value, f is from-m
1value is to n successively
1; When
Time,
Wherein
M
1=400 * cos (π-θ),
and r
1, m
1, n
1adopt respectively rounding-off method to round numerical value, f from 0 successively value to r
1;
2) by the gray-scale value B of image after binaryzation
1[i, j], to projection on j ' axle, calculates the gray-scale value sum of all pixels in every a line parallel with i ' axle, and result of calculation is stored in respectively to array H
1in [h], when
time,
Wherein
N
2=300 * cos θ, and r
2, m, n adopt respectively rounding-off method to round numerical value, h from 0 successively value to r
2; When
Time,
Wherein
M
2=400 * cos (π-θ),
and r
2, m
2, n
2adopt respectively rounding-off method to round numerical value, h is from-m
2value is to n successively
2,
3) at coordinate system i ' O
1in j ', adopt two ends detection method, determine the abscissa value on the left and right border of Notebook Battery on i ' direction of principal axis, and by result store at variable J
l', J
r' in, the ordinate value on the upper and lower border of determining is stored in to variable K ' on j ' direction of principal axis simultaneously
uand K '
din, concrete steps are as follows:
A) f is according to f=-400, and-399 ..., 0,1,2,399,400 values successively, when f meets following condition: F
1[f+2]-F
1[f]>=15 & & F
1[f+2]>=25 & & F
1[f]≤5, show to have detected the left margin of Notebook Battery, use variable J
l' note down current horizontal ordinate f, and make J
l'=f, continues to f assignment, when f meets following condition: F
1[f]-F
1[f+2]>=15 & & F
1[f]>=25 & & F
1[f+2]≤5, show to have detected the right margin of Notebook Battery, use variable J
r' note down current horizontal ordinate f, and make J
r'=f,
B) h is according to h=-300, and-299 ... 0,1,2 ... 299,300 values successively, when h meets following condition: H
1[h+2]-H
1[h]>=15 & & H
1[h+2]>=25 & & H
1[h]≤5, show to have detected the lower boundary of Notebook Battery, with variable K '
dnote down current horizontal ordinate h, and make K '
d=h, continues to h assignment, when h meets following condition: H
1[h]-H
1[h+2]>=15 & & H
1[h]>=25 & & H
1[h+2]≤5, show to have detected the coboundary of Notebook Battery, with variable K '
unote down current horizontal ordinate h, and make K '
u=h,
C) calculate the horizontal ordinate C ' of Notebook Battery central point
i 'with ordinate C '
j ', C '
i '=(J
l'+J
r')/2, C '
j '=(K '
u+ K '
d)/2,
(5) determine the position of Notebook Battery positive pole and negative pole
If F[J
l'] > F[J
r'], Notebook Battery negative pole is at coordinate system i ' O
1the middle abscissa value of j ' is J
l', anodal abscissa value is J
r'; If F[J
l'] < F[J
r'], Notebook Battery positive pole is at coordinate system i ' O
1the middle abscissa value of j ' is J
l', negative pole abscissa value is J
r',
(6) according to Notebook Battery central point at coordinate system i ' O
1horizontal stroke under j ', ordinate value, calculate at iO
1horizontal stroke under j coordinate system, ordinate value, computing formula is as follows:
When
Time,
When
Time,
Wherein, C
i 'and C
j 'be respectively at new rectangular coordinate system i ' O
1horizontal stroke, the ordinate value of definite Notebook Battery central point in j ', as horizontal ordinate C
i 'equal at 0 o'clock,
as horizontal ordinate C
i 'be not equal at 0 o'clock,
(7) control mechanical arm J
1capture Notebook Battery
First, PLC controls mechanical arm J
1to specified coordinate position, i.e. Notebook Battery center C (C
i, C
j), and it is vertical with torsion platform B horizontal center line ST to control the long the longest limit MN of rib of magnetic chuck X1, MN and L
1l
2parallel, when
time, PLC controls mechanical arm and is rotated counterclockwise θ angle and declines 10 centimetres, and then magnetic chuck powers on and captures battery and rise 10 centimetres, now, if F[J
l'] > F[J
r'], control turn clockwise θ angle decline 10 centimetres of mechanical arm, then magnetic chuck power-off is put into Notebook Battery to reverse on platform, if F[J
l'] < F[J
r'], control mechanical arm and be rotated counterclockwise π-θ angle and decline 10 centimetres, then magnetic chuck power-off is put into Notebook Battery to reverse on platform; When
time, control turn clockwise π-θ angle decline 10 centimetres of mechanical arm, then magnetic chuck powers on and captures battery and rise 10 centimetres, now, if F[J
l'] > F[J
r'], control mechanical arm and be rotated counterclockwise π-θ angle and decline 10 centimetres, then magnetic chuck power-off is put into Notebook Battery to reverse on platform, if F[J
l'] < F[J
r'], control turn clockwise θ angle decline 10 centimetres of mechanical arm, then magnetic chuck power-off is put into Notebook Battery to reverse on platform;
Step 2: utilize CCD camera C
2take and reverse six draw-in groove centre bottom rectangle hole images on platform, by image processing algorithm, determine position and the positive and negative electrode direction that Notebook Battery should be placed
(1) image is carried out to binary conversion treatment
With CCD camera C
2take the image that reverses upper six draw-in grooves of platform B, with CCD camera C
2the central point O of the image of taking
2for initial point is set up rectangular coordinate system, the image of taking is carried out to Threshold segmentation binary conversion treatment, obtain the gray-scale value B of binary image
2[i, j],
i
2[i, j] is CCD camera C
2the i that gathers image is capable, the gray-scale value of j row pixel, T
2for the white visible ray that sends from draw-in groove central rectangular aperture hole and the binarization segmentation threshold value of background, T
2=200, i, j is natural number, and i=-199, and-198 ..., 0,1,2 ..., 198, or 199, j=-149 ,-148 ..., 0,1,2 ..., 148, or 149,
(2) image is carried out to noise remove and connective processing
First, the gray-scale value of pixel on image edge is set to 0, then adopts 3 * 3 detection window traversal entire image, the gray-scale value that makes detection window central point is B
2[i, j], the central point around gray-scale value of 8 neighborhood points is respectively B in a clockwise direction from the upper left corner
2[i-1, j+1], B
2[i, j+1], B
2[i+1, j+1], B
2[i+1, j], B
2[i+1, j-1], B
2[i, j-1], B
2[i-1, j-1], B
2[i-1, j],
Allow 3 * 3 detection window travel through successively entire image, the gray-scale value of the pixel under calculation window covers, if B
2[i, j]+B
2[i-1, j+1]+B
2[i, j+1]+B
2[i+1, j+1]+B
2[i+1, j]+B
2[i+1, j-1]+B
2[i, j-1]+B
2[i-1, j-1]+B
2[i-1, j]≤3, make B
2[i, j]=1, otherwise, B made
2[i, j]=0,
Secondly, the image of removing after noise is carried out to horizontal projection
The gray-scale value of removing each pixel listing of image after noise is added, result of calculation is stored in respectively to array F
2in [f],
wherein f is integer, f=-199, and-198 ..., 0,1,2 ..., 198, or 199,
(3) Notebook Battery central point horizontal ordinate in computed image
F is according to f=-199, and-198 ... 0,1,2 ..., 198, or 199 values successively, when f meets following condition: F
2[f+2]-F
2[f]>=15 & & F
2[f+2]>=25 & & F
2[f]≤5, show that the rising edge for the first time that image detected, along coordinate, notes down current horizontal ordinate f with variable G, and make G=f, continue to f assignment, when f meets following condition: F
2[f]-F
2[f+2]>=15 & & F
2[f]>=25 & & F
2[f+2]≤5, show that the trailing edge for the first time that image detected, along coordinate, stops the assignment to f, note down current horizontal ordinate f, and make G '=f, Notebook Battery rectangle draw-in groove K with variable G '
4intermediate rectangular hole is width value d in image
0'=G '-G, unit is pixel, utilizing ruler directly to measure Notebook Battery rectangle draw-in groove intermediate rectangular hole width is d
0, draw-in groove K
1and K
2distance between intermediate rectangular hole center is l
1, draw-in groove K
2and K
3distance between intermediate rectangular hole center is l
2, draw-in groove K
3and K
4distance between intermediate rectangular hole center is l
3, draw-in groove K
4and K
5distance between intermediate rectangular hole center is l
4, draw-in groove K
5and K
6distance between intermediate rectangular hole center is l
5, d
0, l
1, l
2, l
3, l
4and l
5unit be millimeter; Known as calculated, draw-in groove K in image
1and K
2distance between intermediate rectangular hole center
draw-in groove K
2and K
3distance between intermediate rectangular hole center
draw-in groove K
3and K
4distance between intermediate rectangular hole center
draw-in groove K
4and K
5distance between intermediate rectangular hole center
draw-in groove K
5and K
6distance between intermediate rectangular hole center
l
1', l
2', l
3', l
4', l
5' unit be pixel, and round off method is to l
1', l
2', l
3', l
4', l
5' round, establish draw-in groove K in image
1, K
2, K
3, K
4, K
5, K
6the horizontal ordinate of intermediate rectangular hole central point is from left to right respectively x
1, x
2, x
3, x
4, x
5, x
6, unit is pixel,
(4) by template matching method, determine the position that Notebook Battery should be laid
At mechanical arm J
1before laying battery, reverse the CCD camera of platform top and all can image be processed reversing platform photographic images, result of calculation is still stored in respectively to array F
2in [f],
wherein f is integer, f=-199, and-198 ... 0,1,2 ..., 198, or 199 values successively, when f meets following condition: F
2[f+2]-F
2[f]>=15 & & F
2[f+2]>=25 & & F
2[f]≤5, show that first rising edge that image detected, along coordinate, stops the assignment to f, note down current horizontal ordinate f, and make E=f with variable E, when f gets all over being discontented with foot after all values, state condition: F
2[f+2]-F
2[f]>=15 & & F
2[f+2]>=25 & & F
2[f]≤5 o'clock, store in
variable E 0, i.e. E=0, by E respectively with x
1, x
2, x
3, x
4, x
5, x
6compare, if
wherein ε is error threshold, and ε=3, shows draw-in groove K
1placing battery not, now PLC controls mechanical arm J
1the battery of absorption is put into draw-in groove K
1; If
show draw-in groove K
2placing battery not, now PLC controls mechanical arm J
1the battery of absorption is put into draw-in groove K
2; If
show draw-in groove K
3placing battery not, now PLC controls mechanical arm J
1by the first Rotate 180 degree of the battery of drawing, then put into draw-in groove K
3; If
show draw-in groove K
4placing battery not, now PLC controls mechanical arm J
1by the first Rotate 180 degree of the battery of drawing, then put into draw-in groove K
4; If
show draw-in groove K
5placing battery not, now PLC controls mechanical arm the battery of absorption is put into draw-in groove K
5; If
show draw-in groove K
6placing battery not, now PLC controls mechanical arm J
1the battery of absorption is put into draw-in groove K
6; If E=0, shows that 6 draw-in grooves have all put battery, execution step three;
Step 3: by twist mechanism, Notebook Battery both positive and negative polarity is docked to arrangement successively
When 6 draw-in grooves are all after placing battery, PLC controls the twist mechanism reversing on platform, makes K
1, K
2around Z
1axle is rotated counterclockwise 180 degree, makes K simultaneously
5, K
6around Z
2axle is rotated counterclockwise 180 degree, now, and mechanical arm J
2after six joint Notebook Batterys after reversing are captured simultaneously, be placed in the note book battery box on tooling platform V and assemble.