Compare commits
1 Commits
master
...
performanc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2c0be95d5 |
@ -72,7 +72,7 @@ public class OCRService {
|
|||||||
invisibleElementRemovalService.removeInvisibleElements(fileStream, transferOutputStream, false);
|
invisibleElementRemovalService.removeInvisibleElements(fileStream, transferOutputStream, false);
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("Invisible element removal successful for file with dossierId {} and fileId {}, took {}s", dossierId, fileId, format("%.1f", (float) ((end - start) / 1000)));
|
log.info("Invisible element removal successful for file with dossierId {} and fileId {}, took {}s", dossierId, fileId, format("%.1f", (end - start) / 1000.0));
|
||||||
try (InputStream transferInputStream = new ByteArrayInputStream(transferOutputStream.toByteArray())) {
|
try (InputStream transferInputStream = new ByteArrayInputStream(transferOutputStream.toByteArray())) {
|
||||||
runOcr(transferInputStream, out, fileId);
|
runOcr(transferInputStream, out, fileId);
|
||||||
}
|
}
|
||||||
@ -93,12 +93,12 @@ public class OCRService {
|
|||||||
Map<Integer, RectCollection> pageIdToRectCollection = imagePositionRetrievalService.getImagePositionPerPage(pdfDoc, true);
|
Map<Integer, RectCollection> pageIdToRectCollection = imagePositionRetrievalService.getImagePositionPerPage(pdfDoc, true);
|
||||||
|
|
||||||
int numProcessedPages = 0;
|
int numProcessedPages = 0;
|
||||||
|
// optimization: only scanning pages that contain images
|
||||||
for (Integer pageId : pageIdToRectCollection.keySet()) {
|
for (Integer pageId : pageIdToRectCollection.keySet()) {
|
||||||
try {
|
try {
|
||||||
// optimization: creating a new document is faster than reusing the same and adding/removing pages one by one
|
// optimization: creating a new document is faster than reusing the same and adding/removing pages one by one
|
||||||
OCROptions options = new OCROptions();
|
OCROptions options = new OCROptions();
|
||||||
PDFDoc ocrPageDoc = new PDFDoc();
|
PDFDoc ocrPageDoc = new PDFDoc();
|
||||||
// optimization: only scanning pages that contain images
|
|
||||||
Page pdfPage = pdfDoc.getPage(pageId);
|
Page pdfPage = pdfDoc.getPage(pageId);
|
||||||
// optimization: this line ensures the ocr text is placed correctly by PDFTron
|
// optimization: this line ensures the ocr text is placed correctly by PDFTron
|
||||||
pdfPage.setMediaBox(pdfPage.getCropBox());
|
pdfPage.setMediaBox(pdfPage.getCropBox());
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.iqser.red.service.ocr.v1.api.model.DocumentRequest;
|
import com.iqser.red.service.ocr.v1.api.model.DocumentRequest;
|
||||||
import com.iqser.red.service.ocr.v1.server.client.FileStatusProcessingUpdateClient;
|
import com.iqser.red.service.ocr.v1.server.client.FileStatusProcessingUpdateClient;
|
||||||
import com.iqser.red.service.ocr.v1.server.configuration.MessagingConfiguration;
|
import com.iqser.red.service.ocr.v1.server.configuration.MessagingConfiguration;
|
||||||
|
import com.pdftron.pdf.PDFNet;
|
||||||
|
|
||||||
import feign.FeignException;
|
import feign.FeignException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -57,11 +58,12 @@ public class OcrMessageReceiver {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("Successfully processed ocr for file with dossierId {} and fileId {}, took {}", ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId(), end - start);
|
log.info("Successfully processed ocr for file with dossierId {} and fileId {}, took {}", ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId(), end - start);
|
||||||
|
|
||||||
fileStatusProcessingUpdateClient.ocrSuccessful(ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId());
|
fileStatusProcessingUpdateClient.ocrSuccessful(ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId());
|
||||||
|
|
||||||
|
PDFNet.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user