Appdesigner: Workaround Functionality PickableParts?

4 views (last 30 days)
Happy PhD
Happy PhD on 15 Oct 2019
Answered: Thao Pham on 31 Mar 2020
Hi, I am trying to migrate myCameraGUI into AppDesigner. There are some issues in the Migration Report.
For example, the fucntionality Pickableparts is not supported in the App Designer with GUIDETAG cameraAxes. Are there any other similar functionality in the app designer?
I basically want to click on a button, to start and stop a camera stream, and another button to grab the image (snapshot) and save it to .mat file. I have even tried to write the similar code in app designer from scratch but it doesn't react to anything after clicking the button once, so i don't know how to solve that. 'myCameraGUI' does exactly what i want and i don't have any weird loading effects when I want to display the stream in the GUIDE.
I am very new with GUI and App designer, so any help appreciated.

Accepted Answer

Hope Q
Hope Q on 28 Oct 2019
It's not clear why you need pickable parts. Does the user need to draw an region on the image or is the area pre-defined?
If the user needs to draw an area, explore the Rectangle object.

More Answers (1)

Thao Pham
Thao Pham on 31 Mar 2020
after Migration, you can see the code of startstop button like this:
% Button pushed function: startStopCamera
function startStopCamera_Callback(app, event)
% hObject handle to startStopCamera (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Start/Stop Camera
if strcmp(get(app.startStopCamera,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
set(app.startStopCamera,'String','Stop Camera')
start(app.video)
set(app.startAcquisition,'Enable','on');
set(app.captureImage,'Enable','on');
else
% Camera is on. Stop camera and change button string.
set(app.startStopCamera,'String','Start Camera')
stop(app.video)
set(app.startAcquisition,'Enable','off');
set(app.captureImage,'Enable','off');
end
end
but it not work with app designer to show start with camera. So you can following these step below to correct it:
  1. Add new properties:
properties (Access = public)
video % Description
end
properties (Access = private)
webcamObject;
imageObject;
end
  1. Change code of if statement in the startstop button
% Start/Stop Camera
if strcmp(get(app.startStopCamera,'Text'),'Start Camera')
% Camera is off. Change button string and start camera.
%set(app.startStopCamera,'Text','Stop Camera')
app.startStopCamera.Text ='Stop Camera';
try
app.video = videoinput('winvideo', 1);
cam = webcam(1);
app.webcamObject = cam;
app.imageObject = image(app.cameraAxes);
axis(app.cameraAxes,'ij')
res = split(app.webcamObject.Resolution,'x');
app.cameraAxes.XLim = [0,str2double(res{1})];
app.cameraAxes.YLim = [0,str2double(res{2})];
app.webcamObject.preview(app.imageObject);
catch ME
% If problem reading image, display error message
uialert(app.myCameraGUI, ME.message, 'Image Error');
return;
end
triggerconfig(app.video,'manual');
app.video.FramesPerTrigger = Inf; % Capture frames until we manually stop it
%set(app.startAcquisition,'Enable','on');
%set(app.captureImage,'Enable','on');
app.startAcquisition.Enable = 'on';
app.captureImage.Enable = 'on';
else
...

Community Treasure Hunt

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

Start Hunting!

Translated by