Can't run 12-bit video in guide GUI using image acquisition toolbox

2 ビュー (過去 30 日間)
George Funkenbusch
George Funkenbusch 2020 年 7 月 22 日
回答済み: Andrei 2020 年 8 月 19 日
I'm trying to switch a GUI with an image acquisition toolbox video input from an 8-bit setting to a 12-bit setting. When I try to use the 12-bit setting in the imaqtool GUI, I have been able to capture video, grab a frame, and confirm that the exported data was in a 12-bit format. However, when I try to use the same mode in my GUI the display no longer works. I suspect it's because MATLAB colormaps only support lengths of 256, but since the imaqtool GUI is able to get around this limitation, I assume there must be some kind of workaround.
I'm using the following settings in my opening, output, and closing functions:
function Imaging_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Imaging (see VARARGIN)
% Choose default command line output for Imaging
handles.output = hObject;
imaqreset
handles.video = videoinput('pointgrey',1,'F7_BayerBG12_648x488_Mode0')
set(handles.video,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),' ...
'handles=guidata(gcf);'...
'image(getsnapshot(handles.video));'...
'set(handles.cameraAxes,''ytick'',[],''xtick'',[]),'...
'else '...
'delete(imaqfind);'...
'end']);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Imaging wait for user response (see UIRESUME)
uiwait(handles.Imaging);
% --- Outputs from this function are returned to the command line.
function varargout = Imaging_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
handles.output = hObject;
varargout{1} = handles.output;
% --- Executes when user attempts to close Imaging.
function Imaging_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to Imaging (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
delete(hObject);
delete(imaqfind);
and the following is my callback for the "Start Camera" button:
% --- Executes on button press in startbutton.
function startbutton_Callback(hObject, eventdata, handles)
% hObject handle to startbutton (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(handles.startbutton,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
src = getselectedsource(handles.video);
src.ShutterMode = 'Auto';
src.GainMode = 'Auto';
src.WhiteBalanceRBMode = 'Auto';
triggerconfig(handles.video,'manual');
handles.video.FramesPerTrigger = 1;
set(handles.startbutton,'String','Stop Camera')
start(handles.video)
set(handles.captureButton,'Enable','on');
else
% Camera is on. Stop camera and change button string.
set(handles.startbutton,'String','Start Camera')
stop(handles.video)
set(handles.captureButton,'Enable','off');
end
My code is based on this answer: https://www.mathworks.com/matlabcentral/answers/96242-how-can-i-insert-live-video-into-a-matlab-gui-using-image-acquisition-toolbox

回答 (1 件)

Andrei
Andrei 2020 年 8 月 19 日
If you are using a preview callback function, it might be related to the fact that the preview data is by default truncated to 8 bit.
A possible workaround is to use the following command before creating the videoinput object:
imaqmex('feature', '-previewFullBitDepth', true);

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by