Sha256: 5207e1b6ce7ef7fe77151be2402ca736d9c5e593f489d178025aeb00ef472690

Contents?: true

Size: 977 Bytes

Versions: 9

Compression:

Stored size: 977 Bytes

Contents

require 'dlib'

image_file = ARGV[0] || 'ext/dlib-19.4/examples/faces/2009_004587.jpg'

# you can download model file from http://dlib.net/files/mmod_human_face_detector.dat.bz2
model_file = 'mmod_human_face_detector.dat'
detector = Dlib::DNNFaceDetector.new(model_file)

puts 'single detections'

img = Dlib::Image.load(image_file)
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}"
end

puts ''
puts 'multiple detections'

image = Dlib::Image.load(image_file)
images = [image, image, image]
results = detector.detect(images)

results.each do |rects|
  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}"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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