유니티엔진에서 Kinect를 이용해서 띄운 RGB 영상을 녹화하고 싶습니다.
조회수 1943회
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
(openCV는 뭔지 잘 모릅니다) 꼭 유니티상에서 녹화하시려면 Application.CaptureScreenshot을 이용하는 방법이 있기는 합니다. 아래 코드와 같이 매 프레임마다 화면 캡쳐를 하고 나중에 이걸 조합하는 방법입니다. 출처
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(); } }
하지만 유니티에서 이걸 인코딩까지 실시간으로 하는건 대부분의 경우 성능상 무리입니다. iOS나 Android에서 실시간 인코딩까지 지원하는 서비스(everyplay)들은 대부분 Native Plugin을 이용해서 각 플랫폼에 맞는 별도 코드를 사용합니다. 녹화한 다음에 그걸 바로 영상으로 업로드 하는 기능이 필요하시면 XBOX에서 제공하는 Native API를 알아보시는게 빠를것 같네요.
댓글 입력