Search This Blog

Loading...

Thursday, October 18, 2012

Kinect within VMWare

Recently Microsoft announces the availability of the Kinect 1.6 SDK. One of the big enhancements in this release is the support for the Kinect device within a virtual machine (VMWare or Parallels)!

For a client we developed a Kinect application which was shown at the Dutch Floriade festival. More details about this project in a next post.

The problem with the old Kinect SDK was the inability to use the Kinect within a virtual machine. Because of this I had to create a bootcamp partition and install Windows on it just for the sole purpose of Kinect development. The 1.6 SDK solves this!

Below are the results of my tests with the Kinect within VMWare. I used the following system configuration to test on:
  1. MacBook pro 2011 with 2Ghz core i7 and 8GB RAM..
  2. OSX Mountain Lion.
  3. VMWare Fusion 5 running Windows 7.
  4. Visual Studio Express 2012.
  5. Kinect 1.6 SDK.
First I tested the above setup with the Xbox Kinect. This did not work which I more or less expected since Mircosoft wants to push the Kinect for Windows for Kinect development.

Next I tested was the Kinect for Windows. After I connected the device I started the Shape Game sample application. The device was found and worked immediately! I also tested the Kinect with our own application and this also worked as expected.

Ont thing I noticed was that both applications did not run as smooth as when I ran the application under bootcamp. After examing my virtual machine settings I noticed I had given it only 1 cpu core (out of the available 8). This could be the problem. When I changed the maximum number of cpu cores the virtual machine may use to 4, things ran much smoother. There was no noticeable difference when running within a virtual machine or bootcamp. 

For more information about the 1.6 SDK see: http://msdn.microsoft.com/en-us/library/jj663803.aspx#SDK_1pt6_M2.

Conclusion
The new Kinect 1.6 SDK does work within a virtual machine if the Kinect for Windows is used.


Thursday, October 4, 2012

IntelliJ SSR: replace constructors

Suppose you have a large codebase which uses a particular class named SomeClass (nice descriptive name :)). SomeClass has one constructor:

public SomeClass(String a, String b, String c, String d) {
    // Do something
}

This constructor is used at various places in the codebase.

At some point in time an update to SomeClass is made which introduced another constructor:

public SomeClass(String a, String b) {
    // Do something
}


Lets assume you want all calls to the 4 argument constructor to be replaced by the 2 argument constructor. The arguments of the 4 argument constructor should be used in the 2 argument constructor in the following way: new SomeClass(1, 2, 3, 4) becomes new SomeClass(3, 1).

See the following example:


public class UsageOfSomeClass {
    private SomeClass instance_1 = new SomeClass("a", "b", "c", "d");
    private SomeClass instance_2 = new SomeClass("d", "e", "f", "g");
    private SomeClass instance_3 = new SomeClass("h", "i", "j", "k");

    public static void main(String[] args) {
        SomeClass someClass = new SomeClass("1", "2", "3", "4");
    }
}

Should become:

public class UsageOfSomeClass {
    private SomeClass instance_1 = new SomeClass("c", "a");
    private SomeClass instance_2 = new SomeClass("f", "d");
    private SomeClass instance_3 = new SomeClass("j", "h");

    public static void main(String[] args) {
        SomeClass someClass = new SomeClass("3", "1");
    }
}

You can achive the following for an entire codebase with one single structural search and replace action. Use the following templates to achieve this:

Search template: new SomeClass($arg1$, $arg2$, $arg3$, $arg4$)
Replace tempalte: new SomeClass($arg3$, $arg1$)

Hit find and Replace All. Thats it!