Created
December 27, 2011 21:10
-
-
Save sld/1525118 to your computer and use it in GitHub Desktop.
Hornetseye motion object bounding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_human_with_place(thresholed_frame, start_frame) | |
components = thresholed_frame.components | |
mask = components.largest.erode(10).conditional(255, 0) | |
x = lazy( *start_frame.shape ) {|i,j| i} | |
y = lazy( *start_frame.shape ) {|i,j| j} | |
if x.mask(mask).empty? || y.mask(mask).empty? | |
return start_frame | |
else | |
x_range = x.mask(mask).range | |
y_range = y.mask(mask).range | |
box = [x_range, y_range] | |
start_frame[*box] = start_frame[ *box ] / 2 + 0x7F | |
return start_frame | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Idris,
Not sure what you ultimately want to do. But you can detect and filter multiple
components of a thresholded difference image as follows:
Note that if two people are next to each other, they would be seen as a single component
though.
Hope it helps.
Regards Jan