How can i get image from other GUI in a project - i can not use global variable

1 回表示 (過去 30 日間)
Ha Nguyen
Ha Nguyen 2012 年 4 月 25 日
Hi everybody
I have a project and i will summerize :
at first i will run a GUI1 with a button Camera - then another (GUI2 - GUI of Camera) will appear for me to find all camera that connect to my computer - then i will choose one and configurate all properties that i want
and finaly i comeback GUI1 and press 'Take Photo' button to capture a new image and display in an axes on the same GUi - GUI1
But i dont know what to do - i find some way to do but i did not sucess ( i use a gobal variable named 'camojb' in GUi2 ( GUi of Camera) and i used this variable again in GUI 1 )
Pls Help me
many thanks!

回答 (1 件)

Kevin Holst
Kevin Holst 2012 年 4 月 25 日
I'm assuming that the problem is you're unable to use the information you acquired from GUI2. Globals may work, but they're not really recommended except in special circumstances. I'd suggest using setappdata and getappdata. If you're passing the handle of your GUI1 figure it'd be something like:
setappdata(hgui1,'camobj',camobj)
and then on the GUI1 take picture callback:
camobj = getappdata(hgui1,'camobj');
If you're not passing the handle for GUI1 into GUI2 then I'd just suggest using the same code, just swapping 0 for hgui1, that puts it in the root.

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by