これはもちろん、それを使用しているかどうかによって異なります。 zxingのJavaバージョンであっても、いくつかの重要な制限とパフォーマンスの問題があります。たとえば、ページ上に1つのバーコードしか見つからない場合などです。また、ページ上に1次元バーコードを配置するために使用するアルゴリズムは、特に効率的ではありません(2次元バーコードのアルゴリズムについては、私が取り組んでいるプロジェクトの要件の一部ではありませんでした)。これは対処できるすべてのものです。私は数ヶ月前に機能拡張を開始し、1次元のロケーションのパフォーマンスと信頼性を大幅に向上させることができましたが、私たちの開発者の優先順位がシフトして以来、私はそれに取り組んでいません。
C#への部分的なポートが良いかどうかについては、相違点を投稿したい場合はコメントしてください。
EDITは - ここで私がやったリファクタリングの一部です:
public interface RowNumberStrategy {
public int getNextRowNumber();
public class OriginalRowStrategy implements RowNumberStrategy{
int middle;
boolean tryHarder = false;
int rowStep;
int maxLines;
int maxRows;
int x;
public OriginalRowStrategy(int maxRows, boolean tryHarder) {
this.x = 0;
this.maxRows = maxRows;
this.middle = maxRows >> 1; // divide by 2
this.tryHarder = tryHarder;
rowStep = Math.max(1, maxRows >> (tryHarder ? 7 : 4));
if (tryHarder) {
maxLines = maxRows; // Look at the whole image, not just the center
} else {
maxLines = 9; // Nine rows spaced 1/16 apart is roughly the middle half of the image
}
}
public int getNextRowNumber() {
if (x > maxLines)
return -1;
int rowStepsAboveOrBelow = (x + 1) >> 1;
boolean isAbove = (x & 0x01) == 0; // i.e. is x even?
int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow);
if (rowNumber < 0 || rowNumber >= maxRows) {
// Oops, if we run off the top or bottom, stop
return -1;
}
x = x + 1;
return rowNumber;
}
}
public class LinearScanRowStrategy implements RowNumberStrategy{
private final int maxRows;
private int currentRow;
public LinearScanRowStrategy(int totalRows) {
maxRows = totalRows;
currentRow = 0;
}
public int getNextRowNumber() {
if (currentRow > maxRows)
return -1;
return maxRows - 1 - currentRow++;
}
}
public class ProgressiveScanRowStrategy implements RowNumberStrategy{
private final int maxRows;
private int currentStepSize;
private int currentStep;
public ProgressiveScanRowStrategy(int totalRows) {
maxRows = totalRows;
currentStep = 0;
currentStepSize = maxRows;
}
public int getNextRowNumber() {
int nextRow = (currentStep++) * currentStepSize;
if (nextRow < maxRows)
return nextRow;
currentStepSize = currentStepSize >> 1;
if (currentStepSize <= 0)
return -1;
currentStep = 1;
nextRow = currentStep * currentStepSize;
return nextRow;
}
}
}
を次のようにdoDecodeの上部には次のようになります:次のように
まず、RowNumberStrategyを考慮
private Result doDecode(MonochromeBitmapSource image, Hashtable hints) throws ReaderException {
int width = image.getWidth();
int height = image.getHeight();
BitArray row = new BitArray(width);
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
RowNumberStrategy rowProvider = new RowNumberStrategy.ProgressiveScanRowStrategy(height);
int rowNumber;
while ((rowNumber = rowProvider.getNextRowNumber()) != -1){
...
}
最終的には、これはDecodeHintTypeを介して設定できるものでなければなりませんが、進化戦略は従来の戦略よりも高速ですそれだけではなく、ちょっと速く - 多くは速い)。
なぜあなただけが知っているのですか?それを試してみませんか? –
@Ed Oh、um、duh!あなたは知っている、私は私の質問を閉じる必要があると思う。 Oopsey。 –
さて、質問自体は将来の人にとっては役に立ちそうなので、私はそれを閉じるのが正しいとは思わない。また、学習に時間を要する洞察を持つ人もいれば、一目で見逃すかもしれません。私はちょうどその時、それを試してみることが私の最初の目標であることを示唆していました。 –