ARGear SDK Documentations
  • Introduction
  • Android
    • 1. Quickstart
    • 2. Configuration Settings
    • 3. ARGear Overview
    • 4. ARGSession
    • 5. Camera
    • 6. Rendering
    • 7. CMS Service
    • 8. Download Contents
    • 9. Set Contents
    • 10. Media
    • 11. Switch Camera Face
    • 12. Enable Debugging Mode
    • 13. ARCore Connect API
    • 14. API Reference
  • iOS
    • 1. Quickstart
    • 2. Configuration Settings
    • 3. ARGear Overview
    • 4. ARGSession
    • 5. Camera
    • 6. Rendering
    • 7. CMS Service
    • 8. Download Contents
    • 9. Set Contents
    • 10. Media
    • 11. Switch Camera Face
    • 12. Enable Debugging Mode
    • 13. ARKit Connect API
    • 14. API Reference
  • Unity
    • 1. Quickstart
    • 2. Configuration Settings
    • 3. ARGear Plugin Overview
    • 4. ARGearManager
    • 5. ARGearCamera
    • 6. CMS Service
    • 7. Download Contents
    • 8. Set Contents
    • 9. Switch Camera Face
    • 10. Enable Debugging Mode
    • 11. API Reference
Powered by GitBook
On this page
  • 10.1 Take a Photo
  • 10.2 Record a Video

Was this helpful?

  1. iOS

10. Media

ARGear provides photo capture and video recording features through ARGMedia in ratios of 16:9, 4:3, 1:1.

Before using camera functions, video device information must be provided to ARGMedia Class.

Sample code below shows how to set relevant information.

// Sample Code. Setting Video Device Information in ARGMedia Class

// videoDevice: AVCaptureDevice
// videoDeviceOrientation: AVCaptureVideoOrientation
// videoConnection: AVCaptureConnection
// mediaRatio: ARGMediaRatio
// videoBitrate: ARGMediaVideoBitrate
 
ARGMedia *argMedia = [[ARGMedia alloc] init];
 
[argMedia setVideoDevice:device];
[argMedia setVideoDeviceOrientation:videoDeviceOrientation];
[argMedia setVideoConnection:videoConnection];
[argMedia setMediaRatio:ARGMediaRatio_4x3];
[argMedia setVideoBitrate:ARGMediaVideoBitrate_2M];
// Sample Code. Setting Video Device Information in ARGMedia Class

// videoDevice: AVCaptureDevice
// videoDeviceOrientation: AVCaptureVideoOrientation
// videoConnection: AVCaptureConnection
// mediaRatio: ARGMediaRatio
// videoBitrate: ARGMediaVideoBitrate

var arMedia = ARGMedia()

arMedia.setVideoDevice(arCamera.cameraDevice)
arMedia.setVideoDeviceOrientation(arCamera.cameraConnection.videoOrientation)
arMedia.setVideoConnection(arCamera.cameraConnection)
arMedia.setMediaRatio(._4x3)
arMedia.setVideoBitrate(._2M)

10.1 Take a Photo

Using the takePicture function in ARGMedia, users can take a photo of the current rendered ARGFrame. After a photo is captured, the photo is converted into a UIImage and is accessible in the closure interface.

Sample code below shows how to get the captured photo.

// Sample Code. Getting a Captured Image

UIImageView *imageView = [[UIImageView alloc] init];
[_argMedia takePic:^(UIImage * _Nonnull image) {
    [imageView setImage:image];
}];
// Sample Code. Getting a Captured Image

let imageView = UIImageView(frame: frame)
arMedia.takePic { image in
    imageView.image = image
}

10.2 Record a Video

By calling recordVideoStart and recordVideoStop method in ARGMedia class, you can start or stop video recording. Recorded video must be converted into a NSDictionary.

Sample code below shows how to obtain a recorded video.

// Sample Code. Start and Stop Video Recording

ARGMedia *argMedia = [[ARGMedia alloc] init];
…
 
// Start Video Recording
[argMedia recordVideoStart:^(CGFloat recTime) {
    dispatch_async(dispatch_get_main_queue(), ^{
        // recTime represents recorded time
    });
}];
 
// Stop Video Recording
[argMedia recordVideoStop:^(NSDictionary * _Nonnull videoInfo) {
} save:^(NSDictionary * _Nonnull videoInfo) {
    // converting video data into NSDictionary form
}];
// Sample Code. Start and Stop Video Recording

// Start Video Recording
arMedia.recordVideoStart { (sec) in
    // recTime represents recorded time
}

// Stop Video Recording
arMedia.recordVideoStop({ (videoInfo) in
}) { (resultVideoInfo) in
    // convert video data into NSDictionary form
}

Previous9. Set ContentsNext11. Switch Camera Face

Last updated 5 years ago

Was this helpful?