I'd like to record RGB images that were uploaded by Unity Engine using Kinect.

Asked 2 years ago, Updated 2 years ago, 139 views

I'd like to record RGB images that were uploaded by UNI.T. Engine using Kinect camera.

Is there a way to save and recall after recording using openCV?

unity c# opencv kinect

2022-09-21 19:17

1 Answers

(I don't know what openCV is) To record on Unity, there is a way to use Application.CaptureScreenshot. This is how to capture the screen every frame and combine it later, as shown in the code below. Source

using UnityEngine;
using System.Collections;
using System.IO;

public class ScreenRecorder : MonoBehaviour {

    public int maxFrames; //amount of frames you want to record before closing the game

    int shotCount;

    void Awake () {
        Application.targetFrameRate = 1; //forces frame rate to 1
        if (!System.IO.Directory.Exists("Screenshots")) //check if "Screenshots" folder exists
        {
            System.IO.Directory.CreateDirectory(Application.dataPath + "/Screenshots");
        }
    }

    void Update () {
        if (shotCount <= maxFrames) //we don't want to include the first frame since it's a mess
        {
            Application.CaptureScreenshot(Application.dataPath + "/Screenshots/" + "shot" + shotCount + ".png");
            shotCount += 1;
        }
        else //keep making screenshots until it reaches the max frame amount
        {
            StopRecording(); //quit game
        }
    }

    public void StopRecording() //you can call this function for different reasons (e.g camera animation stops)
    {
        Application.Quit();
    }
}

But in most cases, it's impossible to do it in real time from Unity to encoding. Most services that support real-time encoding on iOS or Android use Native Plugin to use separate code for each platform. If you need the ability to record and upload it as a video right away, it would be faster to find out the Native API provided by XBOX.


2022-09-21 19:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.