|
Hi,
I'm doing a project on "Multi Camera Surveillance System ". I've started the project with object tracking using gaussian mixture model and live histogram. I'm trying to incorporate these code into a GUI interface. Now I've been able to start and stop the internal webcamera.
Then I've used a 'pushbutton' as 'Track' which tracks the object. The problem arises here. I'm using Computer vision inbuilt functions for object tracking. So, when I paste the same code into my 'pushbutton_callback' function, I get a error.
The same happens when I try to see live histogram on GUI....Can you please help me?
The function below is for Object tracking...
function track_Callback(hObject, eventdata, handles)
% hObject handle to track (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(handles.track,'String'),'Track')
set(handles.track,'String','Stop Tracking');
trigger(handles.video);
%object tracking using gaussina mixture model
hcsc = hObject;
hof = vision.ForegroundDetector(...
'NumTrainingFrames', 5, ... % only 5 because of short video
'InitialVariance', (30/255)^2); % initial standard deviation of 30/255
hblob = vision.BlobAnalysis( ...
'CentroidOutputPort', false, ...
'AreaOutputPort', true, ...
'BoundingBoxOutputPort', true, ...
'OutputDataType', 'single', ...
'NumBlobsOutputPort', false, ...
'MinimumBlobAreaSource', 'Property', ...
'MinimumBlobArea', 250, ...
'MaximumBlobAreaSource', 'Property', ...
'MaximumBlobArea', 3600, ...
'FillValues', -1, ...
'MaximumCount', 80);
hshapeins1 = vision.ShapeInserter( ...
'BorderColor', 'Custom', ...
'CustomBorderColor', [0 255 0]);
hshapeins2 = vision.ShapeInserter( ...
'Shape','Lines', ...
'BorderColor', 'Custom', ...
'CustomBorderColor', [255 255 0])
htextins = vision.TextInserter( ...
'Text', 'Tracking in progress...', ...
'Location', [10 10], ...
'Color', [255 0 0], ...
'FontSize', 12);
sz = get(0,'ScreenSize');
pos = [20 sz(4)-300 200 200];
hVideoOrig = vision.VideoPlayer('Name', 'Original', 'Position', pos);
pos(1) = pos(1)+220; % move the next viewer to the right
hVideoFg = vision.VideoPlayer('Name', 'Foreground', 'Position', pos);
pos(1) = pos(1)+220;
hVideoRes = vision.VideoPlayer('Name', 'Results', 'Position', pos);
line_row = 22; % Define region of interest (ROI)
while ~isDone(hcsc)
y=step(hcsc);% Read input video frame
image = step(hcsc); % for display purposes
% Remove the effect of sudden intensity changes due to camera's
% auto white balancing algorithm.
y = im2single(y);
y = y-mean(y(:));
fg_image = step(hof, y); % Foreground
% Estimate the area and bounding box of the blobs in the foreground image.
[area, bbox] = step(hblob, fg_image);
Idx = bbox(1,:) > line_row; % Select boxes which are in the ROI.
% Based on dimensions, exclude objects which are not cars. When the
% ratio between the area of the blob and the area of the bounding box
% is above 0.4 (40%) classify it as a car.
ratio = zeros(1, length(Idx));
ratio(Idx) = single(area(1,Idx))./single(bbox(3,Idx).*bbox(4,Idx));
ratiob = ratio > 0.4;
count = int32(sum(ratiob));% Number of cars
bbox(:, ~ratiob) = int32(-1);
% Draw bounding rectangles around the detected cars.
y2x = step(hshapeins1, image, bbox);
% Display the number of cars tracked and a white line showing the ROI.
y2(22:23,:,:) = 255;% White line
y2(1:15,1:30,:) = 0;% Black background for displaying count
image_out = step(htextins, y2,count);
step(hVideoOrig, image);% Original video
step(hVideoFg, fg_image);% Foreground
step(hVideoRes, image_out);% Bounding boxes around cars
end
% Close the video file
release(hcsc);
else
stop(handles.video);
disp('Tracked');
start(handles.video); % Restart the camera
set(handles.track,'String','Track');
end
ERROR=>Undefined function or method 'isDone' for input arguments of type 'double'.
|