1
QRコードのデコードにzxingのユニティバージョンを使用しようとしています。ここゼロを返すQRデコードを返す
コードは次のとおり
テクスチャ= gameObject.GetComponent()。
//texture.pixelInset = new Rect(Screen.width/4, Screen.height/4, Screen.width/2, Screen.height/2);
int imageSize = 100;
Texture2D text2D = new Texture2D(imageSize, imageSize);
text2D = (Texture2D)texture.texture;
Debug.Log("text2D.GetPixels32().Length " + text2D.GetPixels32().Length);
//Debug.Log("text2D.GetRawTextureData().Length " + text2D.GetRawTextureData().Length);
Color32LuminanceSource source = new Color32LuminanceSource(text2D.GetPixels32(), imageSize, imageSize);
RGBLuminanceSource source1 = new RGBLuminanceSource(text2D.GetRawTextureData(), imageSize, imageSize);
Debug.Log(GetString(source.Matrix));
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
BinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source1));
QRCodeReader reader = new QRCodeReader();
BarcodeReader reader1 = new BarcodeReader();
DecodingOptions options = new DecodingOptions();
options.TryHarder = true;
Result resultQRCodeReader = reader.decode(bitmap, options.Hints);
Result resultQRCodeReader1 = reader.decode(bitmap1, options.Hints);
Result resultBarcodeReader = reader1.Decode(source);
Result resultBarcodeReader1 = reader1.Decode(source1);
問題は両方の読者からのすべての「結果」であり、両方のソースがヌル文字列を返します。 私はzxingバーコードツール-でテストしたqrcodeのいくつかの例を試しましたが、それらはすべて問題ありません。
私が間違っていることを理解できません。
の力であると仮定すると?あなたが良い値を持っているかどうかを調べるために、text2D.GetPixels32()配列からいくつかの行を印刷してみてください.. reader.decode(color32array、width、height)で直接text2D.GetPixels32()を使うこともできます。 – mgear