I want to know how to overcome executable standalone app - image write path error?
3 views (last 30 days)
Show older comments
Lowhikan Sivananthasarma
on 31 May 2020
Commented: Thiago Henrique Gomes Lobato
on 31 May 2020
I have been working on Stereo Image capturing standalone app for my univeristy lab experiments. But I'm facing a problem while saving images in a selected path.
Basically what i'm trying to develop is when by pushing select save location button, it should allow me to select the folder where i want to save my images. Then when i click capture stereo images button, it should capture images and save the files in my choosen directory.
For time being,i use my webcam for capturing both images.When i run the code inside the Matlab app designer it works perfectly save the image files wherever i want.But if i export the app as standalone desktop app, it captures the images but it could not save images in any folder.
When i try to solve the issue, i found that i need to use isdeplyoed function. I tried but i could not solve the issue. Also i tried to save in the default ctfroot folder, then it says you don't have write permission.
This is my first app design and first question, So please be kind enough to overcome this problem.
It would be helpful if you can provide any similar app design ideas.
I have attched the parts of code where i have problems and relevant images with this email.
Thanks in advance.
properties (Access = private)
numOfPictures = 5;
waitTime = 1;
VDL;
VDR;
LeftvideoInputNumber = 1;
RightvideoInputNumber = 1;
oldpath= "H:\MATLAB App"
NumberOfTimesButtonHit = 0;
end
properties (Access = public)
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.VDR = videoinput('winvideo',app.LeftvideoInputNumber);
app.VDL = videoinput('winvideo',app.RightvideoInputNumber);
%preview(app.vidObj);
app.SaveLocationEditField.Value=app.oldpath;
end
% Button pushed function: CaptureStereoImagesButton
function CaptureStereoImagesButtonPushed(app, event)
LeftFrameStereo = getsnapshot(app.VDL);
RightFrameStereo = getsnapshot(app.VDR);
imshow(LeftFrameStereo,'Parent', app.UIAxes);
imshow(RightFrameStereo,'Parent', app.UIAxes2);
newpath=app.SaveLocationEditField.Value;
userpath(newpath)
app.NumberOfTimesButtonHit = app.NumberOfTimesButtonHit + 1 ;
num=num2str(app.NumberOfTimesButtonHit);
dtv=datestr(now);
dtv=strrep(dtv,':','_'); %Replace colon with underscore
dtv=strrep(dtv,'-','_');%Replace minus sign with underscore
dtv=strrep(dtv,' ','_');%Replace space with underscore
datenum=sprintf('_%s',num,dtv);
% Save the frames to images in Calibration Images folder
imwrite(LeftFrameStereo,fullfile(userpath,'CalibrationImages','Left', ['IMG_St_L',datenum,'.jpg']));
imwrite(RightFrameStereo,fullfile(userpath,'CalibrationImages','Right', ['IMG_St_R',datenum,'.jpg']));
end
% Button pushed function: SelectLocationButton
function SelectLocationButtonPushed(app, event)
pathname=uigetdir();
app.SaveLocationEditField.Value=pathname;
mainpath=sprintf('%s/CalibrationImages%s',pathname);
leftpath=sprintf('%s/Left%s',mainpath);
rightpath=sprintf('%s/Right%s',mainpath);
mkdir(leftpath)
mkdir(rightpath)
end
0 Comments
Accepted Answer
Thiago Henrique Gomes Lobato
on 31 May 2020
The problem is the userpath function. As stated in the error, you can't modify a matlab path in your deployed application, regardless of using isdeploy or not (this is actually only a value of 1 or 0). Try:
imwrite(LeftFrameStereo,fullfile(newpath,'CalibrationImages','Left', ['IMG_St_L',datenum,'.jpg']));
and remove the following line:
userpath(newpath)
You may have to make some slightely changes for the path to be a full valid one, but besides this it should work.
2 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!