Projecting vision application for industrial robot
Mostrar comentarios más antiguos
Hello. I have task for project. I need create application in Matlab into a robot that will perform pick-and-place tasks. Can someone please advise me whether I think in the right direction. Preliminary scheme looks like this:
- 1. Taking a photo
- 2. Counting how many objects and where they are located
- 3. I recognize the object and classifies it as such. for example Triangle or diamond.
- 4. Downloading its orientation in (x, y) and send to the robot.
- 5. The robot will have a separate program (pick and place) running in a loop.
For now, what i have in my code.
- 1. Taking a picture.
- 2. Converting to binary
- 3. Filling gaps (holes).
- 4. Labelling.
- 5. Using region props witch can determine their orientation, middle.
- 6. Now I want that every object is rotated to angle 0 '. (the same as uploaded template).
- 7. Using the template matching check whether the object agrees with the template.
- 8. When fits send information to the robot.
I'm not good with programming. I hope that someone will give me some tips. Please help.
My code here:
read the second image
img2 = imread('https://s14.postimg.org/y3pheo535/rozsypanka.jpg');
img2 = im2double(rgb2gray(img2));
bw = im2bw(img2); % Otsu's thresholding
bw = imfill(~bw, 'holes'); % fill holes
figure(9),imshow(img2)
% show centers and bounding boxes of each connected component
L = bwlabel(bw);
figure(1),imshow(L == 7)
title('Object 7')
figure(9),imshow(L)
% Get the extrema points for each labeled object.
s = regionprops(L, {'Extrema' 'Centroid', 'BoundingBox', 'Orientation'});
imageHandle = imshow(L, 'InitialMagnification', 'fit');
axesHandle = ancestor(imageHandle, 'axes');
figure(2),imshow(L)
hold on
for k = 1:numel(s)
c = s(k).Centroid;
text(c(1), c(2), sprintf('%d', k), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle');
end
extremas = cat(1, s.Extrema);
%hold on
plot(extremas(:,1),extremas(:,2), 'b*')
figure(3)
hold off
%Makes bounding boxes and X in centers of images
centers = vertcat(s.Centroid);
imshow(bw), hold on
plot(centers(:,1), centers(:,2), 'LineStyle','none', ...
'Marker','x', 'MarkerSize',20, 'Color','r', 'LineWidth',3)
for k=1:numel(s)
rectangle('Position',s(k).BoundingBox, ...
'EdgeColor','g', 'LineWidth',3)
end
hold off
%Rotations
%c = s(r).Centroid;
%It can be done it loop:
%for (L == 1):( L== 7)
Object1=(L == 1);
Object2=(L == 2);
Object3=(L == 3);
Object4=(L == 4);
Object5=(L == 5);
Object6=(L == 6);
Object7=(L == 7);
st = regionprops( Object7, 'Orientation' )
rbw = imrotate(Object7, st.Orientation );
pc = any( rbw, 2 ); %// project all rows into a single column
pr = any( rbw, 1 ); %// project all columns into a single row
fx = find( pr, 1, 'first'); %// first x coordinate
tx = find( pr, 1, 'last'); %// last x coordinat
fy = find( pc, 1, 'first'); %// first y coordinate
ty = find( pc, 1, 'last'); %// last y coordinate
imshow(rbw,[],'border','tight');
hold on;
plot( [fx tx tx fx fx], [fy fy ty ty fy], ':r', 'LineWidth',3);
[fx fy tx ty]
st1 = regionprops( rbw, 'Orientation' );
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Computer Vision Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!