Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/developeracademy-postech/2024-nc2-a30-video

SNOOQ
https://github.com/developeracademy-postech/2024-nc2-a30-video

Last synced: about 10 hours ago
JSON representation

SNOOQ

Awesome Lists containing this project

README

        

# 2024-NC2-A30-Video
![NC2 Slide 16_9 (1)](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-A30-Video/assets/71865277/0787f073-6a79-4014-9f36-a838d4e0a444)

## πŸŽ₯ Youtube Link
(μΆ”ν›„ λ§Œλ“€μ–΄μ§„ 유튜브 링크 μΆ”κ°€)


## πŸ’‘ About Video

- μ˜μƒμ„ λ‹€λ£¨λŠ” Video에 μ–΄λ–€ κΈ°μˆ λ“€μ΄ μžˆλŠ”μ§€ μ•Œκ²Œ λ˜μ—ˆλ‹€.
- AVKit을 ν™œμš©ν•˜λ©΄ μžλ§‰, μΊ‘μ…˜, 속도 쑰절 λ“±μ˜ κΈ°λŠ₯을 가진 Media Playback(μ˜μƒ ν”Œλ ˆμ΄μ–΄)κ³Ό PiP(Picture in Picture)λ₯Ό κ΅¬ν˜„ν•  수 μžˆλ‹€λŠ” 것을 μ•Œκ²Œ λ˜μ—ˆλ‹€.
- AVKit의 AVPlayer와 AVPlayerViewControllerλ₯Ό ν™œμš©ν•΄μ„œ ν”Œλ ˆμ΄μ–΄λ₯Ό κ΅¬ν˜„ν•  수 있게 λ˜μ—ˆλ‹€.


## 🎯 What I focus on?
- ARKit을 ν™œμš©ν•˜μ—¬ ARSessionκ³Ό EyeTracking을 톡합
- AVKit을 μ΄μš©ν•΄ λ™μ˜μƒ ν”Œλ ˆμ΄μ–΄λ₯Ό κ΅¬ν˜„
- μ‚¬μš©μžμ˜ 눈 μ›€μ§μž„κ³Ό 눈 κΉœλ°•μž„μ„ κ°μ§€ν•˜μ—¬ μ˜μƒμ„ μ œμ–΄ν•˜λŠ” κΈ°μˆ μ„ μ€‘μ μ μœΌλ‘œ λ‹€λ£Έ


## πŸ’Ό Use Case
> μ‚¬μš©μžκ°€ 였λ₯Έμͺ½μœΌλ‘œ λˆˆμ„ 움직이면 μžλ™μœΌλ‘œ λ‹€μŒ λ™μ˜μƒμ΄ μž¬μƒλ˜λ©°, 눈 κΉœλ°•μž„μ„ κ°μ§€ν•˜μ—¬ μΌμ‹œμ •μ§€ λ˜λŠ” μž¬μƒμ„ μ œμ–΄ν•  수 μžˆλ‹€.
- μš”λ¦¬ μ€‘μ΄κ±°λ‚˜, ν™ˆνŠΈλ₯Ό ν•˜κ±°λ‚˜, ν•„κΈ°ν•˜λ©΄μ„œ μ˜μƒμ„ λ³Ό λ•Œμ™€ 같은 μƒν™©μ—μ„œ μœ μš©ν•¨
- 손이 λΆˆνŽΈν•œ μ‚¬λžŒλ“€μ΄ ν•Έμ¦ˆν”„λ¦¬ μ»¨νŠΈλ‘€μ„ μ‰½κ²Œ ν•  수 μžˆλ„λ‘ λ„μšΈ 수 있음


## πŸ–ΌοΈ Prototype
![NC2 Mockups](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-A30-Video/assets/71865277/a6c117e4-c9ed-4b9f-acf1-c8b20432f512)
- 메인 ν™”λ©΄μ—μ„œ κ°„λ‹¨ν•œ μ˜¨λ³΄λ”© 문ꡬλ₯Ό 확인할 수 μžˆλ‹€.
- **μ‹œμž‘ν•˜κΈ°** λ²„νŠΌμ„ 눌러 μ˜μƒ μ‹œμ²­μ„ μ‹œμž‘ν•œλ‹€.
- μ˜μƒμ˜ μ‹œκ°„μ΄ λ‹€ 되면 λ‹€μŒ μ˜μƒμœΌλ‘œ μžλ™μœΌλ‘œ λ„˜μ–΄κ°„λ‹€.
- λ‹€λ§Œ 쀑간에 λ‹€μŒ μ˜μƒμœΌλ‘œ μ΄λ™ν•˜κ³  싢을 경우, 눈치λ₯Ό 보듯 πŸ‘€ **였λ₯Έμͺ½ 끝으둜 μ‹œμ„ μ„ λ‘μ—ˆλ‹€ λŒμ•„μ˜€λ©΄** λ‹€μŒμœΌλ‘œ λ„˜κΈΈ 수 μžˆλ‹€.


## πŸ› οΈ About Code
이번 ν”„λ‘œμ νŠΈμ—μ„œλŠ” AVKitκ³Ό ARKit을 ν™œμš©ν•˜μ—¬ μ‚¬μš©μžμ˜ 눈 μ›€μ§μž„κ³Ό κΉœλ°•μž„μœΌλ‘œ μ˜μƒμ„ μ œμ–΄ν•˜λŠ” κΈ°λŠ₯을 κ΅¬ν˜„ν–ˆλ‹€.

### AVKit을 ν™œμš©ν•œ λ™μ˜μƒ ν”Œλ ˆμ΄μ–΄ κ΅¬ν˜„

**AVPlayer와 AVPlayerViewController μ„€μ •**
```swift
var player: AVPlayer?
var playerController: AVPlayerViewController?

@objc func playVideo() {
guard currentVideoIndex < videos.count else {
currentVideoIndex = 0
return
}

let videoName = videos[currentVideoIndex]
guard let path = Bundle.main.path(forResource: videoName, ofType: "mp4") else {
debugPrint("MP4 Not Found")
return
}

let url = URL(fileURLWithPath: path)
let playerItem = AVPlayerItem(url: url)

NotificationCenter.default.addObserver(self, selector: #selector(videoDidEnd), name: .AVPlayerItemDidPlayToEndTime, object: playerItem)

player = AVPlayer(playerItem: playerItem)
playerController = AVPlayerViewController()
playerController?.player = player

present(playerController!, animated: true) {
self.player?.play()
}

startSession()
}
```

### ARKitκ³Ό EyeTracking을 ν†΅ν•œ 눈 μ›€μ§μž„ 감지

**μ„Έμ…˜ μ„€μ • 및 μ‹œμž‘**
```swift
func setupARSession() {
session = ARSession()
session.delegate = self

let configuration = ARFaceTrackingConfiguration()
configuration.isLightEstimationEnabled = true
session.run(configuration, options: [])
}

@objc func startSession() {
eyeTracking?.startSession()
eyeTracking?.showPointer()

let configuration = ARFaceTrackingConfiguration()
configuration.isLightEstimationEnabled = true
session.run(configuration, options: [])
}

@objc func endSession() {
eyeTracking?.hidePointer()
eyeTracking?.endSession()

session.pause()
}
```

**눈 μ›€μ§μž„μ„ ν†΅ν•œ λ™μ˜μƒ μ œμ–΄**
```swift
@objc func checkGazePosition() {
guard let currentSession = eyeTracking?.currentSession, let lastGaze = currentSession.scanPath.last else { return }

if lastGaze.x < 0 {
print("Gaze exited to the right")
endSession()
playNextVideo()
}
}
```