小编Kal*_*ali的帖子

使用opencv(Java)的阈值图像

我正在为我的项目使用Opencv.我需要将下面的图像转换为阈值图像

原始图像

我试过这个功能:

Imgproc.threshold(imgGray, imgThreshold, 0, 255, Imgproc.THRESH_BINARY + Imgproc.THRESH_OTSU); 
Run Code Online (Sandbox Code Playgroud)

但结果并不那么好,如下所示

阈

所以我尝试了adaptiveThreshold function:

Imgproc.adaptiveThreshold(imgGray, imgThreshold, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 11, 2); 
Run Code Online (Sandbox Code Playgroud)

结果如下:

adaptiveThreshold

我只是期望二进制图像只有白色背景和黑色文本,没有黑色区域或噪音(我不喜欢使用,Photo.fastNlMeansDenoising因为它需要很多时间).请帮我解决这个问题.

此外,我正在使用Tesseract日语识别,但准确率不高.您对日本的更好的OCR或任何提高Tesseract质量的方法有什么建议吗?

java android opencv tesseract image-processing

10
推荐指数
1
解决办法
2万
查看次数

使用HashMap的多线程Java Singleton Synchronization

我有以下课程:

public class AggregationController {


    private HashMap<String, TreeMap<Integer, String>> messages; 
    private HashMap<String, Integer> counters;  
    Boolean buildAggregateReply;
    private boolean isAggregationStarted;

    private static HashMap<String, AggregationController> instances = new HashMap<String, AggregationController>();

    private AggregationController() throws MbException{
        messages = new HashMap<String, TreeMap<Integer,String>>();
        counters = new HashMap<String, Integer>();
        buildAggregateReply = true;
        isAggregationStarted = false;
    }

    public static synchronized AggregationController getInstance(String id) throws MbException{
        if(instances.get(id) == null)
            instances.put(id, new AggregationController());
        return instances.get(id);
    }   
Run Code Online (Sandbox Code Playgroud)

我认为这足以避免并发访问,但我收到了这个错误:

HashMap.java
checkConcurrentMod
java.util.HashMap$AbstractMapIterator
java.util.ConcurrentModificationException
Unhandled exception in plugin method
java.util.ConcurrentModificationException
Run Code Online (Sandbox Code Playgroud)

我有10个线程使用这个类,它每100次调用大约抛出一次这个错误.

这个单身人士怎么了?

java singleton multithreading hashmap synchronized

6
推荐指数
1
解决办法
1407
查看次数

OpenShift 中的 Spring 批处理 JDBCPagingItemReader、ThreadPoolTask​​Executor 和多个 pod

我们有一个带有块处理功能的 Spring 批处理应用程序,它作为编写器的一部分从数据库读取记录,处理它们并调用服务/执行一些插入/更新数据库中的一些表。

JDBCPagingItemReader已被使用,因为当 saveState 为 false 时它是线程安全的。已设置排序键,因此线程不会相互交叉。Oracle 数据源和Spring 批处理的配置也ISOLATION_READ_COMMITTED使用了隔离级别。JobRepository

ThreadPoolTaskExecutor目前,在单个实例中使用多线程效果很好。

我们最终应该在 OpenShift 中部署这个 Spring Boot 应用程序,该应用程序将在多个 PODS 中运行,即应用程序的多个实例,它们都从同一个表中读取。

有相关知识的人可以告诉我在多个 Pod(实例)中使用上述组合是否会出现任何问题,或者是否存在必须处理的并发问题。

这种情况下的任何最佳实践都受到高度赞赏。

谢谢你的时间。

java oracle spring-batch openshift spring-boot

5
推荐指数
1
解决办法
584
查看次数