示例#1
0
    // Start is called before the first frame update
    async void Awake()
    {
        Debug.Log("start creating video capture.");
        await CameraPreviewCapture.CreateAsync(OnCaptureCreated);


        //kernelCalc = compute.FindKernel("CalcWhite");
    }
    private void Awake()
    {
        texture = new Texture2D(896, 504, TextureFormat.BGRA32, false);

        foreach (var rawImage in rawImageList)
        {
            rawImage.texture = texture;
        }
        // ファクトリメソッドをコール
        CameraPreviewCapture.CreateAync(CameraPreviewCapture_OnCreated);
    }
示例#3
0
    async void OnDestroy()
    {
        //pointsBuffer.Release();
        //whitesBuffer.Release();

        if (capture != null)
        {
            await capture.Dispose();

            capture = null;
        }
    }
示例#4
0
 async void OnCaptureCreated(CameraPreviewCapture createdObject)
 {
     if (createdObject != null)
     {
         Debug.Log("capture created.");
         capture = createdObject;
         capture.OnFrameArrived += OnFreameArrive;
         await capture.StartVideoModeAsync(false);
     }
     else
     {
         Debug.Log("capture not created.");
     }
 }
    /// <summary>
    /// ファクトリメソッドを呼び出したときのコールバック
    /// カメラプレビューを開始する
    /// </summary>
    /// <param name="captureObject"></param>
    private async void CameraPreviewCapture_OnCreated(CameraPreviewCapture captureObject)
    {
        if (captureObject == null)
        {
            throw new Exception("Failed to create CameraPreviewCapture instance");
        }
        _cameraPreviewCapture = captureObject;
        // 新しいフレームを取得したときのイベントハンドラを設定
        _cameraPreviewCapture.OnFrameArrived += CameraPreviewCapture_OnFrameArrived;
        // カメラプレビューの開始
        var result = await _cameraPreviewCapture.StartVideoModeAsync(false);

        if (!result)
        {
            throw new Exception("Failed to start camera preview");
        }
    }