Friday, March 4, 2016

Processing and OpenCV for Video Movement Detection

Hi everybody!

Find below a little experiment done with Processing and OpenCV for Processing to detect movement in a Camera-Video-Stream. I put together the Capture Sample from Processing and the Contour Sample from OpenCV for Processing (https://github.com/atduskgreg/opencv-processing/blob/master/examples/BackgroundSubtraction/BackgroundSubtraction.pde) to achieve this.

import gab.opencv.*;

import processing.video.*;

Capture cam;
OpenCV opencv;

int lastContourRefresh = millis();
int contourRefreshTreshold = 100000;

void setup() {
  size(1280, 720);

  opencv = new OpenCV(this,1280, 720);
  opencv.startBackgroundSubtraction(2,3,0.5);

  String[] cameras = Capture.list();
  
  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }
    
    // The camera can be initialized directly using an 
    // element from the array returned by list():
    cam = new Capture(this, cameras[0]);
    println("chosen cam: " + cameras[0]);
    cam.start();     
  }      
}

void draw() {
  
  if(cam.available()) {
     cam.read();
  }
  
  image(cam, 0, 0);

    try {
         opencv.loadImage(cam);
    } catch (RuntimeException e ) {
      
    }
    opencv.updateBackground();
    opencv.dilate();
    opencv.erode();
    
    noFill();
    stroke(255, 0, 0);
    strokeWeight(3);
    
    for (Contour contour : opencv.findContours()) {
      contour.draw();
    }
    
    lastContourRefresh = millis();
}

Wednesday, July 22, 2015

Jira Mylyn Connector for Eclipse Mars

For all of you who use Jira with Mylyn and just switched to Eclipse Mars: there is actually no Jira-Connector available if you ask for in the Mylyn Repository-Dialog. So you have to install it for your own by adding the update-site: http://update.atlassian.com/atlassian-eclipse-plugin/rest/e3.7

Even if the connector is supposed to be used up to Eclipse Luna it also works with Eclipse Mars.

Wednesday, April 29, 2015

Testing AngularJS Services with Jasmine

If you write unit test for your angularjs application you may already read the documentation provided by the angularjs website. It has a lot of good information but i missed the description of how to test services that i wrote for my application. For angularjs services the jasmine setup code looks like:

beforeEach(inject(function(_$controller_){
    $controller = _$controller_;
  }));


The _$controller_ is an internal representation of the angularjs controller service, $controller is a local variable.

So, how does injecting of a custom service work? Well, it is easy...

beforeEach(inject(function(_YourService_){
    $localService = _YourService_;
  }));


And the service code:
yourAppServices.factory('YourService', [function($http, ESCommons) {
  return {...}]);

Monday, April 27, 2015

Voxxed - News for Java Developers

If you are looking for the latest news about Java and Web-Technologies you might want to have a look at voxxed.com! This site presentates a lot of information about Java and similiar topics (Grooovy, JavaScript, BigData).

Saturday, April 4, 2015

Javaland 2015 - Day 2

Better late then never here it is, my summary of our second day at Javaland 2015 :-)!

After a first day with a lot of interesting talks and fantastic rides with the Black Mamba we started day 2 at Javaland. This day came up with a lot of JavaFX talks. Perfect, because the last Project at work made heavy use of JavaFX. So i decided to take a look how other programmers work with JavaFX.

Hendrik Ebbers from Canoo and Alexander Casall (Saxonia AG) started after the Keynote with "Enterprise Applications with JavaFX". They gave an overview how to build JavaFX Applications that communicate with JEE Backend Systems and gave some best practice tips how to bind data models to their corresponding view (Model-View-View-Model Pattern), and how to synchronize views between two instances of one JavaFX Application. Theyalso mentioned some interessting JavaFX Libraries that addresses the named Topics:


Well, as you can see, Java Developers are not very creativ when inventing a Name for a library ;-)

IoT

Another big Topic at day two was IoT - Internet of things. Maybe you did not know this term you probably get in touch with it. Since not even Computers and Smartphones but also TVs, Refrigerators, Watches and lot more devices can connect to the Internet we talk about the IoT. To get an easy introduction into that Topic i decided to watch "IoT Magic Show" with Stephen Chin (yeah, the men with the Motorcycle :-) ). Stephen and a colleague explained IoT with the help of three Magic tricks. The most impressing one was the first one. Three People from the audience had to choose one gamingcard and Stephens colleague had to guess what gaming they had choosen. As you might guess he guessed right every Card!
The trick mainly based on an really tiny RFID-Chip inside every Card. With a Little RFID detector hidden in his Hand, he hovered over the Card with the face down. The RFID-Chip transmitted the type of the Card to the detector. Over a Network the result was transmitted to a RasberryPI and finally send to Google Glasses.
That showed how Network capable devices can communicate with each other.

2048

Need a break after a lot of reading? How about playing 2048 to relax? If you don't know 2048 the game you may want to checkout http://gabrielecirulli.github.io/2048/. It is fun and easy to learn!

Bruno Borges and a colleague showed their implementation of 2048 with JavaFX in the next talk. They covered how they did the databinding, the design and the animations with JavaFX to achieve the typical 2048 Feeling. Finally they introduced the port to Android Devices, done with JavaFXPort (http://www.javafxports.org/page/home). You can find the app in the Play-Store https://play.google.com/store/apps/details?id=org.jpereda.game2048

Groovy Traits

A less visited talk but not less interessting was "Traits and their usage inside groovy" by Jochen Theodorou. Jochen talked about the reason why they invented and implemented traits and why it is better to use traits then mixins.
With a lot of examples he showed use cases and best practices.

Projector Pattern

Finally we visited "Efficency and Flexibility of the projector pattern" by Dierk König. Maybe you don't know the pattern it is very likely that you already used this pattern when you programmed some GUI Application. In short words the projector pattern is when you work with an API that describes what the GUI should Display, but not how things are displayed. For this reason you use a Projector and only the projector knows how to Display GUI Elements.

Tuesday, March 31, 2015

Orbit, a new Akka competitive

Bioware the developer of a lot of famous Computer Games announced an Open Source Project for distributed Applications. This project is used by Bioware itself for there Systems, written in Java and distributed with a BSD Licence.
If you know Akka you instantly feel at home when looking at Orbit and its Documentation. So go on and start into the orbit from https://github.com/electronicarts/orbit ;-)

Sunday, March 29, 2015

Javaland 2015

Javaland 2015


It is only a few days since a colleague of mine and i went to Javaland in Phantasialand near Brühl, so it is not to late to give you a summary of the talks i visited. Hope you enjoy :-)

Day 1

Day 1 started with "Lambdas and Streams, Functional Programming with JDK 8" by Simon Ritter. Even for those that were familiar with Lambdas and Streams Simon came up with some best practices using these new Technologies. He highly recommended to avoid using for-each and showed code examples how to do that while working with streams.

Next there was "Understanding Java Bytecode" with Rafael Winterhalter. He started with an introduction to Java Bytecode so everybody got an idea what that is and how you can use it to enhance your application. In the second part of his talk he introduced his ByteCode Framework "Byte Buddy". Byte Buddy has a fluent pattern based API to generate code during runtime. Check it out on http://bytebuddy.net

For all fans of NoSQL DBs Stefan Hochdörfer had a very interesting talk where he showed how to use PostgreSQL Features to mimic some NoSQL DB behavior. This can be done using one or more in combination of the following PostgreSQL Data types:
  • Arrays
  • hstore
  • JSON / JSONB
  • XML
With a ton full of examples he showed how to access fields of these types and how to manipulate them. It was very interesting to see how to access Array fields or JSON fields in one select Statement. You can find the PowerPoint at http://t.co/Qq9VsG7ugz

Even we visit JAVAland Javascript was subject of a lot of talks. So of "TypeScript, Javascript für Java-Entwickler" ("TypeScript, JavaScript for Java-Developers") by Kai Tödter. TypeScript is developed by Microsoft under an OpenSource Licence and brings known OO Features to Javascript. For more Information and Demos visit http://www.typescriptlang.org/.

After lunch we did a deep dive,  Daniel Mitterdorfer explained in "Make or Break: The Big Impact of Small Changes in Performance" how small changes in Java Code can influence or even break CPU Functionalities like CPU Caches and Branch Predictions. For Performance analysing he used JMH (http://openjdk.java.net/projects/code-tools/jmh/) that showed the differences after small changes. You can find his slides here: http://daniel.mitterdorfer.name/talks/2015/make-or-break/#/

Because Java Bytecode is fun i visited "Programming Java Bytecode with Jitescript" presented by Joe Kutner. Joe gave an introduction to Java Bytecode and ended with some Demos of Jitescript. Jitescript itself is only meant to create new classes during runtime, modifcation of existing Bytecode is not possible. If you are interested in Frameworks that manipulates or analyse Bytecode you should checkout Byteman, Javaassist or DRGarbage.