MATLAB Answers

Is it possible to show movie from raspberrypi webcamera using matlab guide.

1 view (last 30 days)
I want to know that Matlab guide (GUI) can show movie from raspberrypi USB webcamera.
I have challenged making program, but it doesn't work correctly.
If you know this solution , please tell me.
  2 Comments
PROJECT SR
PROJECT SR on 27 Sep 2017
Thank you John D'Errico
Actually, I tried to find out problem of my program code. But I couldn't do that.
To begin with, I don't know that it is possible to show movie from raspberrypi through USB webcam, so I wrote this question.
If you don't mind, could you tell me how to solve this problem. I'll send code and show error message.
function 'preview' (type'matlab.graphics.primitive.Image' Input arguments) is not defined.
error: webcamtest2>webcamtest2_OpeningFcn (line 62) preview(img1,hImage1);
error: gui_mainfcn (line 220) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
error: webcamtest2 (line 42) gui_mainfcn(gui_State, varargin{:});

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 27 Sep 2017
Change
axes(handles.axes1);
hImage1=image(zeros(352,288,3),'Parent',handles.axes1);
preview(img1,hImage1);
to
imshow(img1, 'Parent', handles.axes1)
  5 Comments
PROJECT SR
PROJECT SR on 1 Oct 2017
Thank you so much Walter Roberson.
I understand. I can display webcamera's video.

Sign in to comment.

More Answers (1)

Niraj Gadakari
Niraj Gadakari on 27 Sep 2017
You can use the snapshot function in a loop and display it in the GUI using Raspberry Pi webcam. Here is a link that discusses acquiring webcam images in a loop.
  1 Comment
PROJECT SR
PROJECT SR on 27 Sep 2017
Thank you Niraj Gadakari
But I want to show web cam movie using matlab guide(GUI). I tried my program code, but error was occured, and I can not find out reason.
If you don't mind, please tell the solution.
code
******************************************************************** function varargout = webcamtest2(varargin)
% WEBCAMTEST2 MATLAB code for webcamtest2.fig
% WEBCAMTEST2, by itself, creates a new WEBCAMTEST2 or raises the existing
% singleton*.
%
% H = WEBCAMTEST2 returns the handle to a new WEBCAMTEST2 or the handle to
% the existing singleton*.
%
% WEBCAMTEST2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WEBCAMTEST2.M with the given input arguments.
%
% WEBCAMTEST2('Property','Value',...) creates a new WEBCAMTEST2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before webcamtest2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to webcamtest2_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 webcamtest2
% Last Modified by GUIDE v2.5 28-Sep-2017 00:24:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @webcamtest2_OpeningFcn, ...
'gui_OutputFcn', @webcamtest2_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 webcamtest2 is made visible.
function webcamtest2_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 webcamtest2 (see VARARGIN)
% Choose default command line output for webcamtest2
handles.output = hObject;
mypi=raspi;
wcam1 = webcam(mypi,'USB 2.0 Camera (usb-3f980000.usb-1.4):')
img1 = snapshot(wcam1);
axes(handles.axes1);
hImage1=image(zeros(352,288,3),'Parent',handles.axes1);
preview(img1,hImage1);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes webcamtest2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = webcamtest2_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;

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!