Single-camera Mocap Run

This guides you through the process of creating a mocap run when using a single capture input

To create a mocap run you will need to create an instance of MocapRun and provision that through a specific engine class.

However, you will need to go through a specific process to be able to do this:

  1. Define camera settings and capture devices

  2. Create a capture input
    1. We also create a capture

  3. Create a mocap run

1. Define camera settings and capture devices

First you will need to define the capture device that you used

from moveai_mocap.models.captures.capture_device import CaptureDevice

# A capture device is a way of identifying where a camera is during filming.
# camera_settings are not required for single cam (but can be provided if necessary).
# They are intentionally excluded from this example.
capture_device_0 = CaptureDevice(
    device_id="capture_device_0",
)

2. Create a capture input

We need to create a capture input to use as an input to the engine to generate mocap files

from moveai_mocap.models.captures.capture_input import VideoCaptureInput
from moveai_mocap.models.resources.enums.resource_type import ResourceType
from moveai_mocap.models.resources.enums.service import Service
from moveai_mocap.models.resources.resource import Resource

video_capture_input_0 = VideoCaptureInput(
    capture_device=capture_device_0,
    # The Resource defines that this file is stored on S3 and is an input_mp4 type
    input=Resource(
        resource_type=ResourceType.video_capture_input,
        uri="s3://my-bucket/path/to/capture/capture_device_0.mp4",
        service=Service.s3,
    ),
)

Create a capture

from moveai_mocap.models.captures.capture import Capture
capture = Capture(
      inputs=[
          video_capture_input_0
      ],
)

3. Create a mocap run

Now that we’ve defined the capture input we can create a mocap run and provision the engine

from moveai_mocap.models.motion.runs.mocap import MocapRun
from moveai_mocap.models.resources.enums.service import Service
from moveai_mocap.models.resources.resource import Resource
from moveai_mocap.models.resources.enums.resource_type import ResourceType

mocap_run = MocapRun(
    # The capture defined in step 2
    capture=capture,
    number_of_actors=1,
    # Where outputs should be saved. There are many types of output
    # resource
    outputs=[
            Resource(
            resource_type=ResourceType.render_overlay_video,
            uri="s3://my-bucket/path/to/mocap/render_overlay.mp4",
            service=Service.s3,
        )
    ],
)

Provision the engine

from moveai_mocap.compute.ec2 import EC2ComputeManager
from moveai_mocap.models.notifiers.sns import SNSNotifier

sns_notifier = SNSNotifier(
    endpoint="arn:aws:sns:",
    payload={"foo": "bar"},
)

engine = EC2Engine(
    # configure these settings according to your AWS account
    iam_instance_profile_name="instance-profile-name",
    ami_id="ami-12345678",
    subnet_ids=["subnet-1"],
    security_group_ids=["sg-1"],
)
# Calling provision will launch an EC2 instance and generate the output files
# defined on `outputs` on the `mocap_run`
engine.provision(mocap_run)