Advertisement
Guest User

NOWWWWWWWWW

a guest
Oct 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. filename = 'Wandeling_1a.mp4';
  2. hVideoSrc = vision.VideoFileReader(filename, ...
  3. 'ImageColorSpace', 'Intensity',...
  4. 'VideoOutputDataType', 'single');
  5. hBlob = vision.BlobAnalysis( ...
  6. 'AreaOutputPort', false, ...
  7. 'BoundingBoxOutputPort', false, ...
  8. 'OutputDataType', 'single');
  9.  
  10. hVideoOut = vision.VideoPlayer('Name', 'Counted Staples');
  11. hVideoOut.Position(3:4) = [650 350];
  12.  
  13. while ~isDone(hVideoSrc)
  14. I = step(hVideoSrc);
  15. Im = imtophat(I, strel('square',18));
  16. Im = imopen(Im, strel('rect',[15 3]));
  17. th = multithresh(Im); % Determine threshold using Otsu's method
  18. BW = Im > th;
  19. Centroids = step(hBlob, BW); % Blob Analysis
  20.  
  21. StaplesCount = int32(size(Centroids,1));
  22. txt = sprintf('Staple count: %d', StaplesCount);
  23. It = insertText(I,[10 280],txt,'FontSize',22); % Display staples count
  24.  
  25. Centroids(:, 2) = Centroids(1,2); % Align markers horizontally
  26.  
  27. It = insertMarker(It, Centroids, 'o', 'Size', 6, 'Color', 'r');
  28. It = insertMarker(It, Centroids, 'o', 'Size', 5, 'Color', 'r');
  29. It = insertMarker(It, Centroids, '+', 'Size', 5, 'Color', 'r');
  30.  
  31. step(hVideoOut, It);
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement