コード例 #1
0
        void Start()
        {
            //byte[] bytes = File.ReadAllBytes("/Users/akzeac/Downloads/IMG_7764.JPG");
            //byte[] bytes = File.ReadAllBytes("/Users/akzeac/Downloads/IMG_0655.JPG");
            byte[]    bytes   = File.ReadAllBytes("/Users/akzeac/Downloads/IMG_0669.JPG");
            Texture2D texture = new Texture2D(1, 1);

            texture.LoadImage(bytes);


            CvContext cvContext = new CvContext(texture.width, texture.height);


            cvContext.SetImageDataFlipY(texture.GetRawTextureData(), 3);
            int numQrs = cvContext.DetectQrMarkers();

            if (numQrs == 0)
            {
                return;
            }

            var qr = cvContext.GetDetectedQrCorners()[0];

            DrawLine(texture,
                     0, 0,
                     texture.width - 1, 0);
            DrawLine(texture,
                     (int)qr.Corners[0].X, texture.height - 1 - (int)qr.Corners[0].Y,
                     (int)qr.Corners[1].X, texture.height - 1 - (int)qr.Corners[1].Y, Color.blue);
            DrawLine(texture,
                     (int)qr.Corners[1].X, texture.height - 1 - (int)qr.Corners[1].Y,
                     (int)qr.Corners[2].X, texture.height - 1 - (int)qr.Corners[2].Y);
            DrawLine(texture,
                     (int)qr.Corners[2].X, texture.height - 1 - (int)qr.Corners[2].Y,
                     (int)qr.Corners[3].X, texture.height - 1 - (int)qr.Corners[3].Y);
            DrawLine(texture,
                     (int)qr.Corners[3].X, texture.height - 1 - (int)qr.Corners[3].Y,
                     (int)qr.Corners[0].X, texture.height - 1 - (int)qr.Corners[0].Y);


            var detectedMarker = new DetectedARMarker
            {
                Type       = (byte)ARMarkerType.QrCode,
                Header     = new Header(0, default, TfListener.FixedFrameId),