Skip to content

Commit

Permalink
chore: update per review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Nov 29, 2023
1 parent 0ba4247 commit e9276fb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
24 changes: 13 additions & 11 deletions Sources/FaceLiveness/Utilities/CGImage+Convert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import CoreGraphics
import VideoToolbox

extension CGImage {
static func convert(from cvPixelBuffer: CVPixelBuffer?) -> CGImage? {
guard let pixelBuffer = cvPixelBuffer else {
return nil
}
static func convert(from cvPixelBuffer: CVPixelBuffer?) -> CGImage? {
guard let pixelBuffer = cvPixelBuffer else {
return nil
}

var image: CGImage?
VTCreateCGImageFromCVPixelBuffer(
pixelBuffer,
options: nil,
imageOut: &image)
return image
}
var image: CGImage?
VTCreateCGImageFromCVPixelBuffer(
pixelBuffer,
options: nil,
imageOut: &image
)

return image
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct CameraPreviewView: View {

@StateObject var model: CameraPreviewViewModel

public init(model: CameraPreviewViewModel = CameraPreviewViewModel()) {
init(model: CameraPreviewViewModel = CameraPreviewViewModel()) {
self._model = StateObject(wrappedValue: model)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class CameraPreviewViewModel: NSObject, ObservableObject {
super.init()
setupSubscriptions()

let avCpatureDevice = AVCaptureDevice.DiscoverySession(
let avCaptureDevice = AVCaptureDevice.DiscoverySession(
deviceTypes: [.builtInWideAngleCamera],
mediaType: .video,
position: .front
).devices.first

self.previewCaptureSession = LivenessCaptureSession(
captureDevice: .init(avCaptureDevice: avCpatureDevice),
captureDevice: .init(avCaptureDevice: avCaptureDevice),
outputDelegate: self
)

Expand Down
21 changes: 10 additions & 11 deletions Sources/FaceLiveness/Views/GetReadyPage/ImageFrameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ struct ImageFrameView: View {

var body: some View {
if let image = image {
GeometryReader { geometry in
Image(decorative: image, scale: 1.0, orientation: .upMirrored)
.resizable()
.scaledToFill()
.frame(
width: geometry.size.width,
height: geometry.size.height,
alignment: .center)
.clipped()
}
GeometryReader { geometry in
Image(decorative: image, scale: 1.0, orientation: .upMirrored)
.resizable()
.scaledToFill()
.frame(
width: geometry.size.width,
height: geometry.size.height,
alignment: .center)
.clipped()
}
} else {
Color.black
}

}
}

Expand Down

0 comments on commit e9276fb

Please sign in to comment.