Hi all,
I've got a gige camera and using Matlab to create a gui with some controlling functions/processing buttons for the camera images.
Using the following
Image = preview(VidObj);
ExtractedFrame = Image.CData;
I've been able to get the video feed to plot as 3D data which is what I'm looking for.
However, the preview window (small window, also showing the video stream) is always present and tends to be dominant in activity.
This is OK for the most but I think that because it's always visible (it's the active window on top of my gui figure), it's taking away control from my GUI.
I've added sliders in to control the viewing angle (which would be nicer to use the "surf" rotate by clicking and spinning the image, but again it works for what I need.
Where I'm struggling is adjusting camera exposure - it's presently set up as a
uicontrol('Style','edit', ...
which is ideally how I'd like it, but the VideoPreview window always keeps the focus, so I can't actually highlight the exposure time to 'edit' the value (can't get the GUI active for long enough)
But to have the gui with additional buttons and controls is where I'm headed, and using preview(VidObj) only lets this be a 2D image (where I'd like to see peaks as the attached screenshot shows)
One can also see the controls I have - change colormap ('rainbow' = jet), control min & max Z, exposure, then the sliders to control the 'view' of the surf plot of the image.
As I'm also doing more image processing, I can export the image displayed (at the bottom), find camera values above certain Z (peak detection) and apply Z thresholding
by pressing the buttons at the bottom left of the GUI
I'm planning to add more, but tidying the surf(Image) from preview(VidObj) will probably be the quickest way to handle this (and further issues?!)
I include my main code also which is handling the camera acquisition
function DisplayCameraFeed(~, ~)
VidObj = videoinput('gige');
VidObj.SelectedSourceName = 'input1';
[~] = preview(VidObj);
while GUI_Handles.Toggle_MAIN.Value
NthFrame = NthFrame + 1;
VideoProperties = get(VidObj);
CameraProperties = getselectedsource(VidObj);
CameraProperties.ExposureTime = str2double(GUI_Handles.Text_SetExposure.String);
Image = preview(VidObj);
ExtractedFrame = Image.CData;
switch size(ExtractedFrame, 3)
case 1
case 3
ExtractedFrame = rgb2gray(ExtractedFrame);
otherwise
keyboard;
end
GUI_Handles.GlobalCell{2, 4} = ExtractedFrame;
if GUI_Handles.Toggle_Slicing.Value
Toggle_Slicing;
ExtractedFrame = GUI_Handles.GlobalCell{2, 4};
end
surf(flipud(ExtractedFrame));
shading flat;
axis tight;
SetColorMap;
SliderCheck;
AXES = gca;
AXES.Position = [0.25, 0.25, 0.7, 0.7];
AXES.XAxis.Visible = 'off';
AXES.YAxis.Visible = 'off';
AXES.CLim = [GUI_Handles.Slider_Z_Min.Value, GUI_Handles.Slider_Z_Max.Value];
AXES.ZLim = [GUI_Handles.Slider_Z_Min.Value, GUI_Handles.Slider_Z_Max.Value];
AXES.View = [GUI_Handles.Slider_Angle_Azimuth.Value, GUI_Handles.Slider_Angle_Elevation.Value];
AXES.XLabel.String = sprintf('X');
AXES.YLabel.String = sprintf('Y');
AXES.XGrid = 'off';
AXES.YGrid = 'off';
AXES.ZGrid = 'off';
drawnow;
hold on;
Toggle_PeakDetector;
hold off;
end
stoppreview(VidObj)
end
Thanks for your help :)