I want to know how to overcome executable standalone app - image write path error?

2 visualizaciones (últimos 30 días)
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.
Image Acquisition Standalone App
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

Respuesta aceptada

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato el 31 de Mayo de 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 comentarios
Lowhikan Sivananthasarma
Lowhikan Sivananthasarma el 31 de Mayo de 2020
Thank you so much. It worked Perfectly. Thankyou so much for you quick reply as well. I didn't except this while asking question here.I have been trying to solve this issue for a month.Now I'm really happy, since it is my first standalone app.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by