Reader small image

You're reading from  OpenCV 3.0 Computer Vision with Java

Product typeBook
Published inJul 2015
Reading LevelIntermediate
Publisher
ISBN-139781783283972
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Daniel Lelis Baggio
Daniel Lelis Baggio
author image
Daniel Lelis Baggio

Daniel Lélis Baggio has started his works in computer vision through medical image processing at InCor (Instituto do Coração – Heart Institute) in São Paulo, Brazil, where he worked with intra-vascular ultrasound (IVUS) image segmentation. After that he has focused on GPGPU and ported that algorithm to work with NVidia's Cuda. He has also dived into 6 degrees of freedom head tracking with Natural User Interface group through a project called EHCI (http://code.google.com/p/ehci/ ). He also wrote “Mastering OpenCV with Practical Computer Vision Projects” from Packt Publishing.
Read more about Daniel Lelis Baggio

Right arrow

Displaying an image with Swing


OpenCV developers are used to a simple cross-platform GUI by OpenCV, which was called as HighGUI, and a handy method called imshow. It constructs a window easily and displays an image within it, which is nice to create quick prototypes. As Java comes with a popular GUI API called Swing, we had better use it. Besides, no imshow method was available for Java until its 2.4.7.0 version was released. On the other hand, it is pretty simple to create such functionality. Refer to the reference code in chapter2/swing-imageshow.

Let's break down the work in to two classes: App and ImageViewer. The App class will be responsible for loading the file, while ImageViewer will display it. The application's work is simple and will only need to use Imgcodecs's imread method, which is shown as follows:

package org.javaopencvbook;

import java.io.File;
…
import org.opencv.imgcodecs.Imgcodecs;

public class App
{
  static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

public static...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
OpenCV 3.0 Computer Vision with Java
Published in: Jul 2015Publisher: ISBN-13: 9781783283972

Author (1)

author image
Daniel Lelis Baggio

Daniel Lélis Baggio has started his works in computer vision through medical image processing at InCor (Instituto do Coração – Heart Institute) in São Paulo, Brazil, where he worked with intra-vascular ultrasound (IVUS) image segmentation. After that he has focused on GPGPU and ported that algorithm to work with NVidia's Cuda. He has also dived into 6 degrees of freedom head tracking with Natural User Interface group through a project called EHCI (http://code.google.com/p/ehci/ ). He also wrote “Mastering OpenCV with Practical Computer Vision Projects” from Packt Publishing.
Read more about Daniel Lelis Baggio