MATLAB Answers

Sharing data between callback functions

16 views (last 30 days)
Hi, so in one callback function, I have the code,
file = uigetfile('*.jpg');
I would like to acess this file from a different callback function. However when I run the second callback, i get the error, "unrecognized function"
How do I allow the file to be acessed from other callback functions?

  9 Comments

Show 6 older comments
Rik
Rik on 11 Feb 2020
Then it probably makes sense to imread. Whether you want to set the image or the path as property is up to you.
Don't forget to validate the user input (so check if the user actually did select a file).
Oliver Ferenczi
Oliver Ferenczi on 11 Feb 2020
The issue with imread is that I need to access the file that was chosen in another callback function. So I am not sure how to get the file name from the other callback function.

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 11 Feb 2020
"The issue with imread is that I need to access the file that was chosen in another callback function. So I am not sure how to get the file name from the other callback function."
You already have done it! The issue with your original error, as pointed out by Rik is that you never read the image, just passed the filename instead of the image to the face detector.
So instead of:
bboxes = step(faceDetector, app.file);
simply:
faceimage = imread(app.file); %actually read the image
bboxes = step(faceDetector, faceimage);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2019b