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. Android

10. Media

ARGear provides image or video capture through ARGMedia. Users can take a photo or shoot a video in the available ratios, 16:9, 4:3, 1:1.

10.1 Take a Photo

Using the takePicture function in ARGMedia, users can take a photo.

The function must be called in gl thread environment.

Sample code is written below.

ARGMedia argmedia = new ARGMedia(argsession);

GLView.GLViewListener glViewListener = new GLView.GLViewListener() {

    @Override
    public void onDrawFrame(GL10 gl, int width, int height) {

        ARGFrame frame = mARGSession.drawFrame(gl, width, height);
        if (argmedia != null) {
            if (mIsShooting) {
                String path = Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".jpg";
                argmedia.takePicture(frame.getTextureId(), path, ARGMedia.Ratio.RATIO_4_3);
            }
        }

    }
};
var argmedia = ARGMedia(argsession)

override fun onDrawFrame(gl: GL10?, width: Int?, height: Int?) {

    val localWidth = width ?: 0
    val localHeight = height ?: 0
    val frame = argsession.drawFrame(gl, localWidth, localHeight)
    frame?.let {
        if (isShooting) {
            val path = mediaPath + "/" + System.currentTimeMillis() + ".jpg"
            argmedia.takePicture(textureId, path, ARGMedia.Ratio.RATIO_4_3)
        }
    }
    
}

10.2 Record a Video

ARGMedia provides several functions to record a video. Through the functions you can control bitrate, silent mode, and video frame size ratio.

Sample code to record a video is written below.

ARGMedia argmedia = new ARGMedia(argsession);

private void startRecording() {
    int bitrate = 10 * 1000 * 1000; // 10M
    int [] previewSize = mCamera.getPreviewSize();
    mVideoFilePath = Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".mp4";

   // Initiate Recorder
    argmedia.initRecorder(mVideoFilePath, 
                                        previewSize[0], previewSize[1], bitrate,
                                        false, false, false, ARGMedia.Ratio.RATIO_4_3);
    // Start Recording
    argmedia.startRecording();
}

private void stopRecording() {
    // Stop Recording
    argmedia.stopRecording();
}

GLView.GLViewListener glViewListener = new GLView.GLViewListener() {

    @Override
    public void onDrawFrame(GL10 gl, int width, int height) {

        ARGFrame frame = mARGSession.drawFrame(gl, width, height);
        if (argmedia != null && argmedia.isRecording()) {
            // Update Recording Frame
            argmedia.updateFrame(frame.getTextureId());
        }

    }
};
var argmedia = new ARGMedia(argsession);

private fun startRecording() {
    val bitrate = 10 * 1000 * 1000 // 10M
    val previewSize: IntArray? = camera.previewSize
    val videoFilePath = mediaPath + "/" + System.currentTimeMillis() + ".mp4"

    argMedia.initRecorder(
        videoFilePath, previewSize[0], previewSize[1], bitrate,
        false, false, false, ARGMedia.Ratio.RATIO_4_3
    )

    argMedia.startRecording()
}

private fun stopRecording() {
    argmedia.stopRecording()
}

override fun onDrawFrame(gl: GL10?, width: Int?, height: Int?) {

    val localWidth = width ?: 0
    val localHeight = height ?: 0
    val frame = argsession.drawFrame(gl, localWidth, localHeight)
    frame?.let {
        if (argmedia.isRecording) argmedia.updateFrame(it.textureId)
    }
}

Previous9. Set ContentsNext11. Switch Camera Face

Last updated 5 years ago

Was this helpful?