Exemplo n.º 1
0
    IEnumerator Start()
    {
        cameraMat = plane.GetComponent <MeshRenderer>().material;
        decoder   = GetComponent <WebCamDecoder>();

        var devices    = WebCamTexture.devices;
        var deviceName = devices[0].name;

        cameraTexture = new WebCamTexture(deviceName, (int)(Screen.width * 0.5f), (int)(Screen.height * 0.5f));
        cameraTexture.Play();

        yield return(StartCoroutine(decoder.StartDecoding(cameraTexture)));

        cameraMat.mainTexture = cameraTexture;

        // adjust texture orientation;
        plane.transform.rotation = plane.transform.rotation *
                                   Quaternion.AngleAxis(cameraTexture.videoRotationAngle, Vector3.up);
    }
Exemplo n.º 2
0
    IEnumerator Start()
    {
        // get render target;
        plane     = GameObject.Find("Plane");
        cameraMat = plane.GetComponent <MeshRenderer>().material;

        // get a reference to web cam decoder component;
        decoder = GetComponent <WebCamDecoder>();

        // get encoders;
        qrEncoder = Barcode.GetEncoder(BarcodeType.QrCode, new QrCodeEncodeOptions()
        {
            ECLevel = QrCodeErrorCorrectionLevel.H
        });

        pdf417Encoder = Barcode.GetEncoder(BarcodeType.Pdf417);

        qrEncoder.Options.Margin     = 1;
        pdf417Encoder.Options.Margin = 2;

        // init web cam;
        if (Application.platform == RuntimePlatform.OSXWebPlayer ||
            Application.platform == RuntimePlatform.WindowsWebPlayer)
        {
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam));
        }

        var devices    = WebCamTexture.devices;
        var deviceName = devices[0].name;

        cameraTexture = new WebCamTexture(deviceName, 1920, 1080);
        cameraTexture.Play();

        // start decoding;
        yield return(StartCoroutine(decoder.StartDecoding(cameraTexture)));

        cameraMat.mainTexture = cameraTexture;

        // adjust texture orientation;
        plane.transform.rotation = plane.transform.rotation *
                                   Quaternion.AngleAxis(cameraTexture.videoRotationAngle, Vector3.up);
    }