GUI with GUI Live RGB-Plot of Video Data

4 次查看(过去 30 天)
Hello there, I´m creating a customized image processing software with the Image Acquisition Tool. I would like to implement a Live RGB-Plot of Preview-Data. By using the preview function, I pass the preview Data to an axes.handle, which works fine. The I like to pass the data into a customized function (to plot the RGB channels) and pass the plot to another axes-handle (I guess I have to use Event.Data, which is created by the preview function]). But it doesnt work properly. I already tried to use the UpdadepreviewWindowFunction. Does someone have any suggestions?
  2 个评论
Adam
Adam 2018-8-31
编辑:Adam 2018-8-31
Well, the problem is precisely what the error states. 'event' does not exist as a variable in that scope. You say it is created by the preview function yet you don't have any output arguments when you call preview so nothing will be passed from it into this Config_Callback function.
What does preview do exactly and what are you expecting 'event' to be such that it has a .Data field?
Linda Kampe
Linda Kampe 2018-8-31
Hey Adam, thanks for your answer. In the Matlab-Documentation is is written: "When preview invokes the function handle you specify, it passes three arguments to your function: obj, himage and the event-structure (containing the fields Data, Resolution, Status, Timestamp). So you suggestion is to write it like that?: [objt, hObject, Event]=preview(handles.VidObj,handles.hImage)

请先登录,再进行评论。

采纳的回答

Linda Kampe
Linda Kampe 2018-8-31
编辑:Linda Kampe 2018-8-31
In Progress...// So the Live-RGB-Histogram seems to be working. But there is still one Problem left. As you can see in the picture, the Histogram is outside of my GUI. I don´t know how to pass the axes handle to the 'setappdata(im_handle1, 'UpdatePreviewWindowFcn',@update_livehistogram_display)'. There must be a way to deliver the axes handle to my updatefunction ('update_livehistogram_display')? Any suggestions? My code is the following:
% if true
% function Config_Callback(hObject, eventdata, handles)
vid = videoinput('winvideo',1);
im_handle1 = image(zeros(1280,720));
setappdata(im_handle1, 'UpdatePreviewWindowFcn',@update_livehistogram_display);
axes(handles.Camera)
preview(vid,im_handle1);
end
function update_livehistogram_display(obj,event,hImage)
set(hImage,'CData',event.Data);
Red = event.Data(:,:,1);
Green = event.Data(:,:,2);
Blue=event.Data(:,:,3);
[yRed, x] = imhist(Red);
[yGreen, x] = imhist(Green);
[yBlue, x] = imhist(Blue);
% figure('name','value')
% axes(handles.RGB)
plot( x, yRed, 'Red', x, yGreen,'Green', x, yBlue,'Blue');
title('RGB-Live_Histogram')
ylabel('Rate')
xlabel('Intensitiy from 0 to 256')
end
% end
  3 个评论
Linda Kampe
Linda Kampe 2018-9-2
Hey Adam, thank you so much-that was exactly the solution I was searching for! Sorry for my delayed answer- now everything works fine :)
Angelik Hernandez
Angelik Hernandez 2020-3-24
Can you help me. I did the code test and it marks me error, could you share part of your code?

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by