Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/snapchat/camera-kit-ios-sdk

Camera Kit SDK for iOS
https://github.com/snapchat/camera-kit-ios-sdk

ar augmented-reality camera camera-kit ios lens lens-studio lenses mobile snap snapchat

Last synced: 3 months ago
JSON representation

Camera Kit SDK for iOS

Awesome Lists containing this project

README

        



![camerakit_icon](https://github.com/user-attachments/assets/036e42d2-c99f-45bc-ac0a-fe2fc462b6eb)

# Camera Kit for iOS

[Home Page](https://developers.snap.com/camera-kit/home) | [Documentation & Guides](https://developers.snap.com/camera-kit/getting-started/what-is-camera-kit) | [Showcase](https://ar.snap.com/camera-kit) | [API Reference](https://kit.snapchat.com/reference/CameraKit/ios/1.34.0/index.html) | [Developer Portal](https://kit.snapchat.com/manage/) | [My Lenses](https://my-lenses.snapchat.com/) | [Discord](https://discord.gg/snapar)

Camera Kit brings the power of Snap's AR platform to your websites and mobile apps on iOS and Android. It has never been easier to create and deliver scalable, multi-platform AR experiences to meet your customers, wherever they are.


distort
hair_simulation
try_on
3d_hand_tracking
wrist_wear_try_on
eye_wear_try_on
true_size_object
vfx
landmarkers

## Features

### AR Capabilities
- Face Effects
- Body / Face / Hand Tracking
- World Tracking
- Background Segmentation
- Location AR
- and [many more](https://developers.snap.com/camera-kit/ar-content/ar-overview)

### iOS SDK
- Integrate with AVCaptureSession, which allows to maintain full control over session configuration, management, and lifecycle
- Fetch and display your lenses
- Capture media
- Leverage Reference UI modules to quickly build Camera Kit based experiences
- Supports iOS 13.0+

## Integration Steps
1. [Setup](https://developers.snap.com/camera-kit/getting-started/setting-up-accounts) your Camera Kit application using [Developer Portal](https://kit.snapchat.com/manage)
2. [Integrate](https://developers.snap.com/camera-kit/integrate-sdk/mobile/ios) Camera Kit SDK into your iOS application
3. [Create](https://developers.snap.com/camera-kit/ar-content/build-lenses) AR experiences using [Lens Studio](https://ar.snap.com/lens-studio) and manage them using [My Lenses](https://my-lenses.snapchat.com/) site

## Modules

A core module that handles AR experiences:
- `SCSDKCameraKit`

A set of [open-sourced](./Sources), reusable UI components and utilities for easier development of Camera Kit based experiences:
- `SCSDKCameraKitReferenceUI`
- `SCSDKCameraKitReferenceSwiftUI`

Modules required for testing your in-development lenses (see [Push-to-Device](https://developers.snap.com/camera-kit/guides/mobile-customization/in-app-lens-testing)):
- `SCSDKCameraKitBaseExtension`
- `SCSDKCameraKitLoginKitAuth`
- `SCSDKCameraKitPushToDeviceExtension`

## Installation
### [Swift Package Manager](https://github.com/apple/swift-package-manager)
1. In Xcode, select "File" → "Swift Packages" → "Add Package Dependency"
2. Enter the repository URL: `https://github.com/Snapchat/camera-kit-ios-sdk.git`
3. Select the version and modules you want to use in your project

### [CocoaPods](https://cocoapods.org/)
If you use CocoaPods to manage your dependencies, simply add the following to your `Podfile`:
```ruby
pod 'SCCameraKit'
```

If you'd like to use the Reference UI:

```ruby
pod 'SCCameraKitReferenceUI'
pod 'SCCameraKitReferenceSwiftUI'
```

### Manual
1. Download the binaries from the [Releases](https://github.com/Snapchat/camera-kit-ios-sdk/releases) section
2. Unzip and add the Camera Kit SDK .xcframework to your Xcode project
3. In your target's "General" settings, add the framework to the "Frameworks, Libraries, and Embedded Content" section

## Usage
You can find a more detailed tutorial [here](https://developers.snap.com/camera-kit/guides/tutorials/mobile-tutorials/building-your-first-ios-camera-kit-app)

### Initializing Camera Kit
Obtain an API token for your Camera Kit application on [Developer Portal](https://kit.snapchat.com/manage)

```swift
import SCSDKCameraKit

let sessionConfig = SessionConfig(apiToken: "")
let lensesConfig = LensesConfig(cacheConfig: CacheConfig(lensContentMaxSize: 150*1024*1024))

let cameraKit = Session(sessionConfig: sessionConfig, lensesConfig: lensesConfig, errorHandler: self)
```

### Implementing Camera View
```swift
// Configure the camera preview view
let previewView = PreviewView()
previewView.automaticallyConfiguresTouchHandler = true
cameraKit.add(output: previewView)

// Configure the capture session
let captureSession = AVCaptureSession()
let input = AVSessionInput(session: captureSession)
let arInput = ARSessionInput()
cameraKit.start(input: input, arInput: arInput)

DispatchQueue.global(qos: .background).async {
input.startRunning()
}
```

### Applying AR Lens
You can find lens group IDs and specific lens IDs on [My Lenses](https://my-lenses.snapchat.com/) site
```swift
// Observe a particular lens
cameraKit.lenses.repository.addObserver(self, specificLensID: "", inGroupID: "")

// Implement LensRepositorySpecificObserver to receive observed Lens object
extension MyViewController: LensRepositorySpecificObserver {
func repository(_ repository: LensRepository, didUpdate lens: Lens, forGroupID groupID: String) {
lensQueue.async { [weak self] in
guard let self = self else { return }

// Apply a lens, which makes it visible on previewView
self.cameraKit.lenses.processor?.apply(lens: lens, launchData: nil) { success in
if success {
print("\\(lens.name ?? "Unnamed") (\\(lens.id)) Applied")
} else {
print("Lens failed to apply")
}
}
}
}

func repository(_ repository: LensRepository, didFailToUpdateLensID lensID: String, forGroupID groupID: String, error: Error?) {
// Handle errors
}
}
```

## Samples
We provide several sample apps that demonstrate different approaches to integrating the Camera Kit SDK:
- [CameraKitBasicSample](./Samples/CameraKitBasicSample) implements the bare minimum to show a single lens
- [CameraKitSample](./Samples/CameraKitSample) contains a fully functioning camera capture with lenses and preview flow
- [CameraKitAlternateCarouselSample](./Samples/CameraKitAlternateCarouselSample) demonstrates how to build your own carousel and preview screen

## License
Camera Kit for iOS is available under a custom license. See the [LICENSE](./LICENSE) file for more info.

## Contributing
We welcome contributions to the open-sourced parts of Camera Kit for iOS - Reference UI and Sample Apps. Feel free to open issues and submit PRs.

## Changelog
See [CHANGELOG.md](CHANGELOG.md) for details on each release.