PyObjC ARKit Framework

12.1 · active · verified Wed Apr 15

This library provides Python bindings for Apple's ARKit framework, enabling Python applications to leverage Augmented Reality capabilities on macOS and iOS. The current version is 12.1, with releases typically tied to macOS SDK updates, introducing major versions for new macOS support and minor versions for bug fixes and incremental SDK changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import key ARKit classes like `ARSession` and `ARWorldTrackingConfiguration` using PyObjC. It shows basic object instantiation and checks for ARKit availability, which is crucial as it's an Apple-specific framework. The example also calls a class method (`isSupported()`) to illustrate interaction with the underlying Objective-C API.

import objc
from ARKit import ARSession, ARWorldTrackingConfiguration
from Foundation import NSObject # Useful for general Cocoa classes

# ARKit is a macOS/iOS framework, so check for its presence
if not objc.is_defined('ARSession'):
    print("ARKit framework is not available on this system or macOS version.")
else:
    print("ARKit framework is available.")
    
    # Allocate and initialize an ARSession
    session = ARSession.alloc().init()
    print(f"Created ARSession object: {session}")
    
    # Create a configuration for the session
    config = ARWorldTrackingConfiguration.new()
    print(f"Created ARWorldTrackingConfiguration object: {config}")
    
    # Check if ARSession is supported on the device
    is_supported = ARSession.isSupported()
    print(f"ARSession.isSupported(): {is_supported}")
    
    # In a full application, you would run the session like this:
    # session.runWithConfiguration_(config)
    # print("ARSession started.")

view raw JSON →