MATLAB Answers

how i can capture and then save many images using kinect camera at one time?

조회 수: 32(최근 30일)
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

표시 이전 댓글 수: 1
Muhammad Hammad Malik
Muhammad Hammad Malik 16 Aug 2018
thanks for your kind reply.see attach image. i am using this code to save image but this is saving one image at one time, i want to save multiple images in each second.<</matlabcentral/answers/uploaded_files/129150/Capture.JPG>>
Florian Morsch
Florian Morsch 16 Aug 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
Muhammad Hammad Malik
Muhammad Hammad Malik 20 Aug 2018
thanks for your kind help. i have used this code
N = 4;
A = imread('my_img.png');
for ii = 1:N
imwrite(A,strcat('my_new',num2str(ii),'.png'));
end
from link given by you. when i run this code it is saving multiple images but when again i run this, it overwrite the images on previous ones instead creating the new images. so how to do that? thanks

로그인 to comment.

채택된 답변

Florian Morsch
Florian Morsch 20 Aug 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.

  댓글 수: 3

Muhammad Hammad Malik
Muhammad Hammad Malik 27 Aug 2018
thanks.i tried it but it is giving error like 'Unable to open file "my_new1.jpg" for writing. You might not have write permission'. code of error:imwrite(color,strcat('my_new',num2str(NumberOfNextImage),'.jpg'));
Walter Roberson
Walter Roberson 27 Aug 2018
You are probably cd'd to a directory you do not have write access to; in particular you are probably cd'd to the directory MATLAB is installed in. You should cd to somewhere you can write files.
Muhammad Hammad Malik
Muhammad Hammad Malik 28 Aug 2018
i am saving images in F drive, not in C and i already saved images in F drive but when i use this code then it is showing this error. see the code:
a=dir(['F:\kinect data\color\plant' '/*.jpg']); out=size(a,1);
N = 4; for ii = 1:N NumberOfNextImage=ii + out; imwrite(color,strcat('my_new',num2str(NumberOfNextImage),'.jpg')); end

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by