Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename = 'Wandeling_1a.mp4';
- hVideoSrc = vision.VideoFileReader(filename, ...
- 'ImageColorSpace', 'Intensity',...
- 'VideoOutputDataType', 'single');
- hBlob = vision.BlobAnalysis( ...
- 'AreaOutputPort', false, ...
- 'BoundingBoxOutputPort', false, ...
- 'OutputDataType', 'single');
- hVideoOut = vision.VideoPlayer('Name', 'Counted Staples');
- hVideoOut.Position(3:4) = [650 350];
- while ~isDone(hVideoSrc)
- I = step(hVideoSrc);
- Im = imtophat(I, strel('square',18));
- Im = imopen(Im, strel('rect',[15 3]));
- th = multithresh(Im); % Determine threshold using Otsu's method
- BW = Im > th;
- Centroids = step(hBlob, BW); % Blob Analysis
- StaplesCount = int32(size(Centroids,1));
- txt = sprintf('Staple count: %d', StaplesCount);
- It = insertText(I,[10 280],txt,'FontSize',22); % Display staples count
- Centroids(:, 2) = Centroids(1,2); % Align markers horizontally
- It = insertMarker(It, Centroids, 'o', 'Size', 6, 'Color', 'r');
- It = insertMarker(It, Centroids, 'o', 'Size', 5, 'Color', 'r');
- It = insertMarker(It, Centroids, '+', 'Size', 5, 'Color', 'r');
- step(hVideoOut, It);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement