- SeSAC AI를 활용한 iOS 앱개발 과정 하업서
- AR활용 이미지 인식·검출·추적·증강 및 ChatGPT API 활용 이미지 검색·결과 출력 기능 개발
- UIKit
- ARKit
- RealityKit
- Combine
- CoreImage
- Vision
- ChatGPT Vision API
- Google Custom Search API
-
마커 등록 asset에 ARResourc를 통해서 등록했습니다.
-
이미지 인식 및 앵커 생성
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
for anchor in anchors {
guard let imageAnchor = anchor as? ARImageAnchor else { return }
handleImageAnchor(imageAnchor)
}
}- 이미지 트래킹
func resetTracking() {
guard let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) else { return }
arConfiguration.trackingImages = referenceImages
arView.session.run(arConfiguration, options: [.resetTracking, .removeExistingAnchors])
}- 이미지 추출 - 이미지 모서리 꼭지점 계산
guard let topLeft = arView.project(imageAnchorPosition + SIMD3<Float>(-referenceImageWidth/2, referenceImageHeight/2, 0)),
let bottomLeft = arView.project(imageAnchorPosition + SIMD3<Float>(-referenceImageWidth/2, -referenceImageHeight/2, 0)),
let topRight = arView.project(imageAnchorPosition + SIMD3<Float>(referenceImageWidth/2, referenceImageHeight/2, 0)),
let bottomRight = arView.project(imageAnchorPosition + SIMD3<Float>(referenceImageWidth/2, -referenceImageHeight/2, 0)) else { return }- 이미지 왜곡 보정 - CIImage
private func cropImageForPoints(image: CIImage, topLeft: CGPoint, topRight: CGPoint, bottomLeft: CGPoint, bottomRight: CGPoint) -> CIImage? {
let perspectiveTransformFilter = CIFilter.perspectiveCorrection()
perspectiveTransformFilter.inputImage = image
perspectiveTransformFilter.topLeft = CGPoint(x: topLeft.x - 10, y: image.extent.size.height - topLeft.y + 40)
perspectiveTransformFilter.topRight = CGPoint(x: topRight.x - 35, y: image.extent.size.height - topRight.y + 40)
perspectiveTransformFilter.bottomLeft = CGPoint(x: bottomLeft.x - 10, y: image.extent.size.height - bottomLeft.y + 30)
perspectiveTransformFilter.bottomRight = CGPoint(x: bottomRight.x - 35, y: image.extent.size.height - bottomRight.y + 30)
return perspectiveTransformFilter.outputImage!
}-
네트워크 통신 클린 아키텍처와 Combine을 결합하여 통신을 구현했습니다. Data Layer내부 파일들을 확인 바랍니다.
-
유사도 측정 ImageSimilarityAnalyzer에서 애플 Vision 프레임워크를 활용해서 이미지 간의 유사도 거리를 측정합니다.
- 동봉된 Marker를 Asset ARResource에 등록하여 활용 (기본 printed 이미지 마커 등록되어 있음)