CoreML-in-ARKit 项目教程

CoreML-in-ARKit 项目教程

CoreML-in-ARKitSimple project to detect objects and display 3D labels above them in AR. This serves as a basic Template for an ARKit project to use CoreML.项目地址:https://gitcode.com/gh_mirrors/co/CoreML-in-ARKit

1. 项目的目录结构及介绍

CoreML-in-ARKit/
├── CoreML-in-ARKit/
│   ├── AppDelegate.swift
│   ├── Assets.xcassets/
│   ├── Base.lproj/
│   ├── Info.plist
│   ├── SceneDelegate.swift
│   ├── ViewController.swift
│   └── models/
│       └── Resnet50.mlmodel
├── CoreML-in-ARKit.xcodeproj/
│   ├── project.pbxproj
│   ├── project.xcworkspace/
│   └── xcuserdata/
├── CoreML-in-ARKitTests/
│   ├── CoreML-in-ARKitTests.swift
│   └── Info.plist
├── CoreML-in-ARKitUITests/
│   ├── CoreML-in-ARKitUITests.swift
│   └── Info.plist
└── README.md

目录结构介绍

  • CoreML-in-ARKit/: 项目的主要代码文件夹。

    • AppDelegate.swift: 应用程序的入口和生命周期管理。
    • Assets.xcassets/: 存放应用程序的资源文件,如图片。
    • Base.lproj/: 存放应用程序的界面布局文件。
    • Info.plist: 应用程序的配置信息。
    • SceneDelegate.swift: 处理多场景应用程序的场景生命周期。
    • ViewController.swift: 主视图控制器,包含ARKit和CoreML的集成代码。
    • models/: 存放机器学习模型文件。
      • Resnet50.mlmodel: 预训练的ResNet50模型,用于图像识别。
  • CoreML-in-ARKit.xcodeproj/: Xcode项目文件。

    • project.pbxproj: 项目配置文件。
    • project.xcworkspace/: 工作区文件。
    • xcuserdata/: 用户数据文件。
  • CoreML-in-ARKitTests/: 单元测试文件夹。

    • CoreML-in-ARKitTests.swift: 单元测试代码。
    • Info.plist: 单元测试的配置信息。
  • CoreML-in-ARKitUITests/: UI测试文件夹。

    • CoreML-in-ARKitUITests.swift: UI测试代码。
    • Info.plist: UI测试的配置信息。
  • README.md: 项目说明文档。

2. 项目的启动文件介绍

AppDelegate.swift

AppDelegate.swift 是应用程序的入口文件,负责管理应用程序的生命周期。以下是文件的主要内容:

import UIKit
import ARKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if !ARWorldTrackingConfiguration.isSupported {
            fatalError("ARKit is not supported on this device.")
        }
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // 应用程序即将进入非活动状态时调用
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // 应用程序进入后台时调用
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // 应用程序即将进入前台时调用
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // 应用程序成为活动状态时调用
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // 应用程序即将终止时调用
    }
}

SceneDelegate.swift

SceneDelegate.swift 处理多场景应用程序的场景生命周期。以下是文件的主要内容:

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }
    }

    func scene

CoreML-in-ARKitSimple project to detect objects and display 3D labels above them in AR. This serves as a basic Template for an ARKit project to use CoreML.项目地址:https://gitcode.com/gh_mirrors/co/CoreML-in-ARKit

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

戚言玲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值