A good library for image processing (Computer Vision) – 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).


Personal note: how to increase the menu font size in Netbeans with 4K display

The default font size used in menus, dialogs, views, etc. is too small. Can I make it bigger?

Yes. The size of the interface font is controlled by the --fontsize <size> option. The default <size> value is 11. You can set it to 12 or even a higher value and see if it works better for you. The --fontsize argument applies to fonts used in menus, dialogs and most components in the IDE.

To change the GUI font-size only once, you can launch NetBeans with the --fontsize <size> option.

To change the GUI font size permanently, edit netbeans.conf file. Specifically, in netbeans.conf (which is located in the /etc folder of your NetBeans installation), look for the line that starts with “netbeans_default_options=”. Edit the fontsize parameter if present. If not, add something like “–fontsize 16” (without the quote) at the end of the line.

The size of fonts used in editors (rather than the user interface) is also based on the --fontsize parameter, unless it has been customized in Tools | Options | Fonts & Colors (or Tools | Options | Editing | Editor Settings in older versions).


Run NetBeans with a larger font size:

netbeans --fontsize 14

Run NetBeans with Metal L&F and a larger font size:

netbeans –laf javax.swing.plaf.metal.MetalLookAndFeel –fontsize 14

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


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;

     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);
         // This will make the executor accept no new threads
         // and finish all existing threads in the queue
         // 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.