RED-7669: optimize OCR-module performance

* moar sigsegv
This commit is contained in:
Kilian Schuettler 2023-11-15 17:19:11 +01:00
parent 12217f2459
commit 574f7ac25e
2 changed files with 6 additions and 11 deletions

View File

@ -1,11 +1,8 @@
package com.knecon.fforesight.service.ocr.processor.service.threads;
import static com.knecon.fforesight.service.ocr.processor.utils.NativeMemoryAllocationUtils.getDetectionScriptBuffers;
import static net.sourceforge.tess4j.ITessAPI.TRUE;
import java.io.File;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.file.Path;
import java.util.List;
import java.util.NoSuchElementException;
@ -18,7 +15,6 @@ import com.knecon.fforesight.service.ocr.processor.service.OcrProgressLogger;
import com.knecon.fforesight.service.ocr.processor.service.Statistics;
import com.knecon.fforesight.service.ocr.processor.utils.NativeMemoryAllocationUtils;
import com.knecon.fforesight.service.ocr.processor.utils.Tesseract2;
import com.sun.jna.ptr.PointerByReference;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
@ -133,12 +129,12 @@ public class OCRThread extends Thread {
int orient_deg = 0;
int result = TessAPI1.TessBaseAPIDetectOrientationScript(detectionScriptHandle,
buffers.orient_degB(),
buffers.orient_confB(),
buffers.script_nameB(),
buffers.script_confB());
buffers.orientationDegreeResultBuffer(),
buffers.orientationDegreeConfidenceBuffer(),
buffers.scriptureNameBuffer(),
buffers.scriptureConfidenceBuffer());
if (result == TRUE) {
orient_deg = buffers.orient_degB().get();
orient_deg = buffers.orientationDegreeResultBuffer().get();
}
synchronized (OCRThread.class) {

View File

@ -3,7 +3,6 @@ package com.knecon.fforesight.service.ocr.processor.utils;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import com.knecon.fforesight.service.ocr.processor.service.threads.OCRThread;
import com.sun.jna.ptr.PointerByReference;
import lombok.experimental.UtilityClass;
@ -21,7 +20,7 @@ public class NativeMemoryAllocationUtils {
}
public record DetectionScriptBuffers(IntBuffer orient_degB, FloatBuffer orient_confB, PointerByReference script_nameB, FloatBuffer script_confB) {
public record DetectionScriptBuffers(IntBuffer orientationDegreeResultBuffer, FloatBuffer orientationDegreeConfidenceBuffer, PointerByReference scriptureNameBuffer, FloatBuffer scriptureConfidenceBuffer) {
}
}