I am trying to capture text from image
This is my service class code
@Service
public class ImagePreprocessingService {
static {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
public File preprocessImage(File imageFile) throws IOException {
enhanceImageQuality(imageFile);
return imageFile;
}
private void enhanceImageQuality(File imageFile) {
String str = imageFile.getAbsolutePath();
System.out.println(str);
Mat src = Imgcodecs.imread(str, Imgcodecs.IMREAD_GRAYSCALE);
// Resize the image
Imgproc.resize(src, src, new Size(src.width() * 2, src.height() * 2), 0, 0, Imgproc.INTER_CUBIC);
// Apply GaussianBlur to reduce noise
Imgproc.GaussianBlur(src, src, new Size(3, 3), 0);
// Apply thresholding to binarize the image
Imgproc.threshold(src, src, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU);
Imgcodecs.imwrite(imageFile.getAbsolutePath(), src);
}
}
I have extracted file of openCV in my system and I have configured my environment variables as well
I am getting this error, when I execute the code
java.lang.UnsatisfiedLinkError: 'long org.opencv.imgcodecs.Imgcodecs.imread_0(java.lang.String, int)'
at org.opencv.imgcodecs.Imgcodecs.imread_0(Native Method) ~[opencv-4.5.1-1.jar:na]
at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:185) ~[opencv-4.5.1-1.jar:na]