0

ZBar-Sharp ( https://github.com/jonasfj/zbar-sharp ) では、以下のコードで Image クラス内のシステム ライブラリで画像が処理されました。

===============

public Image(System.Drawing.Image image) : this() {

    Byte[] data = new byte[image.Width * image.Height * 3];
    //Convert the image to RBG3
    using(Bitmap bitmap = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb)){
        using(Graphics g = Graphics.FromImage(bitmap)){
            g.PageUnit = GraphicsUnit.Pixel;
            g.DrawImageUnscaled(image, 0, 0);
        }
        // Vertically flip image as we are about to store it as BMP on a memory stream below
        // This way we don't need to worry about BMP being upside-down when copying to byte array
        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
        using(MemoryStream ms = new MemoryStream()){
        bitmap.Save(ms, ImageFormat.Bmp);
        ms.Seek(54, SeekOrigin.Begin);
        ms.Read(data, 0, data.Length);
        }
    }
    //Set the data
    this.Data = data;
    this.Width = (uint)image.Width;
    this.Height = (uint)image.Height;
    this.Format = FourCC('R', 'G', 'B', '3');
}

===============

その後、Zbar 内から Y800 に変換されます。

ただし、このアプローチでは、ZBar ネイティブ スキャンと 99.x% の正確性を比較すると、.Net ラッパーの正確性は 80% しかないため、スキャンの正確性が損なわれました。

ZBar は画像処理タスクに画像マジックをネイティブに使用するため、.Net ライブラリを使用するのではなく、imageMagic.Net を使用して画像を処理し、Zbar DLL に渡すことが提案されました。

だから私は ZBarSharp 内の Image クラスを以下のようなオーバーロードで更新する必要があると考えていました

=================

public Image(string fileName)
: this()
{
MagickImage image = new MagickImage(fileName, settings);

//Set the data
this.Data = image.ToByteArray();
this.Width = (uint)image.Width;
this.Height = (uint)image.Height;
this.Format = FourCC('R', 'G', 'B', '3');
}

=================

ただし、元の .Net ライブラリは、特定のファイルで 5650560 を取得するために長さが約 5650614 でオフセットが 54 のイメージ Byte[] を作成するのに対し、imageMagic は同じファイルを読み取り、長さが 15194 の Byte[] を生成することに気付きました。より小さく、また imageMagic.Net からの Byte[] は常にスキャンから結果を取得しません。密度、フォーマットなどで imageMagic Read のさまざまな設定を試しましたが、配列の長さが常に短く、スキャンから結果が得られません。

imageMagic.Net を使用して、.Net ライブラリによって生成された同様の同等のものをより良い品質で使用するために、私が見逃したことを誰かが指摘するのを手伝ってくれるかどうか疑問に思っていますか?

前もって感謝します。

4

0 に答える 0