Clear Filters
Clear Filters

Two camera previews in one Matlab GUIDE window

7 views (last 30 days)
So I made a custom GUI with GUIDE to see my two camera previews next to each other. It contains a panel and two axes inside. Im using two gige vision cameras that record video not in color but in black and white or gray I should say.
Im having the following problems:
I always get only one camera preview, at least a black screen on the left axes and nothing on the right. I would like to know what Im doing wrong here.
axes(handles.axes1);
axes(handles.axes2);
Another problem is:
image(zeros(1082,1312,3)
At first I do not know which resolutions are available for my cameras and the imaqtool only tells me mon8, or mono12...
The 3 at the end means TrueColor and I know that my cameras only produce gray images. So what do I have to put in here then?
And at last, I would like to know what you guys think of the rest of the code shown below?
function varargout = example1(varargin)
% EXAMPLE1 MATLAB code for example1.fig
% EXAMPLE1, by itself, creates a new EXAMPLE1 or raises the existing
% singleton*.
%
% H = EXAMPLE1 returns the handle to a new EXAMPLE1 or the handle to
% the existing singleton*.
%
% EXAMPLE1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EXAMPLE1.M with the given input arguments.
%
% EXAMPLE1('Property','Value',...) creates a new EXAMPLE1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before example1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to example1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help example1
% Last Modified by GUIDE v2.5 08-Sep-2017 13:02:13
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @example1_OpeningFcn, ...
'gui_OutputFcn', @example1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before example1 is made visible.
function example1_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 example1 (see VARARGIN)
% Choose default command line output for example1
handles.output = hObject;
axes(handles.axes1);
axes(handles.axes2);
vid1 = videoinput('gige', 1,'Mono8');
vid2 = videoinput('gige', 2,'Mono8');
hImage1 = image(zeros(1082,1312,3),'Parent',handles.axes1);
hImage2 = image(zeros(1082,1312,3),handles.axes2);
src1 = getselectedsource(vid1);
src2 = getselectedsource(vid2);
set(vid1,'TriggerRepeat',inf);
set(vid2,'TriggerRepeat',inf);
src1.AcquisitionStartTriggerMode = 'On';
src2.AcquisitionStartTriggerMode = 'On';
triggerconfig(vid1, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
triggerconfig(vid2, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
src1.AcquisitionStartTriggerActivation = 'FallingEdge';
src2.AcquisitionStartTriggerActivation = 'FallingEdge';
src1.AcquisitionStartTriggerSource = 'Line1';
src2.AcquisitionStartTriggerSource = 'Line1';
preview(vid1, hImage1);
preview(vid2, hImage2);
imaqmem(1000000000000);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes example1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = example1_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
varargout{1} = handles.output;
  2 Comments
Jayant
Jayant on 14 Jun 2021
@Marcel have you found any solution on this issue? as i am having the same issue. Troubling with it.
@Ben Drebing this is not the solution. Its something different issue.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!