A kind of vision-based detection for the automatic mounted box of Notebook Battery and control method
Technical field
What the present invention relates to is a kind of automatic production line, and particularly a kind of automation of scattered synthetic rapid-assembling is rawProduce line, belong to Electromechanical Control field.
Background technology
Along with the development of world's industry and commerce process, the same society's life falling behind of material and cultural needs that the mankind are growingContradiction between product increases day by day, the scientific and technological progress of entering to determine society. The gusher formula of the notebook of various brands goes outExisting, the competition of aggravation Liao Ge businessman. Improve the quality of products, speed production efficiency and will determine that businessman obtains initiatively in competition.
Find through retrieval, the assembling of current domestic Notebook Battery is handwork substantially, and the master that handwork existsWant problem to have: production efficiency is low and quality is unstable, in addition owing to a large amount of repeating, dull operation can make people feel uninteresting,, very easily there is loading error in fatigue. Not only can affect the quality of battery if made a mistake, also can produce after after sale unnecessaryReally. And the expensive of nowadays manpower work is also the unmodifiable fact.
Summary of the invention
The object of the invention is to overcome the domestic deficiency taking handwork as main Notebook Battery assemble method, provide oneKind utilize vision-based detection principle, method simple, detect accurate high, controlling unit automaticity high for Notebook Battery fromVision-based detection and the control method of moving mounted box.
Concrete technical scheme of the present invention is as follows:
For vision-based detection and the control method of Notebook Battery automatic Composition, the method concrete steps are as follows:
Respectively directly over production line station A and battery draw-in groove K3And K4CCD camera C is installed directly over centre1And CCDCamera C2, on the torsion platform B of parallel and production line, six battery draw-in groove K are set1,K2,K3,K4,K5,K6, and manipulator J1With manipulator J2, the centre bottom of six battery draw-in grooves is offered rectangle hole, below each battery draw-in groove, places upward respectivelyThe white visible light source irradiating, battery draw-in groove K1And K2Connect as one battery draw-in groove K3And K4Connect as one battery draw-in groove K5And K6Connect as one, at draw-in groove K3The lower left corner arranges a rotating shaft Z perpendicular to reversing platform B1, at K4The upper right corner is perpendicular to torsionPlatform B arranges a rotating shaft Z2,K2And K3Through rotating shaft Z1Be connected, make K1,K2Can be around Z1Be rotated counterclockwise 180 degree, K4And K5Through revolvingRotating shaft Z2Be connected, K5,K6Can be around Z2Be rotated counterclockwise 180 degree, concrete steps are as follows:
Step 1: utilize CCD camera C1Take pictures extract the Notebook Battery at station A place on production line centre coordinate andDirectional information, and control manipulator J1Capture battery
(1) adopt a kind of improved Roberts edge algorithms to detect the edge of notebook cell image;
(2) the polar angle θ of the column axis by the above-mentioned station A of Hough transformation calculations place Notebook Battery;
(3) Coordinate Conversion
By original coordinate system iO1Any point coordinate [i, j] in j is transformed into i ' O in new coordinate system1J ', and calculate that it is newCoordinate figure [i ', j '], specific formula for calculation is as follows:
First, whenTime, by original coordinate system iO1J is around an O1Be rotated counterclockwiseAngle set up new withO1For the rectangular coordinate system i ' O of initial point1j′,
,
Wherein, i ', j ' is respectively coordinate system i ' O1The horizontal stroke of j ' mid point, ordinate value, and i ', j ' is natural number, i '=-399 ,-398, L0,1,2, L, 398, or 399, j '=-299 ,-298, L, 0,1,2, L, 298, or 299, and the abscissa i of pointEqual at 0 o'clock,In the time that the abscissa i of point is not equal to 0,
WhenTime, by original coordinate system iO1J is around an O1Be rotated counterclockwiseAngle is set up new for O1ForRectangular coordinate system i ' the O of initial point1j′,
,
(4) calculate above-mentioned station A place Notebook Battery center point coordinate
First, at original coordinate system iO1In j, the image gathering is carried out to Threshold segmentation binary conversion treatment, obtain two-valueChange the gray value B of image1[i,j],I1[i, j] is the gray scale of the original image of collectionValue, T is the binarization segmentation threshold value of barrier and background, T=210, I1In the original image that [i, j] representative gathers i capable, theThe gray value of j row pixel, i=0,1,2, L, 398, or 399, j=0,1,2, L, 298, or 299, and by binaryzation in coordinate systemThe point of not processing is all set to 0,
Then, by the gray value B of image after binaryzation1[i, j], at coordinate system i ' O1In j ' respectively on i ' axle and j ' axleProjection, determines the coordinate J ' of battery central point on i ' axle and j ' axlexAnd J 'y, concrete steps are as follows:
1) by the gray value B of image after binaryzation1[i, j], to projection on i ' axle, calculates each parallel with j ' axle and lists allThe gray value sum of pixel, is stored in respectively array F by result of calculation1In [f], whenTime, Wherein m1=300×cosθ,n1=300 × cos θ, and r1、m1、n1Adopt respectively rounding-off method to getInteger value, f is from-m1Value is to n successively1; When Time, Wherein m1=400×cos(π-θ),And r1、m1、n1Adopt respectively rounding-off method to round numerical value, f is from 0Value is to r successively1;
2) by the gray value B of image after binaryzation1[i, j], to projection on j ' axle, calculates in every a line parallel with i ' axle allThe gray value sum of pixel, is stored in respectively array H by result of calculation1In [h], whenTime, Wherein n2=300 × cos θ, and r2, m, n adopt respectively fourHouse five enters method and rounds numerical value, h from 0 successively value to r2; When Time, Wherein m2=400×cos(π-θ),And r2、m2、n2Adopt respectivelyRounding-off method rounds numerical value, and h is from-m2Value is to n successively2,
3) at coordinate system i ' O1In j ', adopt two ends detection methods, determine left and right on i ' direction of principal axis of Notebook BatteryThe abscissa value on border, and by result store at variable J 'L、J′RIn, simultaneously by the upper and lower border of determining on j ' direction of principal axisOrdinate value is stored in variable K 'UAnd K 'DIn, concrete steps are as follows:
A) f is according to f=-400 ,-399, L, and 0,1,2,399,400 values successively, in the time that f meets following condition: F1[f+2]-F1[f]≥15&&F1[f+2]≥25&&F1[f]≤5, show to have detected the left margin of Notebook Battery, use variableJ′LNote down current abscissa f, and make J 'L=f, continues to f assignment, when f meets following condition: F1[f]-F1[f+2]≥15&&F1[f]≥25&&F1[f+2]≤5, show to have detected the right margin of Notebook Battery, with variable J 'RNote down currentAbscissa f, and make J 'R=f,
B) h is according to h=-300 ,-299, L0, and 1,2, L299,300 values successively, when h meets following condition: H1[h+2]-H1[h]≥15&&H1[h+2]≥25&&H1[h]≤5, show to have detected the lower boundary of Notebook Battery, use variableK′DNote down current abscissa h, and make K 'D=h, continues to h assignment, when h meets following condition: H1[h]-H1[h+2]≥15&&H1[h]≥25&&H1[h+2]≤5, show to have detected the coboundary of Notebook Battery, with variable K 'UNote down currentAbscissa h, and make K 'U=h,
C) the abscissa C ' of calculating Notebook Battery central pointi′With ordinate C 'j′,C′i′=(J′L+J′R)/2,C′j′=(K′U+K′D)/2,
(5) determine the position of the anodal and negative pole of Notebook Battery
If F[J 'L]>F[J′R], Notebook Battery negative pole is at coordinate system i ' O1The middle abscissa value of j ' is J 'L, anodal horizontal seatScale value is J 'R; If F[J 'L]<F[J′R], Notebook Battery positive pole is at coordinate system i ' O1The middle abscissa value of j ' is J 'L, negative pole horizontal strokeCoordinate figure is J 'R,
(6) according to Notebook Battery central point at coordinate system i ' O1Horizontal stroke under j ', ordinate value, calculate at iO1J coordinate systemUnder horizontal stroke, ordinate value, computing formula is as follows:
When Time,
When Time,
Wherein, Ci′And Cj′Be respectively at new rectangular coordinate system i ' O1The horizontal stroke of definite Notebook Battery central point, vertical in j 'Coordinate figure, as abscissa Ci′Equal at 0 o'clock,As abscissa Ci′Be not equal at 0 o'clock,
(7) control manipulator J1Capture Notebook Battery
First, PLC controls manipulator J1To specified coordinate position, i.e. Notebook Battery center C (Ci,Cj), and controlMagnetic chuck X1The long the longest limit MN of rib vertical with torsion platform B horizontal center line ST, MN and L1L2Parallel, whenTime, PLC controls manipulator and is rotated counterclockwise θ angle and declines 10 centimetres, then the magnetic chuck crawl battery that powers onAnd rise 10 centimetres, and now, if F[J 'L]>F[J′R], control turn clockwise θ angle decline 10 centimetres of manipulator, thenMagnetic chuck power-off is put into Notebook Battery to reverse on platform, if F[J 'L]<F[J′R], control manipulator and be rotated counterclockwise π-θAngle also declines 10 centimetres, and then magnetic chuck power-off is put into Notebook Battery to reverse on platform; WhenTime, controllerTurn clockwise π-θ angle decline 10 centimetres of tool hand, then magnetic chuck powers on and captures battery and rise 10 centimetres, now,If F[J 'L]>F[J′R], control manipulator and be rotated counterclockwise π-θ angle and decline 10 centimetres, then magnetic chuck power-off is by penRemember that this battery is put on torsion platform, if F[J 'L]<F[J′R], control turn clockwise θ angle decline 10 centimetres of manipulator,Then magnetic chuck power-off is put into Notebook Battery to reverse on platform;
Step 2: utilize CCD camera C2Take and reverse six draw-in groove centre bottom rectangle hole images on platform, by figureDetermine as Processing Algorithm 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 C2Take the image that reverses upper six draw-in grooves of platform B, with CCD camera C2The center of the image of takingPoint O2For initial point is set up rectangular coordinate system, the image of taking is carried out to Threshold segmentation binary conversion treatment, obtain binary imageGray value B2[i,j],I2[i, j] is CCD camera C2The i that gathers image is capable,The gray value of j row pixel, T2For the white visible ray that sends from draw-in groove central rectangular aperture hole and the binarization segmentation threshold of backgroundValue, T2=200, i, j is natural number, and i=-199 ,-198, L, 0,1,2, L, 198, or 199, j=-149 ,-148, L, 0,1,2, L, 148, or 149,
(2) image is carried out to noise remove and connective processing
First, the gray value of pixel on image edge is set to 0, then adopts 3 × 3 detection window traversal view pictureImage, the gray value that makes detection window central point is B2[i, j], central point around the gray value of 8 neighborhood points from the upper left corner withBe respectively clockwise B2[i-1,j+1]、B2[i,j+1]、B2[i+1,j+1]、B2[i+1,j]、B2[i+1,j-1]、B2[i,j-1]、B2[i-1,j-1]、B2[i-1,j],
Allow 3 × 3 detection window travel through successively entire image, the gray value of the pixel under calculation window covers, if B2[i,j]+B2[i-1,j+1]+B2[i,j+1]+B2[i+1,j+1]+B2[i+1,j]+B2[i+1,j-1]+B2[i,j-1]+B2[i-1,j-1]+B2[i-1, j]≤3, make B2[i, j]=1, otherwise, B made2[i,j]=0,
Secondly, the image of removing after noise is carried out to floor projection
The gray value of removing each pixel listing of image after noise is added, result of calculation is stored in respectivelyArray F2In [f],Wherein f is integer, f=-199, and-198, L, 0,1,2, L, 198, or 199,
(3) Notebook Battery central point abscissa in computed image;
(4) determine by template matching method the position that Notebook Battery should be laid
At manipulator J1Before laying battery, the CCD camera that reverses platform top all can be to reversing platform photographic images, to figurePicture is processed, and result of calculation is still stored in respectively to array F2In [f],Wherein f is integer,F=-199 ,-198, L0,1,2, L, 198, or 199 values successively, when f meets following condition: F2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5, show that first rising edge that image detected, along coordinate, stops the assignment to f, with becomingAmount E notes down current abscissa f, and makes E=f, states condition: F when f gets all over being discontented with foot after all values2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5 o'clock, store in variable E 0, i.e. E=0, by E respectively with x1、x2、x3、x4、x5、x6Compare, ifWherein ε is error threshold, and ε=3, shows draw-in groove K1Not placing battery, nowPLC controls manipulator J1The battery of absorption is put into draw-in groove K1; IfShow draw-in groove K2Not placing battery,Now PLC controls manipulator J1The battery of absorption is put into draw-in groove K2; IfShow draw-in groove K3Do not placeBattery, now PLC controls manipulator J1By first the battery of drawing Rotate 180 degree, then put into draw-in groove K3; IfShow draw-in groove K4Not placing battery, now PLC controls manipulator J1The battery of absorption is first rotated180 degree, then put into draw-in groove K4; IfShow draw-in groove K5Not placing battery, now PLC controls manipulatorThe battery of absorption is put into draw-in groove K5; IfShow draw-in groove K6Not placing battery, now PLC controllerTool hand J1The battery of absorption is put into draw-in groove K6; If E=0, shows that six 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 six draw-in grooves are all after placing battery, PLC controls the twist mechanism reversing on platform, makes K1、K2Around Z1Axle is counterclockwiseRotate 180 degree makes K simultaneously5、K6Around Z2Axle is rotated counterclockwise 180 degree, now, and manipulator J2By six joint notebook electricity after reversingPond is placed in the note book battery box on tooling platform V and assembles after capturing simultaneously.
Further design of the present invention is:
CCD camera C1Be responsible for the collection of Notebook Battery image on production line, CCD camera C2Be responsible for reversing platform B upper sixThe collection of individual draw-in groove and center white visible images thereof, manipulator J1With manipulator J2End is respectively with cuboid grooveShape magnetic chuck X1And X2, manipulator J1Be responsible for a batteries capture rear and be put in the draw-in groove reversing on platform from production line,Manipulator J2After being responsible for six batteries on torsion retrotorsion platform B to capture together, be placed in the battery case of notebook batteryBox is placed on and reverses on the other tooling platform V of platform B.
Described in (1) of step 1, adopt the edge of improved Roberts edge algorithms detection notebook cell image, toolBody step is as follows:
First, with CCD camera C1The image of taking production line station A place Notebook Battery, at the lower-left point of image isInitial point O1Set up rectangular coordinate system iO1J, adopts 3 × 3 whole image of detection window traversal, in 8 connected pixel neighborhoods, respectivelyCalculated level direction, vertical direction, the Grad in 135 degree directions and 45 degree directions, wherein, the Grad in horizontal directionFor: P0[i,j]=|I1[i-1,j]-I1[i+1, j] |, the Grad in vertical direction is: P90[i,j]=|I1[i,j-1]-I1[i, j+1] |, the Grad in 135 degree directions is: P135[i,j]=|2×(I1[i-1,j-1]-I1[i+1, j+1]) |, 45 degree sidesGrad is upwards: P45[i,j]=|2×(I1[i+1,j-1]-I1[i-1, j+1]) |, I in formula1It is former that [i, j] representative gathersThe gray value of capable, the j row pixel of i in beginning image, i=0,1,2, L, 398, or 399, j=0,1,2, L, 298, or 299,
Secondly, calculate total Grad M[i in 8 connected pixel neighborhoods, j], M[i, j]=P0[i,j]+P90[i,j]+P135[i,j]+P45[i, j], and itself and the threshold tau of setting are compared, obtain the gray value C[i of binaryzation back edge image, j], Wherein, the selected threshold that τ is marginal point, and τ=6.
Described in (2) of step 1, pass through the utmost point of the column axis of the above-mentioned station A of Hough transformation calculations place Notebook BatteryAngle θ, concrete steps are as follows:
First, will be with O1For the rectangular coordinate system of initial point changes into O1For the polar coordinate system of initial point, establishing ρ is utmost point footpath, and α isPolar angle, ρ and α are natural number, and ρ equals 0,1 ..., 498, or 499, α equals 0,1 ..., 178, or 179, respectively in its maximumBetween value and minimum of a value, set up a discrete parameter space;
Secondly, set up the accumulator 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 value is 1, doesHough conversion, calculates this corresponding curve in polar coordinate system, and adds 1, i.e. N[ρ on corresponding accumulator] [α]=N[ρ][α]+1,
Finally, find out the local maximum of the accumulator of collinear points on correspondence (x, y) coordinate system, this value provide (x,Y) parameter (ρ of collinear points straight line on coordinate plane0,α0),α0Be the polar angle of the straight line that collinear points are maximum, because two, batteryThe length of crest line HR and GP is the longest, and therefore, the line segment that collinear points are maximum must be in HR or GP, again because HR and GP are flatOK, again with battery post body axis L1L2Parallel, therefore, battery post body axis L1L2Polar angle θ=α0。
Notebook Battery central point abscissa in computed image described in (3) of step 2, concrete steps are as follows:
F is according to f=-199 ,-198, L0, and 1,2, L, 198, or 199 values successively, when f meets following condition: F2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5, show that the rising edge for the first time that image detected is along coordinate,Note down current abscissa f with variable G, and make G=f, continue to f assignment, when f meets following condition: F2[f]-F2[f+2]≥15&&F2[f]≥25&&F2[f+2]≤5, show that the trailing edge for the first time that image detected, along coordinate, stops composing to fValue, notes down current abscissa f with variable G ', and makes G '=f, Notebook Battery rectangle draw-in groove K4Intermediate rectangular hole is at figureWidth value d ' in picture0=G '-G, unit is pixel, utilizes ruler directly to measure Notebook Battery rectangle draw-in groove intermediate rectangular holeWidth is d0, draw-in groove K1And K2Distance between intermediate rectangular hole center is l1, draw-in groove K2And K3Intermediate rectangular hole center itBetween distance be l2, draw-in groove K3And K4Distance between intermediate rectangular hole center is l3, draw-in groove K4And K5In intermediate rectangular holeDistance between the heart is l4, draw-in groove K5And K6Distance between intermediate rectangular hole center is l5,d0、l1、l2、l3、l4And l5ListPosition is millimeter; Known as calculated, draw-in groove K in image1And K2Distance between intermediate rectangular hole centerDraw-in grooveK2And K3Distance between intermediate rectangular hole centerDraw-in groove K3And K4Distance between intermediate rectangular hole centerDraw-in groove K4And K5Distance between intermediate rectangular hole centerDraw-in groove K5And K6Intermediate rectangular holeDistance between centerl′1、l′2、l′3、l′4、l′5Unit be pixel, and round off method is to l '1、l′2、l′3、l′4、l′5Round, establish draw-in groove K in image1、K2、K3、K4、K5、K6The abscissa of intermediate rectangular hole central point is from left to right respectively x1、x2、x3、x4、x5、x6, unit is pixel,
Compared with prior art, tool of the present invention has the following advantages:
(1) the present invention adopts machine vision technique, propose a kind of vision-based detection for the automatic mounted box of Notebook Battery andControl method, has overcome that production efficiency hand-manipulated is low, quality is unstable, the drawback of loading error, has improved Notebook BatteryThe gentle efficiency of Automated water of installing.
(2) utilize two CCD cameras, be respectively used to calculate the centre coordinate of Notebook Battery on production line and determine penRemember the position that this battery should be placed, and then realized the automatic mounted box of Notebook Battery, improved Notebook Battery automatic mountingThe precision of box and reliability.
Brief description of the drawings
Fig. 1 is workbench schematic diagram;
Fig. 2 reverses platform initial position floor map;
Fig. 3 is the position view after Notebook Battery rotation;
Fig. 4 comprises that Fig. 4 (a) and 4 (b) are the coordinate transform schematic diagrames that solves polar angle;
Fig. 5 is overall workflow figure.
In figure: 1-transfer station; 2-Notebook Battery; 4-CCD camera C1; 5-station A; 6-magnetic chuck X1; 8 batteriesBox; 9-manipulator J2; 10-reverses platform B; 11-magnetic chuck X2; A 12-CCD report picture C2; 13-draw-in groove K1; 14 draw-in groove K2; 15-Draw-in groove K3; 16-draw-in groove K4; 17-draw-in groove K5; 18-draw-in groove K6; 19-rotating shaft Z1; 20-rotating shaft Z2; Hole in the middle of 21-draw-in groove.
Detailed description of the invention:
As shown in Figure 5, the present invention comprises following step for vision-based detection and the control method of Notebook Battery automatic CompositionRapid:
Respectively directly over production line station A and battery draw-in groove K3And K4CCD camera C is installed directly over centre1And CCDCamera C2, on the torsion platform B of parallel and production line, six battery draw-in groove K are set1,K2,K3,K4,K5,K6, six Battery CardsThe centre bottom of groove is offered rectangle hole, places respectively the white visible light source irradiating, electricity below each battery draw-in groove upwardPond draw-in groove K1And K2Connect as one battery draw-in groove K3And K4Connect as one battery draw-in groove K5And K6Connect as one, at draw-in grooveK3The lower left corner arranges a rotating shaft Z perpendicular to reversing platform B1, at K4The upper right corner arranges a rotating shaft Z perpendicular to reversing platform B2,K2WithK3Through rotating shaft Z1Be connected, make K1,K2Can be around Z1Be rotated counterclockwise 180 degree, K4And K5Through rotating shaft Z2Be connected, K5,K6Can be around Z2Be rotated counterclockwise 180 degree. Concrete layout as shown in Figure 1-Figure 3.
CCD camera C1Be responsible for the collection of Notebook Battery image on production line, CCD camera C2Be responsible for reversing platform B upper 6The collection of individual draw-in groove and center white visible images thereof, manipulator J1With manipulator J2End is respectively with cuboid grooveShape magnetic chuck X1And X2, manipulator J1Be responsible for a batteries capture rear and be put in the draw-in groove reversing on platform from production line,Manipulator J2After being responsible for six batteries on torsion retrotorsion platform B to capture together, be placed in the battery case of notebook batteryBox 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 C1Take pictures extract the Notebook Battery at station A place on production line centre coordinate andDirectional information, and control manipulator J1Capture battery
(1) adopt a kind of improved Roberts edge algorithms to detect the edge of notebook cell image
First, with CCD camera C1The image of taking production line station A place Notebook Battery, at the lower-left point of image isInitial point O1Set up rectangular coordinate system iO1J, adopts 3 × 3 whole image of detection window traversal, in 8 connected pixel neighborhoods, respectivelyCalculated level direction, vertical direction, the Grad in 135 degree directions and 45 degree directions, wherein, the Grad in horizontal directionFor: P0[i,j]=|I1[i-1,j]-I1[i+1, j] |, the Grad in vertical direction is: P90[i,j]=|I1[i,j-1]-I1[i, j+1] |, the Grad in 135 degree directions is: P135[i,j]=|2×(I1[i-1,j-1]-I1[i+1, j+1]) |, 45 degree sidesGrad is upwards: P45[i,j]=|2×(I1[i+1,j-1]-I1[i-1, j+1]) |, I in formula1It is former that [i, j] representative gathersThe gray value of capable, the j row pixel of i in beginning image, i=0,1,2, L, 398, or 399, j=0,1,2, L, 298, or 299,
Secondly, calculate total Grad M[i in 8 connected pixel neighborhoods, j], M[i, j]=P0[i,j]+P90[i,j]+P135[i,j]+P45[i, j], and itself and the threshold tau of setting are compared, obtain the gray value C[i of binaryzation back edge image, j], Wherein, the selected threshold that τ is marginal point, and τ=6,
(2) the polar angle θ of the column axis by the above-mentioned station A of Hough transformation calculations place Notebook Battery
As shown in Figure 4, Figure 5, first, will be with O1For the rectangular coordinate system of initial point changes into O1For the polar coordinate system of initial point,If ρ is utmost point footpath, α is polar angle, and ρ and α are natural number, and ρ equals 0,1 ..., 498, or 499, α equals 0,1 ..., 178, or 179,Between its maximum and minimum of a value, set up respectively a discrete parameter space;
Secondly, set up the accumulator 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 value is 1, doesHough conversion, calculates this corresponding curve in polar coordinate system, and adds 1, i.e. N[ρ on corresponding accumulator] [α]=N[ρ][α]+1,
Finally, find out the local maximum of the accumulator of collinear points on correspondence (x, y) coordinate system, this value provide (x,Y) parameter (ρ of collinear points straight line on coordinate plane0,α0),α0Be the polar angle of the straight line that collinear points are maximum, because two, batteryThe length of crest line HR and GP is the longest, and therefore, the line segment that collinear points are maximum must be in HR or GP, again because HR and GP are flatOK, again with battery post body axis L1L2Parallel, therefore, battery post body axis L1L2Polar angle θ=α0,
(3) Coordinate Conversion
By original coordinate system iO1Any point coordinate [i, j] in j is transformed into i ' O in new coordinate system1J ', and calculate that it is newCoordinate figure [i ', j '], specific formula for calculation is as follows:
First, whenTime, by original coordinate system iO1J is around an O1Be rotated counterclockwiseAngle set up new withO1For the rectangular coordinate system i ' O of initial point1j′,
,
Wherein, i ', j ' is respectively coordinate system i ' O1The horizontal stroke of j ' mid point, ordinate value, and i ', j ' is natural number, i '=-399 ,-398, L0,1,2, L, 398, or 399, j '=-299 ,-298, L, 0,1,2, L, 298, or 299, and the abscissa i of pointEqual at 0 o'clock,In the time that the abscissa i of point is not equal to 0,
WhenTime, by original coordinate system iO1J is around an O1Be rotated counterclockwiseAngle is set up new for O1For formerRectangular coordinate system i ' the O of point1j′,
,
(4) calculate above-mentioned station A place Notebook Battery center point coordinate
First, at original coordinate system iO1In j, the image gathering is carried out to Threshold segmentation binary conversion treatment, obtain two-valueChange the gray value B of image1[i,j],I1[i, j] is the gray value of the original image of collection,T is the binarization segmentation threshold value of barrier and background, T=210, I1Capable, the j of i row in the original image that [i, j] representative gathersThe gray value of pixel, i=0,1,2, L, 398, or 399, j=0,1,2, L, 298, or 299, and by no place of binaryzation in coordinate systemThe point of managing is all set to 0,
Then, by the gray value B of image after binaryzation1[i, j], at coordinate system i ' O1In j ' respectively on i ' axle and j ' axleProjection, determines the coordinate J ' of battery central point on i ' axle and j ' axlexAnd J 'y, concrete steps are as follows:
1) by the gray value B of image after binaryzation1[i, j], to projection on i ' axle, calculates each parallel with j ' axle and lists allThe gray value sum of pixel, is stored in respectively array F by result of calculation1In [f], whenTime, Wherein m1=300×cosθ,n1=300 × cos θ, and r1、m1、n1Adopt and round up respectivelyMethod rounds numerical value, and f is from-m1Value is to n successively1; When Time, Wherein m1=400×cos(π-θ), And r1、m1、n1Adopt respectivelyRounding-off method rounds numerical value, f from 0 successively value to r1;
2) by the gray value B of image after binaryzation1[i, j], to projection on j ' axle, calculates in every a line parallel with i ' axleThe gray value sum of all pixels, is stored in respectively array H by result of calculation1In [h], whenTime, Wherein n2=300×cosθ, and r2, m, n adopt respectively rounding-off method to round numerical value, h from 0 successively value to r2; When Time, Wherein m2=400×cos(π-θ),And r2、m2、n2Adopt respectively rounding-off method to round numerical value, h is from-m2Value is to n successively2,
3) at coordinate system i ' O1In j ', adopt two ends detection methods, determine left and right on i ' direction of principal axis of Notebook BatteryThe abscissa value on border, and by result store at variable J 'L、J′RIn, simultaneously by the upper and lower border of determining on j ' direction of principal axisOrdinate value is stored in variable K 'UAnd K 'DIn, concrete steps are as follows:
A) f is according to f=-400 ,-399, L, and 0,1,2,399,400 values successively, in the time that f meets following condition: F1[f+2]-F1[f]≥15&&F1[f+2]≥25&&F1[f]≤5, show to have detected the left margin of Notebook Battery, use variableJ′LNote down current abscissa f, and make J 'L=f, continues to f assignment, when f meets following condition: F1[f]-F1[f+2]≥15&&F1[f]≥25&&F1[f+2]≤5, show to have detected the right margin of Notebook Battery, with variable J 'RNote down currentAbscissa f, and make J 'R=f,
B) h is according to h=-300 ,-299, L0, and 1,2, L299,300 values successively, when h meets following condition: H1[h+2]-H1[h]≥15&&H1[h+2]≥25&&H1[h]≤5, show to have detected the lower boundary of Notebook Battery, use variableK′DNote down current abscissa h, and make K 'D=h, continues to h assignment, when h meets following condition: H1[h]-H1[h+2]≥15&&H1[h]≥25&&H1[h+2]≤5, show to have detected the coboundary of Notebook Battery, with variable K 'UNote down currentAbscissa h, and make K 'U=h,
C) the abscissa C ' of calculating Notebook Battery central pointi′With ordinate C 'j′,C′i′=(J′L+J′R)/2,C′j′=(K′U+K′D)/2,
(5) determine the position of the anodal and negative pole of Notebook Battery
If F[J 'L]>F[J′R], Notebook Battery negative pole is at coordinate system i ' O1The middle abscissa value of j ' is J 'L, anodal horizontal seatScale value is J 'R; If F[J 'L]<F[J′R], Notebook Battery positive pole is at coordinate system i ' O1The middle abscissa value of j ' is J 'L, negative pole horizontal strokeCoordinate figure is J 'R,
(6) according to Notebook Battery central point at coordinate system i ' O1Horizontal stroke under j ', ordinate value, calculate at iO1J coordinate systemUnder horizontal stroke, ordinate value, computing formula is as follows:
When Time,
When Time,
Wherein, Ci′And Cj′Be respectively at new rectangular coordinate system i ' O1The horizontal stroke of definite Notebook Battery central point, vertical in j 'Coordinate figure, as abscissa Ci′Equal at 0 o'clock,As abscissa Ci′Be not equal at 0 o'clock,
(7) control manipulator J1Capture Notebook Battery
First, PLC controls manipulator J1To specified coordinate position, i.e. Notebook Battery center C (Ci,Cj), and controlMagnetic chuck X1The long the longest limit MN of rib vertical with torsion platform B horizontal center line ST, MN and L1L2Parallel, whenTime, PLC controls manipulator and is rotated counterclockwise θ angle and declines 10 centimetres, then the magnetic chuck crawl battery that powers onAnd rise 10 centimetres, and now, if F[J 'L]>F[J′R], control turn clockwise θ angle decline 10 centimetres of manipulator, thenMagnetic chuck power-off is put into Notebook Battery to reverse on platform, if F[J 'L]<F[J′R], control manipulator and be rotated counterclockwise π-θAngle also declines 10 centimetres, and then magnetic chuck power-off is put into Notebook Battery to reverse on platform; WhenTime, controllerTurn clockwise π-θ angle decline 10 centimetres of tool hand, then magnetic chuck powers on and captures battery and rise 10 centimetres, now,If F[J 'L]>F[J′R], control manipulator and be rotated counterclockwise π-θ angle and decline 10 centimetres, then magnetic chuck power-off is by penRemember that this battery is put on torsion platform, if F[J 'L]<F[J′R], control turn clockwise θ angle decline 10 centimetres of manipulator,Then magnetic chuck power-off is put into Notebook Battery to reverse on platform;
Step 2: utilize CCD camera C2Take and reverse six draw-in groove centre bottom rectangle hole images on platform, by figureDetermine as Processing Algorithm 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 C2Take the image that reverses upper six draw-in grooves of platform B, with CCD camera C2The center of the image of takingPoint O2For initial point is set up rectangular coordinate system, the image of taking is carried out to Threshold segmentation binary conversion treatment, obtain binary imageGray value B2[i,j],I2[i, j] is CCD camera C2The i that gathers image is capable,The gray value of j row pixel, T2For the white visible ray that sends from draw-in groove central rectangular aperture hole and the binarization segmentation threshold of backgroundValue, T2=200, i, j is natural number, and i=-199 ,-198, L, 0,1,2, L, 198, or 199, j=-149 ,-148, L, 0,1,2, L, 148, or 149,
(2) image is carried out to noise remove and connective processing
First, the gray value of pixel on image edge is set to 0, then adopts 3 × 3 detection window traversal view pictureImage, the gray value that makes detection window central point is B2[i, j], central point around the gray value of 8 neighborhood points from the upper left corner withBe respectively clockwise B2[i-1,j+1]、B2[i,j+1]、B2[i+1,j+1]、B2[i+1,j]、B2[i+1,j-1]、B2[i,j-1]、B2[i-1,j-1]、B2[i-1,j],
Allow 3 × 3 detection window travel through successively entire image, the gray value of the pixel under calculation window covers, if B2[i,j]+B2[i-1,j+1]+B2[i,j+1]+B2[i+1,j+1]+B2[i+1,j]+B2[i+1,j-1]+B2[i,j-1]+B2[i-1,j-1]+B2[i-1, j]≤3, make B2[i, j]=1, otherwise, B made2[i,j]=0,
Secondly, the image of removing after noise is carried out to floor projection
The gray value of removing each pixel listing of image after noise is added, result of calculation is stored in respectivelyArray F2In [f],Wherein f is integer, f=-199, and-198, L, 0,1,2, L, 198, or 199,
(3) Notebook Battery central point abscissa in computed image
F is according to f=-199 ,-198, L0, and 1,2, L, 198, or 199 values successively, when f meets following condition: F2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5, show that the rising edge for the first time that image detected is along coordinate,Note down current abscissa f with variable G, and make G=f, continue to f assignment, when f meets following condition: F2[f]-F2[f+2]≥15&&F2[f]≥25&&F2[f+2]≤5, show that the trailing edge for the first time that image detected, along coordinate, stops composing to fValue, notes down current abscissa f with variable G ', and makes G '=f, Notebook Battery rectangle draw-in groove K4Intermediate rectangular hole is at figureWidth value d ' in picture0=G '-G, unit is pixel, utilizes ruler directly to measure Notebook Battery rectangle draw-in groove intermediate rectangular holeWidth is d0, draw-in groove K1And K2Distance between intermediate rectangular hole center is l1, draw-in groove K2And K3Intermediate rectangular hole center itBetween distance be l2, draw-in groove K3And K4Distance between intermediate rectangular hole center is l3, draw-in groove K4And K5In intermediate rectangular holeDistance between the heart is l4, draw-in groove K5And K6Distance between intermediate rectangular hole center is l5,d0、l1、l2、l3、l4And l5ListPosition is millimeter; Known as calculated, draw-in groove K in image1And K2Distance between intermediate rectangular hole centerDraw-in grooveK2And K3Distance between intermediate rectangular hole centerDraw-in groove K3And K4Distance between intermediate rectangular hole centerDraw-in groove K4And K5Distance between intermediate rectangular hole centerDraw-in groove K5And K6Intermediate rectangular hole centerBetween distancel′1、l′2、l′3、l′4、l′5Unit be pixel, and round off method is to l '1、l′2、l′3、l′4、l′5Round, establish draw-in groove K in image1、K2、K3、K4、K5、K6The abscissa of intermediate rectangular hole central point is from left to right respectively x1、x2、x3、x4、x5、x6, unit is pixel,
(4) determine by template matching method the position that Notebook Battery should be laid
At manipulator J1Before laying battery, the CCD camera that reverses platform top all can be to reversing platform photographic images, to figurePicture is processed, and result of calculation is still stored in respectively to array F2In [f],Wherein f is integer,F=-199 ,-198, L0,1,2, L, 198, or 199 values successively, when f meets following condition: F2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5, show that first rising edge that image detected, along coordinate, stops the assignment to f, with becomingAmount E notes down current abscissa f, and makes E=f, states condition: F when f gets all over being discontented with foot after all values2[f+2]-F2[f]≥15&&F2[f+2]≥25&&F2[f]≤5 o'clock, store in variable E 0, i.e. E=0, by E respectively with x1、x2、x3、x4、x5、x6Compare, ifWherein ε is error threshold, and ε=3, shows draw-in groove K1Not placing battery, nowPLC controls manipulator J1The battery of absorption is put into draw-in groove K1; IfShow draw-in groove K2Do not place electricityPond, now PLC controls manipulator J1The battery of absorption is put into draw-in groove K2; IfShow draw-in groove K3NotPlacing battery, now PLC controls manipulator J1By first the battery of drawing Rotate 180 degree, then put into draw-in groove K3; IfShow draw-in groove K4Not placing battery, now PLC controls manipulator J1The battery of absorption is first rotated180 degree, then put into draw-in groove K4; IfShow draw-in groove K5Not placing battery, now PLC controls manipulatorThe battery of absorption is put into draw-in groove K5; IfShow draw-in groove K6Not placing battery, now PLC controllerTool hand J1The battery of absorption is put into draw-in groove K6; 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 K1、K2Around Z1Axle is counterclockwiseRotate 180 degree makes K simultaneously5、K6Around Z2Axle is rotated counterclockwise 180 degree, now, and manipulator J2By six joint notebook electricity after reversingPond is placed in the note book battery box on tooling platform V and assembles after capturing simultaneously.