문제

이미지에서 바코드를 찾고 읽을 수있는 좋은 오픈 소스 라이브러리를 찾고 있습니다 (바코드 스캐너 사용과 비교). Stack Overflow의 다른 질문에서 xxing ( "Zebra Crossing")는 꽤 좋습니다. Java를 위해 만들어졌지만 C# 포트가 있습니다. 그러나 그것이 완전하지 않을 수도 있다고 생각합니다. 당신은 그것이 생각하십니까? 믿을 수 있는 그러한 상황에서 바코드를 구문 분석하기에 충분합니까, 아니면 다른 도서관이 더 좋습니까?

편집하다: Ed가 의견에서 지적했듯이 먼저 시도해야합니다. 와우, 나는 그것을 생각하지 않았다. :) 그러나 내 질문은 부분 포트가 충분히 신뢰할 수 있는지 여부입니다. 이전에 사용한 사람 중 누구라도 숙련도로 스캔 할 수 있습니까?

도움이 되었습니까?

해결책

이것은 물론 사용하는 것에 달려 있습니다. ZXing의 Java 버전조차도 중요한 제한 사항과 성능 문제가 있습니다. 예를 들어, 페이지에서 하나의 바코드 만 찾을 수 있습니다. 또한 페이지에서 1D 바코드를 찾는 데 사용하는 알고리즘은 특별히 효율적이지 않습니다 (2D 바코드의 알고리즘에 대해서는 알지 못합니다. 이것은 다룰 수있는 모든 것들입니다. 몇 달 전에 향상을 시작했고 1D 위치 성능과 신뢰성을 크게 향상시킬 수 있었지만 개발 우선 순위가 바뀌어 그 이후로 작업하지 않았습니다.

C#에 대한 부분 포트가 양호한 지 여부에 관해서는 차이점이 무엇인지 다시 게시하고 싶다면 기꺼이 의견을 말할 것입니다.

편집 - 여기에 내가 한 리팩토링 중 일부가 있습니다.

먼저 다음과 같이 rownumberstrategy를 고려하십시오.

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의 상단 부분은 다음과 같습니다.

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를 통해 설정할 수있는 것이되어야하지만, 우리는 진보적 인 전략이 우리가 던질 수있는 모든 경우에 기존 전략보다 빠릅니다 (조금 더 빠르지 않습니다. 많이 더 빠르게).

다른 팁

나는 1 년 이상 Java 버전을 사용하여 매일 약 100 개를 스캔했으며 훌륭하게 작동합니다. C# 버전이 더 나빠질 이유는 없습니다.

Java 버전을 컴파일하십시오 IKVMC, C# 코드에서 액세스하는 것보다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top