Matlab code object recognition .pdf



Nom original: Matlab code object recognition.pdfAuteur: estudiante

Ce document au format PDF 1.5 a été généré par Microsoft® Word 2010, et a été envoyé sur fichier-pdf.fr le 13/11/2015 à 18:14, depuis l'adresse IP 200.3.x.x. La présente page de téléchargement du fichier a été vue 423 fois.
Taille du document: 614 Ko (9 pages).
Confidentialité: fichier public


Aperçu du document


MATLAB PROCESSING FOR OBJECT
RECOGNITION AND POSITION
DETERMINATION

%% initialisation .................................................................................................................................. 2
%% get an image of the empty shelf and calibration for distances .................................................... 2
%% setting the origine and scale......................................................................................................... 3
%% load the image of the wanted object ........................................................................................... 3
%% get an image of the shelf with the objects on it ........................................................................... 4
%% preprocessing for images ............................................................................................................ 5
%% finding the object in the shelf image ............................................................................................ 6
%% find position using the bounding boxes; ..................................................................................... 8

1

Pierre Ralite, CTAI, PUJ Bogotá

%% initialisation
vid=videoinput('kinect',1,'RGB_1280x960');
depth=videoinput('kinect',2);
preview(vid)
%You should choose a 640x480 because the depth sensor as the same resolution but here
we choose a better resolution ( 1280x960 ) and we will divide the position by two later to
have depth and rgb at same dimensions

%% get an image of the empty shelf and calibration for distances
empty_shelf=getsnapshot(vid);
empty_shelf = empty_shelf(:,end:-1:1,:);
imtool(empty_shelf)
%the shelf must be at least 70cm away from the Kinect according to the Kinect manual.
The second line is a vertical symmetry.

2

Pierre Ralite, CTAI, PUJ Bogotá

%% setting the origine and scale
zero=[658 960-644];
zero=zero/2;
onex=[872 960-642];
oney=[650 960-410];
onex=onex/2;
oney=oney/2;
markx=270; % mark is the real distance in mm btw zero and one on x axis
marky=280;
scalex=markx/(onex(1,1)-zero(1,1));
scaley=marky/(oney(1,2)-zero(1,2));
% execute this step again each time the shelf or the camera is moved.

%% load the image of the wanted object
imageNames =
{'pr1.jpg','pr2.jpg','pr3.jpg','pr4.jpg','pr5.jpg','pr6.jpg','pr7.jpg','pr8.jpg','pr9.jpg'};
numImages = numel(imageNames);
emptyEntry = struct('image',[],'thumbnail',[]);

3

Pierre Ralite, CTAI, PUJ Bogotá

imageCollection = repmat(emptyEntry,[1 numImages]);
for i = 1:numel(imageCollection)
imageCollection(i).image = imread(imageNames{i});
end
%this creates an image collection with all the views of the object the robot should pick,
the more you have the better (change illumination and angles)

%% get an image of the shelf with the objects on it
full_shelf=getsnapshot(vid);
full_shelf = full_shelf(:,end:-1:1,:);
full_shelf_depth=getsnapshot(depth);
full_shelf_depth = full_shelf_depth(:,end:-1:1);
%the shelf must be at least 70cm away from the Kinect according to the Kinect manual

4

Pierre Ralite, CTAI, PUJ Bogotá

%% preprocessing for images
new_objects=imabsdiff(full_shelf,empty_shelf);
substracting the empty_shelf image from the full_shelf one
imshow(new_objects)

% we show the image

new_objects=im2bw(new_objects,graythresh(new_objects));
new_objects=bwareaopen(new_objects,1000);
se=strel('disk',20);
new_objects=imdilate(new_objects,se);
bw=bwlabel(new_objects,8);
stats=regionprops(bw,'BoundingBox','Centroid');
hold on %shows the boundingboxes on the image
for(object=1:length(stats))
bb=stats(object).BoundingBox;
bc=stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','Linewidth',1)
plot(bc(1),bc(2),'-m+')

5

Pierre Ralite, CTAI, PUJ Bogotá

%gives rectangles for each object
%stores it

end
hold off
numObject = length(stats);
emptyEntry =
struct('image',[],'thumbnail',[]);
objectCollection = repmat(emptyEntry,[1 numObject]);
j=1;
for j = 1:numel(objectCollection)
objectCollection(j).image = imcrop(full_shelf,stats(j).BoundingBox);
end
%the loop creates a collection with the new_objects from full shelf

%% finding the object in the shelf image
%init for second loop
j=1;
m=0;
i=1;
A=[];

[m,n] = size(A);

%first for loop in j is used to process surf on each new object from full shelf

6

Pierre Ralite, CTAI, PUJ Bogotá

for j=1:length(stats)
cameraframegray=rgb2gray(objectCollection(j).image); %preprocessing
cameraframepts=detectSURFFeatures(cameraframegray);
%surf algorithm
detects points of interest of new object number j
cameraFeatures=extractFeatures(cameraframegray,cameraframepts);
%we store it
%second for loop in i is used to process surf on the wanted objet collection
for i=1:numImages
a= rgb2gray(imageCollection(i).image);
imrefpts=detectSURFFeatures(a);
imreffeatures=extractFeatures(a,imrefpts);
idxpairs=matchFeatures(cameraFeatures,imreffeatures);
%then it does a
matching with the j new object on the shelf
matchedcamerapts= cameraframepts(idxpairs(:,1));
matchedimrefpts= imrefpts(idxpairs(:,2));
B=matchedcamerapts.Location;
[m1,n1] = size(B);
[i,j,m1,m]
if m1>m %stores the best matching result
A=B;
m=m1;
n=i;
MC=matchedcamerapts;
MI=matchedimrefpts;
k=j;
end
end
end
figure(1)
showMatchedFeatures(objectCollection(k).image,imageCollection(i).image, MC, MI,
'montage');

7

Pierre Ralite, CTAI, PUJ Bogotá

%% find position using the bounding boxes;
x1=stats(k).Centroid(1,1);
y1=stats(k).Centroid(1,2);
x2=round(x1);
y2=960-round(y1);
z2=impixel(full_shelf_depth,x2/2,y2/2);
z=z2(:,1);
x=(x2/2-zero(:,1))*scalex;
y=(y2/2-zero(:,2))*scaley;
Position=[x y z]

8

Pierre Ralite, CTAI, PUJ Bogotá

1) http://amazonpickingchallenge.org/details.shtml
2) http://support.xbox.com/en-US/xbox-360/kinect/kinect-sensor-components
3) http://openkinect.org/wiki/Protocol_Documentation#Control_Commands;a=sum
mary
4) https://en.wikipedia.org/wiki/Kinect
5) http://www.mathworks.com/products/image/
6) http://www.mathworks.com/discovery/object-recognition.html
7) Digital System Design 2nd Edition by Potowski
8) Image processing with Matlab by Carol Martinez, Course: Computer Vision for
robo2cs, Beijing July 2014
9) http://www.mathworks.com/help/vision/examples/image-search-using-pointfeatures.html

Useful links:
1) http://www.mathworks.com/matlabcentral/linkexchange/links/2718-kinect-formatlab
2) http://studentguru.gr/b/vangos/archive/2011/01/20/how-to-successfully-installkinect-windows-openni-nite
3) http://www.mathworks.com/matlabcentral/fileexchange/30242-kinect-matlab
4) Kinect developer toolbox windows Microsoft http://www.microsoft.com/enus/download/details.aspx?id=36998
5) https://sites.google.com/site/julianquirogasepulveda/teaching/senales-eimagenen
6) http://www.mathworks.com/help/imaq/acquiring-image-and-skeletal-data-usingthe-kinect.html
7) http://www.instructables.com/id/Control-a-Robotic-Arm-with-the-MicrosoftKinect/?ALLSTEPS

9

Pierre Ralite, CTAI, PUJ Bogotá


Aperçu du document Matlab code object recognition.pdf - page 1/9
 
Matlab code object recognition.pdf - page 2/9
Matlab code object recognition.pdf - page 3/9
Matlab code object recognition.pdf - page 4/9
Matlab code object recognition.pdf - page 5/9
Matlab code object recognition.pdf - page 6/9
 




Télécharger le fichier (PDF)


Matlab code object recognition.pdf (PDF, 614 Ko)

Télécharger
Formats alternatifs: ZIP



Documents similaires


matlab code object recognition
matlab apc second presentation
proposed system for mid air holography p
ralite colombia 1
une prothese dans le cerveau pour doper la memoire
tutorial3

Sur le même sujet..