Summary of the invention
The objective of the invention is to overcome the deficiency of prior art, provide that a kind of real-time is high, algorithm is simple, operand is little and be applicable to robot navigation's under the specific environment robot method for tracing based on color identification.
The present invention solves its technical problem and takes following technical scheme to realize:
A kind of robot method for tracing based on color identification may further comprise the steps:
Step 1: utilize the camera of installing in the robot to grasp piece image;
Step 2: the position coordinates of the image that grasps being analyzed and obtained the particular color object;
Step 3: generate control command and control robot motion according to the position coordinates of particular color object, circulation execution in step 1 is to step 3, until the distance of robot and particular color object during less than setting value, and the robot stop motion.
And said particular color object is red object, green object or blue object.
And said step 2 comprises following processing procedure:
(1) be the YUV color-code with the rgb color code conversion;
(2) according to the color of particular color object, find marginal position X2, the X1 of particular color object, Y2, Y1, and then obtain the position coordinates of particular color object in this image: (X2-X1)/2, (Y2-Y1)/2.
And said step 3 comprises following processing procedure according to the position coordinates generation control command of particular color object:
(1) piece image is divided into left field, zone, front side and right side area on X-direction;
(2) if the position coordinates of particular color object is positioned at the right side area of image, then generate dextrorotary control command; If the position coordinates of particular color object is positioned at left field, then robot generates the control command to anticlockwise; Otherwise the position coordinates of particular color object is positioned at the zone, front side, and then robot generates proal control command.
And described left field, zone, front side and the ratio of right side area on the image X-direction are: 7/16,1/8,7/16.
Advantage of the present invention and good effect are:
The present invention adopts the navigation trace mode based on color identification; Utilize camera to grasp image and the image that grasps is carried out simple analysis handle and to realize; It is big and consumed the problem of a large amount of system resource to have solved complex algorithm, operand that traditional vision guided navigation mode exists; Overcome the problem that the guide rail navigate mode needs mounting guide rail and limited by the place simultaneously; Also overcome the sensor navigate mode and need use big quantity sensor and need carry out the problem that cycle is long, workload is big that a large amount of test corrected parameters exists, had that algorithm is simple, operand is little, real-time and system resource taken characteristics such as little sensor.In addition; The present invention only need increase a camera module for robot and can realize; Do not need other hardware device, than other navigate mode, it is simple in structure, with low cost; Can be widely used in robot system, be specially adapted under the specific occasion tracking for the particular color object with camera.
The specific embodiment
Below in conjunction with accompanying drawing the embodiment of the invention is done further detailed description.
A kind of robot method for tracing based on color identification like Fig. 1, may further comprise the steps:
Step 1, utilize the camera installed in the robot to grasp piece image.
This step is utilized the camera of installing in the robot to be taken pictures in camera the place ahead and is grasped image; The resolution ratio of this image situation according to the actual requirements is provided with, and resolution ratio is high more, and navigation accuracy is also high more; But the requirement to hardware is also high more, and operand is also big more.Image with 1280x1024 resolution ratio describes below.
Step 2, the image that grasps analyzed and obtains the position coordinates of particular color object.
The particular color object can that is to say that this method for tracing can carry out tracing navigation to red object, green object and blue object for red body, green object and blue object.
This step specifically comprises following processing procedure:
(1) be the YUV color-code with the rgb color code conversion:
Because the image of general camera collection all is all to adopt the rgb color coding, therefore, need convert the rgb color coded system to YUV color-code mode according to following transformational relation:
Y=0.299*R+0.587*G+0.114*B;
U=-0.147*R-0.289*G+0.436*B=0.492*(B-Y);
V=0.615*R-0.515*G-0.100*B=0.877*(R-Y);
(2) according to follow the trail of the scope of object color; Find marginal position X2, the X1 of particular color object, Y2, Y1, and then obtain the position coordinates of particular color object in this field of view for (X2-X1)/2; (Y2-Y1)/2; In the following formula, X1, X2 are the coordinate of reflection left and right edges in image of object, Y1, Y2 be the reflection of object in image on the coordinate of lower limb.
In order to find the marginal position of particular color object, need to set in advance to follow the trail of the color gamut of object.Wherein, red object color gamut is:
ymin=75,ymax=225;
umin=100,umax=150;
vmin=175,vmax=250;
Green object color scope:
ymin[ix]=25,ymax[ix]=45;
umin[ix]=65,umax[ix]=85;
vmin[ix]=15,vmax[ix]=35;
Blue object color scope:
ymin[ix]=55,ymax[ix]=65;
umin[ix]=175,umax[ix]=185;
vmin[ix]=95,vmax[ix]=105。
Step 3, generate control command and control robot motion according to the position coordinates of particular color object.
(1) for robot is carried out navigation processing, need with piece image on the image X-direction, promptly transversely be divided into left field, zone, front side, right side area, as shown in Figure 2.Left field, zone, front side, the ratio of right side area on image X-direction (laterally) are: 7/16,1/8,7/16; Image with 1280x1024 resolution ratio is an example; Then left field, zone, front side, right side area are respectively 1 to 560 (size is 56); The zone, front side is 561 to 720 (size is 160), and right side area is 721 to 1280 (size is 560).
(2) position coordinates according to the particular color object generates control command and execution: if position coordinates (X2-X1)/2>720; Explain that then the position coordinates of particular color object is positioned at the right side area of image; Promptly generate dextrorotary control command; The control robot is rotational time T1 to the right, jumps to step 1 then; If (X2-X1)/2<560, explain that then the position coordinates of particular color object is positioned at the left field of image, then robot generates the control command to anticlockwise, and the control robot is rotational time T1 left, jumps to step 1 then; Otherwise the position coordinates of particular color object is positioned at the zone, front side, and then robot generates proal control command; The control robot time T 2 that travels forward is come the roughly distance of judgment object and robot through the size of (X2-X1) and setting value x relatively then, if (X2-X1)<setting value x; Robot and object then are described beyond risk distance, can be continued to move ahead, jump to step 1 then; Otherwise robot stops to move ahead.In the present embodiment, the T1 value is 50ms-70ms; The T2 value is 0.8s-1.2s, time T 1, and T2 is related to robot after action, and in desired zone, concrete value can be provided with in the afore mentioned rules scope according to actual conditions object.
Can realize robot tracking function through above-mentioned steps based on color identification.
Embodiment of the present invention is illustrative, rather than determinate, so the present invention is not limited to the embodiment described in the specific embodiment.Other embodiments that every technical scheme according to the present invention draws belong to the scope that the present invention protects equally.