How do you create a panorama with multiple images?
32 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a script that is connected to a raspberry pi with pan/tilt servos on a webcam. I am attempting to create a panorama by taking images and using the subplot command, but there is the blank space between the images.
function takePano(rpi, s1, s2)
%rpi is a raspberry pi, and s1/s2 are servos.
index=0;
for ii=0:2
for jj=0:2
%These 2 lines move the camera to the correct orientation.
writePosition(s1, 180-(90*jj))
writePosition(s2, 90*ii)
pause(0.5)
%These 2 lines take the picture and transfer it to my computer.
system(rpi, 'fswebcam -r 1920x1080 --no-banner pano_rpi.png')
getFile(rpi, '/home/pi/pano_rpi.png')
index=index+1;
%This line creates the pano one image at a time (per iteration).
subplot(3,3,index), imshow('pano_rpi.png')
disp(index)
end
end
%These 2 lines zero the camera position after it is done.
writePosition(s1, 90)
writePosition(s2, 90)
end
Is there a way to eliminate this blank space or a better way to do this?
NOTE: every time the raspberry pi takes a new picture it over-writes the previous one using the same file name.
0 Kommentare
Antworten (1)
Divya Yerraguntla
am 2 Apr. 2020
Bearbeitet: Divya Yerraguntla
am 2 Apr. 2020
Hi Alexander,
You could use the imread and montage functions from Image Processing Toolbox to accomplish your task instead of using subplots. Have a look at a modified version of your code below:
function takePano(rpi, s1, s2)
%rpi is a raspberry pi, and s1/s2 are servos.
index=0;
for ii=0:2
for jj=0:2
%These 2 lines move the camera to the correct orientation.
writePosition(s1, 180-(90*jj))
writePosition(s2, 90*ii)
pause(0.5)
%These 2 lines take the picture and transfer it to my computer.
system(rpi, 'fswebcam -r 1920x1080 --no-banner pano_rpi.png')
getFile(rpi, '/home/pi/pano_rpi.png')
index=index+1;
allimages(:,:,:,index) = imread('pano_rpi.png') % All the images are written to
% variable allimages by the end of the loop
imshow('pano_rpi.png')
disp(index)
end
end
montage(allimages); % displays all your images without space
%These 2 lines zero the camera position after it is done.
writePosition(s1, 90)
writePosition(s2, 90)
end
Hope it helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Run on Target Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!