How can I input live video from IP webcam to Face counter Code so that i Can get video from my Mobile.?
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
function varargout = count(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @count_OpeningFcn, ...
                   'gui_OutputFcn',  @count_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
% --- Executes just before count is made visible.
function count_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for count
handles.output = hObject;
axes(handles.axes1);
imshow('piet.jpg');
axis off;
set(handles.text2,'string','0');
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = count_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;
% --- Executes on button press in start
function start_Callback(hObject, eventdata, handles)
global vid    
vid = videoinput('winvideo' , 1, 'YUY2_640X480');  %The is the video input from webcam i Want to Replace it with IP webcam Video in the code
function count_Callback(hObject, eventdata, handles)
global vid     
% Set the parameters for video
triggerconfig( vid ,'manual');                                      % the trigger occurs only after the trigger function
set(vid, 'FramesPerTrigger',1);                                     % one frame acquired per trigger
set(vid, 'TriggerRepeat',Inf);                                      % Keep executing the trigger every time the trigger condition is met until the stop function is called 
set(vid,'ReturnedColorSpace','rgb');                                % to get the rgb colour image 
vid.Timeout = 10;
start(vid);  
while (1)  
facedetector = vision.CascadeObjectDetector;                                % Create a cascade detector object                                              
trigger(vid);                                                               %trigger to get the frame from the video
image = getdata(vid);                                                       %store that frame in 'image'
bbox = step(facedetector, image);                                           % position of face in 'bbox' (x, y, width and height)
insert_object = insertObjectAnnotation(image,'rectangle',bbox,'Face');      % Draw the bounding box around the detected face.
imshow(insert_object);
axis off;                                                                   % invisible the axis from GUI
no_rows = size(bbox,1);                                                     % get the number of rows (which will be equal to number of people)
X = sprintf('%d', no_rows);
set(handles.text2,'string',X);                                              %display the value of X in GUI
end
% --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject    handle to stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global vid
stop(vid),clear vid %stop the running video
``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
% Now this is the code for IP Webcam.
url = 'http://<192.168.43.1:8080>/shot.jpg'; %want to give this video to the input of face couter
ss  = imread(url);
fh = image(ss, 'Parent', ax);
while(1)
    ss  = imread(url);
    set(fh,'CData',ss);
    drawnow;
end
0 Commenti
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!