C# 在Unity中使用ZXing定位QRcode';s位置模式

C# 在Unity中使用ZXing定位QRcode';s位置模式,c#,unity3d,zxing,C#,Unity3d,Zxing,作为标题,我想使用定位三位置模式。 我想知道当我从webcamtexture获得新的二维码时,如何获得这些图案的x y位置。 我应该如何实现这是Unity(C#)?使用以下代码解码ZXing dll private WebCamTexture camTexture; private Rect screenRect; void Start() { screenRect = new Rect(0, 0, Screen.width, Screen.height); camTextur

作为标题,我想使用定位三位置模式。

我想知道当我从webcamtexture获得新的二维码时,如何获得这些图案的x y位置。

我应该如何实现这是Unity(C#)?

使用以下代码解码ZXing dll

private WebCamTexture camTexture;
private Rect screenRect;
void Start()
{
    screenRect = new Rect(0, 0, Screen.width, Screen.height);
    camTexture = new WebCamTexture();
    camTexture.requestedHeight = Screen.height;
    camTexture.requestedWidth = Screen.width;
    if (camTexture != null)
    {
        camTexture.Play();
    }
}

void OnGUI()
{
    // drawing the camera on screen
    GUI.DrawTexture(screenRect, camTexture, ScaleMode.ScaleToFit);
    // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake
    try
    {
        IBarcodeReader barcodeReader = new BarcodeReader();
        // decode the current frame
        var result = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height);
        if (result != null)
        {
            Debug.Log("DECODED TEXT FROM QR: " +result.Text);
        }
        ResultPoint[] point = result.ResultPoints;
        Debug.Log("X: " + point[0].X + " Y: " + point[1].Y);
    }
    catch (Exception ex) { Debug.LogWarning(ex.Message); }
}
我参考了他的资料。它在自述文件中也有二维码生成器。阅读自述。几乎相同的只是
ResultPoint[]point=result.ResultPoints已添加到其中。这给出了图像的3个角的位置。显然,您需要在资源中的plugins文件夹中添加ZXing.dll。

希望这有助于获得结果。

您可以参考了解更多。本博客只展示了ZXing如何解码和编码(之前已经做过这部分),但仍然不知道如何获得图案的位置。一年半前,我曾在android和pc上尝试解码ZXing的QR标记,所以当时它确实对我有效。现在不知道,但也应该能够使用ios。