コード例 #1
0
    private void Awake()
    {
        Application.targetFrameRate = 120;

        _device = Device.Open(0);

        _device.StartCameras(new DeviceConfiguration
        {
            ColorFormat            = ImageFormat.ColorBGRA32, // Note: other formats would be hardware-native, faster
            ColorResolution        = ColorResolution.R720p,
            DepthMode              = DepthMode.NFOV_Unbinned, // Note: makes a large difference in latency!
            SynchronizedImagesOnly = true,
            CameraFPS              = FPS.FPS30,
        });

        var calibration = _device.GetCalibration();

        _colorDims = new int2(
            calibration.ColorCameraCalibration.ResolutionWidth,
            calibration.ColorCameraCalibration.ResolutionHeight
            );
        // _depthDims = new int2(
        //     calibration.DepthCameraCalibration.ResolutionWidth,
        //     calibration.DepthCameraCalibration.ResolutionHeight
        // );

        _depth = new NativeArray <float>(_colorDims.x * _colorDims.y, Allocator.Persistent);

        _depthTex   = new Texture2D(_colorDims.x, _colorDims.y, TextureFormat.RFloat, false, true);
        _segmentTex = new Texture2D(_colorDims.x, _colorDims.y, TextureFormat.RGBA32, false, true);
        _colorTex   = new Texture2D(_colorDims.x, _colorDims.y, TextureFormat.RGBA32, false, true);

        _transformedDepth = new Image(
            ImageFormat.Depth16,
            _colorDims.x, _colorDims.y, _colorDims.x * sizeof(System.UInt16));

        _transformedSegment = new Image(
            ImageFormat.Custom8,
            _colorDims.x, _colorDims.y, _colorDims.x * sizeof(System.Byte));

        _depthTransformer = calibration.CreateTransformation();

        // _tracker = Tracker.Create(calibration, new TrackerConfiguration {
        //     SensorOrientation = SensorOrientation.Default,
        //     ProcessingMode = TrackerProcessingMode.Gpu,
        //     GpuDeviceId = 0,
        // });

        _mesh = new GameObject("Mesh").AddComponent <MeshTile>();
        _mesh.Create(_colorDims);
        _mesh.MeshRenderer.material = _material;
        _mesh.MeshRenderer.material.SetTexture("_ColorTex", _colorTex);
        _mesh.MeshRenderer.material.SetTexture("_DepthTex", _depthTex);

        _exporter = gameObject.GetComponent <AlembicExporter>();
    }
コード例 #2
0
        public void SetUp()
        {
            var scene = SceneManager.CreateScene(sceneName);

            SceneManager.SetActiveScene(scene);
            var go = new GameObject("Recorder");

            exporter = go.AddComponent <AlembicExporter>();
            exporter.MaxCaptureFrame = 20;
            exporter.Recorder.Settings.OutputPath =
                "Assets/" + Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".abc";
            exporter.CaptureOnStart = false;

            camera = new GameObject("Cam");
            camera.AddComponent <Camera>();
            camera.transform.localPosition = new Vector3(0, 1, -10);
        }