我遇到一个问题,我需要帮助来解码C#中来自网络摄像头的qr代码。.我目前正在使用c#中的zxing库。但是,由于某种原因,我有些困惑,需要帮助来正确解决此问题。几乎所有教程代码都已过时。因此,如果有人帮助我从我的网络摄像头解码我的二维码,那将很棒。顺便说一下,我将Unity用作前端,将C#用作后端。感谢您的帮助。干杯。
Json结果:
{"name":"Mike"}
这是我的代码:
public void CheckQrCode()
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://PROJECT_URL.firebaseio.com/qrCode/qrCode.json");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "PUT";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
try
{
// Instantiate the barcode reader object.
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 is from QR Code" + result.Text);
SceneManager.LoadScene("Verify");
streamWriter.Write(result);
}
}
catch (Exception ex)
{
Debug.LogWarning (ex.Message);
}
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
}