How to set a variable name after snapshot?
1 回表示 (過去 30 日間)
古いコメントを表示
MUHAMMAD NAZMI ZAINAL AZALI
2019 年 11 月 27 日
コメント済み: Image Analyst
2019 年 11 月 28 日
Hi, i have a problem on how to save as variable image name and called it after snaphot? after that i want to crop it.
recognizeThreshold = 100;
vid = handles.vid;
vid.FramesPerTrigger = 1;
vid.ReturnedColorspace = 'rgb';
triggerconfig(vid, 'manual');
vidRes = get(vid, 'VideoResolution');
cam.Resolution = '1920x1080';
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', handles.axes3);
preview(vid, hImage);
% bersedia untuk capture image
start(vid);
% capture!
trigger(vid);
snapshot = getdata(vid);
counter=1;
% save the image file
%imwrite(snapshot, 'C:\Users\nazmiz\Desktop\PCB Tester\TestedPCB\Test.png')
savenam = strcat('C:\Users\nazmiz\Desktop\PCB Tester\TestedPCB\' ,num2str(counter), '.png'); %this is where and what your image will be saved
baseDir = 'C:\Users\nazmiz\Desktop\PCB Tester\TestedPCB\';
% baseName = 'image_';
newName = [baseDir num2str(counter) '.jpg'];
while exist(newName,'file')
counter = counter + 1;
newName = [baseDir num2str(counter) '.jpg'];
end
% show gambar yang snap tadi tu
axes(handles.axes3);
%imshow('C:\Users\nazmiz\Desktop\PCB Tester\TestedPCB\' ,num2str(counter),'.png');
%crop('C:\Users\nazmiz\Desktop\PCB Tester\TestedPCB\' ,num2str(counter),'.png');
%testing(cropimage.jpg);
This is an example image, i want to take a pcb picture only.
0 件のコメント
採用された回答
Image Analyst
2019 年 11 月 28 日
I usually call getsnapshot(), but you did
snapshot = getdata(vid);
so snapshot is the name of your variable. You can use imcrop() to crop it.
7 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!