public void BeginScanQRCode()
    {
        TrackerManager.Instance.GetTracker <ObjectTracker>().Stop();
        CameraDevice.Instance.Stop();
        lastCaptureTime = Time.realtimeSinceStartup;
        RegisterFormat();
        ScanQRCode();
        TrackerManager.Instance.GetTracker <ObjectTracker>().Start();
        CameraDevice.Instance.Start();
#if !UNITY_EDITOR
        NetworkMeshSource.getSingleton().sendImage(m_Texture, Camera.main.transform.position, Camera.main.transform.rotation);
#endif
        try
        {
            QRCodeChecker qr = QRCodeChecker.getSingleton();
            string        o  = qr.findQRCodeInImage(m_Texture);
            Debug.Log(o);
            if (o.Length > 0)
            {
                outText = o;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            outText = "Exception Thrown";
            return;
        }
        //m_RawImageBig.texture = m_Texture;
        //m_RawImageBig.mainTexture = m_Texture;
        //m_RawImageBig.SetNativeSize(); holy giant plane batman.
        //m_RawImageBig.material.SetTexture(m_Texture);
        //m_RawImageBig.material.mainTexture = m_Texture;
    }
    private void ScanQRCode()
    {
        if (mFormatRegistered)
        {
            if (mAccessCameraImage)
            {
                Vuforia.Image image = CameraDevice.Instance.GetCameraImage(mPixelFormat); //DC this is where problem is
                if (image != null && image.IsValid())
                {
                    string imageInfo = mPixelFormat + " image: \n";
                    imageInfo += " size: " + image.Width + " x " + image.Height + "\n";
                    imageInfo += " bufferSize: " + image.BufferWidth + " x " + image.BufferHeight + "\n";
                    imageInfo += " stride: " + image.Stride;
                    Debug.Log(imageInfo);
                    byte[] pixels = image.Pixels;

                    if (pixels != null && pixels.Length > 0)
                    {
                        Debug.Log("Image pixels: " + pixels[0] + "," + pixels[1] + "," + pixels[2] + ",...");
                        Texture2D tex = new Texture2D(image.BufferWidth, image.BufferHeight, TextureFormat.RGB24, false); // RGB24
                        tex.LoadRawTextureData(pixels);
                        tex.Apply();
                        m_Texture             = tex;
                        m_RawImageBig.texture = tex;
                        m_RawImageBig.material.mainTexture = tex;
                        QRCodeChecker qr = QRCodeChecker.getSingleton();
                        Debug.Log(qr.findQRCodeInImage(m_Texture));
                    }
                }
            }
        }
    }
Example #3
0
    void FixedUpdate()
    {
        if (lastCaptureTime + 10.0f < Time.realtimeSinceStartup)
        {
            TrackerManager.Instance.GetTracker <ObjectTracker>().Stop();
            CameraDevice.Instance.Stop();
            lastCaptureTime = Time.realtimeSinceStartup;
            RegisterFormat();
            this.TakePhoto();
            TrackerManager.Instance.GetTracker <ObjectTracker>().Start();
            CameraDevice.Instance.Start();
#if !UNITY_EDITOR
            NetworkMeshSource.getSingleton().sendImage(m_Texture, Camera.main.transform.position, Camera.main.transform.rotation);
#endif

            QRCodeChecker qr = QRCodeChecker.getSingleton();
            string        o  = qr.findQRCodeInImage(m_Texture);
            Debug.Log(o);
            if (outTextGO != null)
            {
                outTextGO.text = o;
            }
            //m_RawImageBig.texture = m_Texture;
            //m_RawImageBig.mainTexture = m_Texture;
            //m_RawImageBig.SetNativeSize(); holy giant plane batman.
            //m_RawImageBig.material.SetTexture(m_Texture);
            //m_RawImageBig.material.mainTexture = m_Texture;
        }
    }