Skip to content

Commit

Permalink
Testflight - v1.0 (#4)
Browse files Browse the repository at this point in the history
* Front inicial

- Definindo os emojis
- Atributos necessários criados na teal principal
- Classe costumizada para criação de views

* Mudanças MainView

- add constraints
-criação botao start

* photos view

photos view criada!

* Finalizando tela principal

- Reestruturando código
- Add novos botões na tela

* add expressions

add expressions para cada emoji

* icones

add icones no assets

* mudancas expressoes

* Finalizando tela de resultado

Add botão de troca de emoji

* Criando a lógica principal

- Add no Testflight

Co-authored-by: Gabriele Namie <[email protected]>
Co-authored-by: Gabriele Namie <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2022
1 parent ec7a3b2 commit f21c206
Show file tree
Hide file tree
Showing 34 changed files with 1,527 additions and 133 deletions.
126 changes: 126 additions & 0 deletions Nano05-AR/Nano05-AR/Complemets/ExpressionAnalysis.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//
// ExpressionAnalysis.swift
// Nano05-AR
//
// Created by Gui Reis on 08/06/22.
//
import ARKit


class ExpressionAnalysis {

/* MARK: - Atributos */

/// Analise da expressão
private var analysis = ""



/* MARK: - Métodos */


/// Compara se a expressão é o emoji em si
private func compareExpression(to emoji: Emojis, with anchor: ARFaceAnchor) -> Bool {

let innerUp = self.getExpressionValue(with: .browInnerUp, for: anchor) > 0.1
let cheekPuff = self.getExpressionValue(with: .cheekPuff, for: anchor) > 0.1

// 😗
let mouthPucker = self.getExpressionValue(with: .mouthPucker, for: anchor) > 0.3


// 😛
let tongueOut = self.getExpressionValue(with: .tongueOut, for: anchor) > 0.3

// ☹️
let frownLeft = self.getExpressionValue(with: .mouthFrownLeft, for: anchor) > 0.1
let frownRight = self.getExpressionValue(with: .mouthFrownRight, for: anchor) > 0.1


// 😃
let smileLeft = self.getExpressionValue(with: .mouthSmileLeft, for: anchor) > 0.2
let smileRight = self.getExpressionValue(with: .mouthSmileRight, for: anchor) > 0.2
let jawOpen = self.getExpressionValue(with: .jawOpen, for: anchor) > 0.2


// 😏
let lookInLeft = self.getExpressionValue(with: .eyeLookInLeft, for: anchor) > 0.1
let lookInRight = self.getExpressionValue(with: .eyeLookInRight, for: anchor) > 0.1


// 😒
if lookInLeft && lookInRight && frownLeft && frownRight {
self.analysis += "rancorozinho"
}


// 😮 🤔
let outerUpLeft = self.getExpressionValue(with: .browOuterUpLeft, for: anchor) > 0.1
let outerUpRight = self.getExpressionValue(with: .browOuterUpRight, for: anchor) > 0.1

if outerUpLeft && outerUpRight && frownLeft && frownRight && !innerUp {
self.analysis += "pensandinho"
}

// ☺️
let blinkRight = self.getExpressionValue(with: .eyeBlinkRight, for: anchor) > 0.1
let blinkLeft = self.getExpressionValue(with: .eyeBlinkLeft, for: anchor) > 0.1

// 🙄
let lookUpLeft = self.getExpressionValue(with: .eyeLookUpLeft, for: anchor) > 0.1
let lookUpRight = self.getExpressionValue(with: .eyeLookUpRight, for: anchor) > 0.1

// 🥺 🤢

switch emoji {
case .piscadinha:
return false
case .linguinha:
return tongueOut
case .beijinho:
return mouthPucker && !innerUp
case .tristinho:
return frownLeft && frownRight && !innerUp
case .contentizinho:
return smileLeft && smileRight && jawOpen && !tongueOut
case .surpresinho:
return self.getExpressionValue(with: .jawOpen, for: anchor) > 0.5
case .boiolinha:
return innerUp && blinkLeft && blinkRight && smileLeft && smileRight
case .dozinha:
return false
case .tediozinho:
return innerUp && lookUpLeft && lookUpRight
case .safadinho:
return smileRight && lookInLeft && lookInRight
case .chateadinho:
return innerUp && frownRight && frownLeft
case .enjoadinho:
return cheekPuff && innerUp && !mouthPucker
}


}

/// Analisa uma determinada expressão
public func getExpressionAnalysis(with anchor: ARAnchor) -> Emojis? {
for emoji in MainViewController.emojisSelected {
let faceAnchor = ARFaceAnchor(anchor: anchor)
if self.compareExpression(to: emoji, with: faceAnchor) {
return emoji
}
}
return nil
}


/// Pega o valor de uma determinada expressão
private func getExpressionValue(with expression: ARFaceAnchor.BlendShapeLocation, for anchor: ARFaceAnchor) -> Decimal {
let expression = anchor.blendShapes[expression]

if let value = expression?.decimalValue {
return value
}
return -1
}
}
Loading

0 comments on commit f21c206

Please sign in to comment.