Example #1
0
    protected virtual IEnumerator RunGraph()
    {
        var webCamScreenController = webCamScreen.GetComponent <WebCamScreenController>();

        graph.Initialize();

        sidePacket = new SidePacket();
        sidePacket.Insert("focal_length_pixel", new FloatPacket(webCamScreenController.FocalLengthPx()));

        graph.StartRun(sidePacket).AssertOk();

        while (true)
        {
            yield return(new WaitForEndOfFrame());

            if (!webCamScreenController.isPlaying())
            {
                Debug.LogWarning("WebCam is not working");
                break;
            }

            var pixelData = webCamScreenController.GetPixels32();
            var width     = webCamScreenController.Width();
            var height    = webCamScreenController.Height();

            graph.PushColor32(pixelData, width, height);
            graph.RenderOutput(webCamScreenController, pixelData);
        }
    }