Sha256: ca6ed477f8653a961da57311da43ded6053276ad2f5c8e14eeaf860402d27975

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

require 'spec_helper'

describe Spyglass::CascadeClassifier do
  let(:classifier) { Spyglass::CascadeClassifier.new(fixture_path('haarcascade_frontalface_default.xml')) }
  let(:lena) { Spyglass::Image.load(fixture_path('lena.jpg')) }

  describe '.new' do
    it 'should receive an argument' do
      expect { Spyglass::CascadeClassifier.new }.to raise_error ArgumentError;
      expect( classifier ).to be_a Spyglass::CascadeClassifier
    end
  end

  describe '.detect' do
    it 'should return an array of Spyglass::Rect' do
      rects = classifier.detect(lena, scale_factor: 1.3)

      expect( rects ).to be_a Array

      rect = rects.first
      expect( rect ).to         be_a Spyglass::Rect
      expect( rect.x ).to       be_close_to 215, threshold: 10
      expect( rect.y ).to       be_close_to 202, threshold: 10
      expect( rect.width ).to   be_close_to 174, threshold: 10
      expect( rect.height ).to  be_close_to 174, threshold: 10
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spyglass-0.0.5.1 spec/spyglass/cascade_classifier_spec.rb
spyglass-0.0.5 spec/spyglass/cascade_classifier_spec.rb
spyglass-0.0.4.1 spec/spyglass/cascade_classifier_spec.rb
spyglass-0.0.4 spec/spyglass/cascade_classifier_spec.rb
spyglass-0.0.3 spec/spyglass/cascade_classifier_spec.rb
spyglass-0.0.2 spec/spyglass/cascade_classifier_spec.rb