how i can capture and then save many images using kinect camera at one time?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Muhammad Hammad Malik
le 15 Août 2018
Commenté : Walter Roberson
le 30 Nov 2021
how i can capture and thensave many images using kinect camera at one time? i am using matlab by making GUI. i can save image now but i want to save more then one images with the passing of seconds. kindly guide me thanks
4 commentaires
Florian Morsch
le 16 Août 2018
I dont know what you have attached there, its no link ;)
This might help you, its a example on how to get multiple images from a webcam. Since you already can get your images from the kinect you just can change the loop in the example. https://de.mathworks.com/help/supportpkg/usbwebcams/ug/acquire-webcam-images-in-a-loop.html
And for the saving of the images you could take a look here: https://de.mathworks.com/matlabcentral/answers/115539-how-to-save-write-images-using-for-loop
Muhammad Hammad Malik
le 20 Août 2018
Modifié(e) : Walter Roberson
le 27 Août 2018
Réponse acceptée
Florian Morsch
le 20 Août 2018
Right now you have a fixed N, in this case N=4 and if you run your code you will save the images to my_new1.png, my_new2.png, and so on. Now if you run the code again, the N stays the same which causes the name to be the same, thats why you are overriting the images. If you want to save multiple images in the folder, search for all image files in the folder, count them and then add that number to the name.
From this already answered question ( https://de.mathworks.com/matlabcentral/answers/65564-find-total-number-of-images-in-a-folder ) you can learn how to count the images in a folder.
You can use
a=dir([yourfolder '/*.jpg']); %%You have to give your folder location here
out=size(a,1);
N = 4;
A = imread('my_img.png');
for ii = 1:N
NumberOfNextImage=ii + out;
imwrite(A,strcat('my_new',num2str(NumberOfNextImage),'.png'));
Now your code would check for the total amount of images in the folder and if you run with 4 images and say you already have 12 in the folder, your images would be named ii + 12, so my_img13.png, my_img14.png, ... and so on.
4 commentaires
Muhammad Hammad Malik
le 28 Août 2018
Modifié(e) : Walter Roberson
le 30 Nov 2021
Walter Roberson
le 30 Nov 2021
That code tries to write images into the current directory, not into the directory that you read the images from.
imgdir = 'F:\kinect data\color\plant';
a = dir( fullfile(imgdir, '*.jpg') );
out=size(a,1);
N = 4;
for ii = 1:N
%at this point, update the variable named color with a new image
NumberOfNextImage=ii + out;
outfile = fullfile(imgdir, "my_new" + NumberOfNextImage + ".jpg");
imwrite(color, outfile);
end
Plus de réponses (1)
Mohamed Ramadan
le 30 Nov 2021
mycam=webcam
preview(mycam)
img=snapshot(mycam);
imshow(img)
imwrite(img,'newimage.jpg');
0 commentaires
Voir également
Catégories
En savoir plus sur Kinect For Windows Sensor dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!