Skip to content

Commit

Permalink
the right way of ruby?
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Oct 22, 2010
1 parent ae5f897 commit ad91177
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions bin/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
if !truth[name]
truth[name] = Array.new
end
truth[name].push({ :leftEye => { :x => args[1].to_f, :y => args[2].to_f },
:rightEye => { :x => args[3].to_f, :y => args[4].to_f },
truth[name].push({ :left_eye => { :x => args[1].to_f, :y => args[2].to_f },
:right_eye => { :x => args[3].to_f, :y => args[4].to_f },
:nose => { :x => args[5].to_f, :y => args[6].to_f },
:leftMouth => { :x => args[7].to_f, :y => args[8].to_f },
:centerMouth => { :x => args[9].to_f, :y => args[10].to_f },
:rightMouth => { :x => args[11].to_f, :y => args[12].to_f } })
:left_mouth => { :x => args[7].to_f, :y => args[8].to_f },
:center_mouth => { :x => args[9].to_f, :y => args[10].to_f },
:right_mouth => { :x => args[11].to_f, :y => args[12].to_f } })
total += 1
end

Expand All @@ -44,12 +44,18 @@
height *= 1.5
outlier = true
truth[name].each do |face|
if (face[:leftEye][:x] > x && face[:leftEye][:x] < x + width && face[:leftEye][:y] > y && face[:leftEye][:y] < y + height &&
face[:rightEye][:x] > x && face[:rightEye][:x] < x + width && face[:rightEye][:y] > y && face[:rightEye][:y] < y + height &&
face[:nose][:x] > x && face[:nose][:x] < x + width && face[:nose][:y] > y && face[:nose][:y] < y + height &&
face[:leftMouth][:x] > x && face[:leftMouth][:x] < x + width && face[:leftMouth][:y] > y && face[:leftMouth][:y] < y + height &&
face[:centerMouth][:x] > x && face[:centerMouth][:x] < x + width && face[:centerMouth][:y] > y && face[:centerMouth][:y] < y + height &&
face[:rightMouth][:x] > x && face[:rightMouth][:x] < x + width && face[:rightMouth][:y] > y && face[:rightMouth][:y] < y + height)
if (face[:left_eye][:x] > x && face[:left_eye][:x] < x + width &&
face[:left_eye][:y] > y && face[:left_eye][:y] < y + height &&
face[:right_eye][:x] > x && face[:right_eye][:x] < x + width &&
face[:right_eye][:y] > y && face[:right_eye][:y] < y + height &&
face[:nose][:x] > x && face[:nose][:x] < x + width &&
face[:nose][:y] > y && face[:nose][:y] < y + height &&
face[:left_mouth][:x] > x && face[:left_mouth][:x] < x + width &&
face[:left_mouth][:y] > y && face[:left_mouth][:y] < y + height &&
face[:center_mouth][:x] > x && face[:center_mouth][:x] < x + width &&
face[:center_mouth][:y] > y && face[:center_mouth][:y] < y + height &&
face[:right_mouth][:x] > x && face[:right_mouth][:x] < x + width &&
face[:right_mouth][:y] > y && face[:right_mouth][:y] < y + height)
outlier = false
break
end
Expand Down

0 comments on commit ad91177

Please sign in to comment.