안녕하세요, 아래 코드를 사용하여 이미지에서 바코드를 읽으려고했지만 여러 바코드가 포함되어 있으므로 파일을 읽을 수 없습니다. 이에 대한 해결 방법이 있습니까?
@GetMapping(value = "OCR/Apachecamel")
@ApiOperation(value = "Get result from Barcode Apachecamel library")
public BarcodeInfo GetApachecamelResult() throws Exception {
try {
InputStream barCodeInputStream = new FileInputStream("images/multiple.png");
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(
new BufferedImageLuminanceSource(ImageIO.read(barCodeInputStream))));
if (bitmap.getWidth() < bitmap.getHeight()) {
if (bitmap.isRotateSupported()) {
bitmap = bitmap.rotateCounterClockwise();
}
}
return decode(bitmap);
} catch (IOException e) {
throw new BarcodeDecodingException(e);
}
}
private BarcodeInfo decode(BinaryBitmap bitmap) throws BarcodeDecodingException {
Reader reader = new MultiFormatReader();
try {
Result result = reader.decode(bitmap);
return new BarcodeInfo(result.getText(), result.getBarcodeFormat().toString());
} catch (Exception e) {
throw new BarcodeDecodingException(e);
}
}
public static class BarcodeInfo {
private final String text;
private final String format;
public String getText() {
return text;
}
public String getFormat() {
return format;
}
BarcodeInfo(String text, String format) {
this.text = text;
this.format = format;
}
}
public static class BarcodeDecodingException extends Exception {
BarcodeDecodingException(Throwable cause) {
super(cause);
}
}
pom.xml
<!-- https://mvnrepository.com/artifact/org.apache.camel/camel-barcode -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-barcode</artifactId>
<version>2.21.1</version>
</dependency>
오류
동봉 된 이미지
누군가가 이것에 대한 해결 방법이 있음을 알려줄 수 있습니까? 미리 감사드립니다
- 답변 # 1
관련 자료
- typescript - Angular에서`ComponentFactoryResolver`를 사용할 때 다른 구성 요소로 데이터를 전달할 수 없습니다
- jquery - Kendo UI Grid를 사용하여 백엔드 페이지 매김을 사용할 수 없습니다
- java - Spring Boot를 사용하여 제공 할 수 없습니다
- Python Drive API를 사용하여 200MB 이상의 csv 파일을 업로드 할 수 없습니다
- javascript - react-router를 사용하여로드 할 수없는 경로
- Spring Boot에서 JUnit 5를 사용하여 RestTemplate을 모의 할 수 없습니다
- spring - JUnit 5에서 @Value를 사용하여 속성 값을 가져올 수 없습니다
- java - Apache Derby 용 JDBC 드라이버를로드 할 수 없습니다
- javascript - iframe을 사용하여 Angular JS 애플리케이션에서 Angular 10 애플리케이션으로 메시지를 게시 할 수 없음
- 병렬 처리 중 Apache Camel Scheduler 지연이 고려되지 않음
- c# - HttpClient를 사용하는 API 호출에 대해 NLog로 Microsoft 로그를 억제 할 수 없음
- javascript - Twilio를 사용하여 보낸 메시지 목록을 resjson 할 수 없습니다
- reactjs - JSX에서 삼항 연산자를 사용하여 리디렉션을 포함 할 수 없습니다
- python - xpath를 사용하여 href 태그에서 텍스트를 추출 할 수 없습니다
- python - pymysql을 사용하여 MySQL에 데이터 파일을로드 할 수 없습니다파일을 찾을 수 없습니다
- apache camel kafka - producer 구성에서 "deliveryrequestms"속성을 설정하는 방법
- Apache Camel은 문자열 메시지 본문에서 아포스트로피를 제거합니다
- 파이썬에서 문자열 형식을 사용하여 원하는 출력을 얻을 수 없습니다
- node.js - nestjs/mongoose를 사용하여 mongoDB를 연결할 수 없습니다
알고리즘의 기본과 자바를 먼저 배워야한다고 생각합니다.
TRY_HARDER
그리고 사용GenericMultipleBarcodeReader
:)