私はそれを使用するための非常に単純な認識イメージ用のC# libを作成しており、C#へのポートmonodroid
も使用しています。しかし、ファイルから画像バイトを読み取った後、バーコードスキャンzxing
と同じように、そのようなことを行います。zxing
binaryBitmap = new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(rawRgb, width, height, format)));
しかし、なぜか上下反転してしまいます。binaryBitmap
ビットマップとしてピクセル単位でファイルに保存するだけです。
なぜそれが起こるのか理解してください。私は何を間違っていますか?
@Michael は Zxing.Net.Mobile ポートを使用しています。ここからhttps://github.com/Redth/ZXing.Net.Mobile。私が PlanarYUVLuminanceSource を使用しているのは非常に奇妙です-その後、そのような画像http://i.imgur.com/OlwqC0I.pngを取得しますが、RGBLuminanceSource を使用している場合は、ほぼ正常な画像が完全に取得されます。画像の例を参照してください。だから今、私は2つの質問さえ持っています:
- なぜ平面は画像の一部だけを取り、「レイヤーオンレイヤー」効果があるのですか? と
- RGBLuminanceSource を使用する場合、色が反転する理由は、長方形の境界線がどこか黒で、どこかが白であることを意味します。それは彼らがすべて黒い実像だからですか?
更新: デバイスからバイトを取得する方法は次のとおりです。また、ご覧のとおり、nv21 形式を設定しているため、YUV である必要があります。rgbソースが機能し(リスト画像はOK)、PLanarYUVが:((ところで、プレビューフレームからの元のバイトは結果と同じファイルサイズを持っています。何か提案はありますか?
public void OnPreviewFrame(byte[] bytes, Android.Hardware.Camera camera)
{
var img = new YuvImage(bytes, ImageFormatType.Nv21, cameraParameters.PreviewSize.Width, cameraParameters.PreviewSize.Height, null); string _fileName2 = "YUV_BYtes_"+ DateTime.Now.Ticks +".txt";
string pathToFile2 = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, _fileName2);
using (var fileStream = new FileStream(pathToFile2, FileMode.Append, FileAccess.Write, FileShare.None))
{
fileStream.Write(img.GetYuvData(), 0, img.GetYuvData().Length);
}
}
public void SurfaceChanged(ISurfaceHolder holder, global::Android.Graphics.Format format, int width, int height)
{
if (camera == null)
return;
var parameters = camera.GetParameters();
width = parameters.PreviewSize.Width;
height = parameters.PreviewSize.Height;
parameters.PreviewFormat = ImageFormatType.Nv21;
//parameters.PreviewFrameRate = 15;
//this.height = size.height;
//this.width = size.width;
//camera.setParameters( params );
//parameters.PreviewFormat = ImageFormatType.;
camera.SetParameters(parameters);
camera.SetDisplayOrientation(90);
camera.StartPreview();
cameraResolution = new Size(parameters.PreviewSize.Width, parameters.PreviewSize.Height);
AutoFocus();
}