Sha256: 0d453492d842307e46ac3cd5656b7b8207ebed6593cb071abcd1a508914a8ecd

Contents?: true

Size: 536 Bytes

Versions: 9

Compression:

Stored size: 536 Bytes

Contents

require 'dlib'

image_file = ARGV[0] || 'ext/dlib-19.4/examples/faces/2009_004587.jpg'
img = Dlib::Image.load(image_file)
detector = Dlib::FrontalFaceDetector.new

rects = detector.detect(img)

puts "number of faces detected #{rects.length}"
rects.each.with_index do |rect, index|
  puts "Detection #{index}: Left: #{rect.left} Top: #{rect.top} Right: #{rect.right} Bottom: #{rect.bottom} Area: #{rect.area}"
  img.draw_rectangle!(rect, [0, 0, 255]) if rect.area > 0
end

output_file = ARGV[1] || 'faces.jpg'
img.save_jpeg(output_file)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dlib-1.2.2 examples/face_detection.rb
dlib-1.2.1 examples/face_detection.rb
dlib-1.2.0 examples/face_detection.rb
dlib-1.1.5 examples/face_detection.rb
dlib-1.1.4 examples/face_detection.rb
dlib-1.1.3 examples/face_detection.rb
dlib-1.1.2 examples/face_detection.rb
dlib-1.1.1 examples/face_detection.rb
dlib-1.1.0 examples/face_detection.rb