// 實例化
BarcodeReader barcodeReader = new BarcodeReader();
// 獲取攝像機畫面的像素顏色數(shù)組信息
data = webCamTexture.GetPixels32();
//獲取圖片中的二維碼信息
Result[] result = barcodeReader.DecodeMultiple(data, webCamTexture.width, webCamTexture.height);
if (result != null && result.Length >1)
{
for (int i = 0; i < result.Length; i++)
{
text.text = result.Length.ToString();
}
Debug.Log(result.Length); //顯示獲取到的數(shù)量
}
至于zxing的代碼怎么寫我就不寫了,畢竟網(wǎng)上有很多的。
平常在獲取二維碼內(nèi)容的時候我們會調(diào)用barcodeReader.Decode(),這個。
而獲取多個就是上面的代碼“Result[] result = barcodeReader.DecodeMultiple(data, webCamTexture.width, webCamTexture.height);”這會得到一個數(shù)組。zxing識別到的多個二維碼數(shù)據(jù)就會存儲到這個數(shù)組中,遍歷就可以獲取到內(nèi)部的數(shù)據(jù)了。