示例#1
0
    public IEnumerator ExportFrame()
    {
        while (true)
        {
            if (sendToAWS && !isRunning)
            {
                isRunning = true;
                yield return(frameEnd);

                tex.Resize(arCam.pixelWidth, arCam.pixelHeight);
                tex.ReadPixels(screenRect, 0, 0);
                tex.Apply();

                TextureScale.Bilinear(tex, tex.width / 2, tex.height / 2);
                croppedTex = TextureTools.ResampleAndCrop(tex, tex.width, tex.height / 2 + 100);
                frameBytes = croppedTex.EncodeToJPG();

                dataToStream.ApproximateCaptureTime = System.DateTime.UtcNow;
                dataToStream.FrameCount             = Time.frameCount;
                dataToStream.ImageBytes             = frameBytes;

                JSONdataToStream = dataToStream.serialize();
                _C.PutRecord(JSONdataToStream, "FrameStream", (response) => { });

                frameBytes       = null;
                JSONdataToStream = null;
                isRunning        = false;
            }
            yield return(exportInterval);
        }
    }
示例#2
0
    public IEnumerator ExportFrame()
    {
        yield return(frameEnd);

        tex.Resize(arCamTexture.width, arCamTexture.height);
        tex.ReadPixels(new Rect(0, 0, arCamTexture.width, arCamTexture.height), 0, 0);
        tex.Apply();

        TextureScale.Bilinear(tex, tex.width / 2, tex.height / 2);

        byte[] frameBytes = tex.EncodeToJPG();

        //Debug to write texture into PNG
        //File.WriteAllBytes(Application.dataPath + System.String.Format( "/../SavedScreen{0}.jpg", frames), frameBytes);

        FramePackage dataToStream     = new FramePackage(System.DateTime.UtcNow, frames, frameBytes);
        string       JSONdataToStream = dataToStream.serialize();

        Debug.Log("Sending image to Kinesis");
        _C.PutRecord(JSONdataToStream, "FrameStream", (response) => {});
    }