forked from WeTransfer/WeScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageFeatureTestHelpers.swift
38 lines (29 loc) · 1.08 KB
/
ImageFeatureTestHelpers.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// ImageFeatureTestHelpers.swift
// WeScanTests
//
// Created by Boris Emorine on 2/24/18.
// Copyright © 2018 WeTransfer. All rights reserved.
//
import UIKit
import AVFoundation
@testable import WeScan
enum ResourceImage: String {
case rect1 = "Square.jpg"
case rect2 = "Rectangle.jpg"
case rect3 = "BigRectangle.jpg"
}
final class ImageFeatureTestHelpers: NSObject {
static func getRectangleFeatures(from resourceImage: ResourceImage, withCount count: Int) -> [Quadrilateral] {
var rectangleFeatures = [Quadrilateral]()
for _ in 0 ..< count {
rectangleFeatures.append(ImageFeatureTestHelpers.getRectangleFeature(from: resourceImage))
}
return rectangleFeatures
}
static func getRectangleFeature(from resourceImage: ResourceImage) -> Quadrilateral {
let image = UIImage(named: resourceImage.rawValue, in: Bundle(for: ImageFeatureTestHelpers.self), compatibleWith: nil)
let ciImage = CIImage(image: image!)!
return CIRectangleDetector.rectangle(forImage: ciImage)!
}
}