Java

A good library for image processing (computer vision) – OpenCV

http://ubaa.net/shared/processing/opencv/

OpenCV is an open source computer vision library originally developed by Intel. It is free for commercial and research use under a BSD license. The library is cross-platform, and runs on Mac OS X, Windows and Linux. It focuses mainly towards real-time image processing, as such, if it finds Intel’s Integrated Performance Primitives on the system, it will use these commercial optimized routines to accelerate itself.

This implementation is not a complete port of OpenCV. Currently, this library supports :

  • real-time capture
  • video file import
  • basic image treatment (brightness, contrast, threshold, …)
  • object detection (face, body, …)
  • blob detection

Future versions will include more advanced functions such as motion analysis, object and color tracking, multiple OpenCV object instances …

For more information about OpenCV visit the Open Source Computer Vision Library Intel webpage, the OpenCV Library Wiki, and the OpenCV Reference Manual (pdf).

 

Question: is there a Java library to manipulate Microsoft documents?
Answer: check out Apache POI – the Java API for Microsoft Documents

 

A Processing/Java library for physics based simulations

https://github.com/diwi/PixelFlow

 

Java multi-thread (concurrency) example

Two class files; using ExecutorService instead of working with threads directly. This is the preferred way…

myWorker class
 public class myWorker implements Runnable {

     int thread_no;

     public myWorker(int thread_no) {
       this.thread_no = thread_no;
     }

     @Override
     public void run() {

       for (int i = 0; i < 500; i ++ ) {
           System.out.println("We are in thread# " + thread_no + " and the current number is " + i);
       }
       System.out.println("Thread# " + thread_no + " is completed.");

     }

}

main class

public class JavaThreadExample2 {

     public static void main(String[] args) throws InterruptedException {

         int nThreads = Runtime.getRuntime().availableProcessors();
         System.out.println("Ok, we have maximum " + nThreads + " threads available.");
 
         ExecutorService myExecutor = Executors.newFixedThreadPool(nThreads);
 
         for (int i = 0 ; i <= nThreads; i++)
         {
 
             Runnable worker = new myWorker(i);
             myExecutor.execute(worker);
 
         }
 
         // This will make the executor accept no new threads
         // and finish all existing threads in the queue
         myExecutor.shutdown();
 
         // Wait maximum 6 hours until all threads are finish
         myExecutor.awaitTermination(6L, TimeUnit.HOURS);
         System.out.println("Finished all threads");
     }
 
}

Q: How to choose a different version of Java as the default runtime on Ubuntu?

$sudo update-alternatives –config java.

For example, PDFsam Basic only works with Java 8. If you have multiple versions of Java installed, you will need to update the default runtime then to make it work. Otherwise, PDFsam Basic won’t start.