Callback function is not executed anymore after using snapshot or step getting image frames
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using a GUI to start and stop my video camera. First I create the videoinput with
- vid = videoinput('avtmatlabadaptor64_r2009b',1,'F7M0_Raw8_1032x778');
- start(vid);
Everything works fine if I get image data in a loop data with:
image = getdata(vid,1,'single')
But this is extremely slow. So I changed this line into
image = getsnapshot(vid); (or alternatively into image = step(vid); using imaq.VideoDevice)
which both run 10 times faster. My problem is now that my GUI button press functions are not executed anymore when I press a button. The header of this function is: function buttonStop_Callback(hObject, ~, handles) Has anyone an idea how I can fix this problem?
댓글 수: 2
Image Analyst
2012년 6월 26일
Does the button move at all when you press it? Or change color or get a little dotted line in it?
채택된 답변
tlawren
2012년 6월 26일
What does your stop callback function actually do? Does it set a stop flag variable? When I make data collection GUIs, I typically put my data collection code inside a loop that is designed to run non-stop until a stop flag is set. My stop buttons then have only one purpose and that is to set the stop flag. A rough example of this process is the following.
% pre-collect data stuff
set(handles.StopButton,'UserData', 0);
while (get(handles.StopButton,'UserData') == 0)
% collect data
end
% post collect stuff
The StopButton function simply sets the UserData field in handles.StopButton to 1.
This may not be the best way to actually collect data in a GUI and it may not be of any use to you (I don't know how getdata and getsnapshot work), but it might be an idea to consider.
댓글 수: 4
Image Analyst
2012년 6월 27일
I'm not sure why either. All I know is that I've tried to do that before and it doesn't work with buttons, however it does work with checkboxes. So if I need to break out of an intensive, computationally heavy loop I make visible a checkbox that says "Finish now" which the user can click and my loop can check and bail out if it's checked. Then I hide the checkbox until the next time. Making a "Finish Now" button to set a "FinishNow" flag didn't seem to work, I guess because the loop was so intensive it never got around to starting that parallel code execution going. Maybe putting in that pause gave it a chance to catch its breath and do other things, like running that button's callback.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!