Building IPython from git in Windows

IPython is basicly an interactive python shell. The interesting part is the IPython notebook and IPython qt shell where you are allowed to display inline plots and images.

IPython notebook is also very useful when sharing an implementation detail/tutorial or a code block with a friend/colleague.

If you put your notebook file somewhere publicly visible, nbviewer can render it for you, allowing to share your documents with anybody even though they don't have python/ipython installed.

You can install IPython for windows through WinPython distribution automatically. However IPython is very actively being develeoped, so using stable releases you may miss a quite a few features.

That brings us to the main goal of this post, how to build IPython from git in windows:

First the requirements:

  • Git for windows.
  • A python distribution. I prefer WinPython.
  • Python and scripts folders added in path enviroment variable.
    For WinPython, add the following to the path:
    C:\SDK\WinPython-32bit-3.3.2.1\python-3.3.2\Scripts; C:\SDK\WinPython-32bit-3.3.2.1\scripts;

Now the actual steps:

  1. Run Git Bash
  2. cd into your favorite development folder, i.e.
    cd /c/SDK/
  3. type the following git command
    git clone --recursive https://github.com/ipython/ipython.git
  4. when complete
    cd ipython
  5. type the following command to build IPython
    easy_install .

That's it!

Getting Started with Vuforia and Android NDK for Augmented Reality Applications

  1. Setup your Android Development Environment.
  2. Setup your Android NDK Environment.
  3. Install Vuforia SDK.
    1. Download the newest release from www.vuforia.com.
    2. Unzip the SDK to somewhere you like, ex:
      C:\SDK\android\vuforia-sdk-android-xx-yy-zz
    3. Set the QCAR Environment variable
      1. In Eclipse, go to Window->Preferences.
      2. Navigate to Java->Build Path->Classpath Variables using the hierarchy browser.
      3. Create a new variable by selecting New...
      4. Add:
        QCAR_SDK_ROOT
        into the Name: field, and navigate using Folder... to the Vuforia SDK root folder. In ex:
        C:\SDK\android\vuforia-sdk-android-xx-yy-zz
  4. You are now ready to import one of the samples and start playig. Remember Vuforia SDK requires an actual Android Device it would not work on emulators.
  5. After importing samples, don't forget adding native support and setting up debugging flags for the NDK compiler, as described here

Setting up Android NDK Development and Debugging inside Eclipse

To follow the steps, you should have an up and running Android SDK environment. If you don't, you can follow this guide.

  1. Download the latest Android NDK from:
    http://developer.android.com/tools/sdk/ndk/index.html
    You should match the instruction sets of your SDK, JDK and NDK. In example, if you have an x86 Android SDK you should download the x86 NDK.
  2. Extract the contents to a folder of your liking, ex:
    C:\SDK\android\android-ndk-r8e-windows-x86\
  3. Install the NDK plugin through ADT
    1. In eclipse click, Help -> Install New Software
    2. In the Work with field select
      Android Developer Tools Update Site - http://dl-ssl.google.com/android/eclipse/
      from the dropdown menu and hit enter.
    3. Check the NDK Plugins box, and click next.
    4. ADT should automatically download and install the plugins
  4. Setting NDK path
    1. In eclipse, Window -> Preferences
    2. From the list on the left, expand Android and select NDK.
    3. Enter the folder you extracted the NDK files, to NDK Location field.

At this point everything is set up and should be working, however there are some additional steps to be able to build and debug an NDK project.

To convert a sample project to Native project:

  1. In Eclipse, File -> import; then expand Android and select Existing Android Code Into Workspace
  2. Browse for a simple sample project, ex:
    C:\SDK\android\android-ndk-r8e\samples\hello-jni
  3. Click Finish.
  4. Right click the project name, go to Android Tools and click Add native support
  5. Don't change the lib name, and click finish.

To debug native code:

  • In eclipse, double click on hello-jni.c which is under jni folder.
  • You should see the following code:
jstring  
Java_com_example_hellojni_HelloJni_stringFromJNI(JNIEnv* env,
jobject thiz )
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
  • insert a break point to return line
  • however you may also need to add the following:
jstring  
Java_com_example_hellojni_HelloJni_stringFromJNI(JNIEnv* env,
jobject thiz )
{
sleep(5);
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
  • This enables the gdb_server to catch up. Since it takes a few seconds for native debugging to start working, sleeping here for 5 seconds allows us to catch the break point in the return line.
  • Right click the project and hover on debug as then click Android Native Application
  • The debugger should kick in and the execution would stop at the breakpoint.

Setting up Android SDK Development Environment

  1. Download the Android SDK bundle from:
    http://developer.android.com/sdk/index.html#download
    I have downloaded the 32-bit Windows version, however it shouldn't differ very much between other OS'es or 64bit editions.
  2. Extract the files to some folder, ex:
    C:/SDK/android/
    So that you would have eclipse and SDK folder under android
  3. Go to eclipse sub-folder and run eclipse.exe If eclipse runs, go to step 4, else:
    1. You probably got an error like:
      JDK Not Found Error
    2. You need to download latest JDK from Oracle:
      http://www.oracle.com/technetwork/java/javase/downloads/index.html
      If you previously downloaded 32bit version of the SDK, you should also download the x86 version of JDK, vice versa for x64.
    3. After installation add java binaries folder to your path, typically they are located at:
      C:\Program Files (x86)\Java\jdk1.7.0_25\bin
    4. Try running eclipse.exe again, this time the IDE should load.
  4. Fire up SDK Manager which is located next to eclipse and SDK folders.
    And install the updates and API's you would like to use.
  5. We're done, enjoy!

Getting started with QCAR

I have written a never version of this post with updated information, you can find it here.

  1. Get an account for QDevNet:
    http://developer.qualcomm.com/user/register
  2. Get another for QCAR SDK: I have no idea why, but you need different accounts for QDevNet and QCAR
    https://ar.qualcomm.com/qdevnet/user/register
    This is the account you will login to download SDK files, your password is sent via an email.
  3. Go to the main SDK page:
    https://ar.qualcomm.com/qdevnet/sdk
  4. Using the link above, download the distribution, you would like to use. I will continue this howto assuming you've downloaded, qcar-sdk-1.0.0.bin for linux.
  5. Open a terminal window
    1. cd into your downloads folder
    2. chmod 755 qcar-sdk-1.0.0.bin to set the executable bit.
    3. and run the installer via ./qcar-sdk-1.0.0.bin
    4. You can change the installation path as you like
  6. Set up environment variables
    1. Start Eclipse
    2. Window -> Preferences
    3. Java->Build Path->Classpath Variables
    4. set QCAR_SDK_ROOT as your installation directory
    5. default value is /home/yourUserName/Development/Android/qcar-sdk-xx-yy-zz
  7. Open a sample project
    1. In eclipse
    2. File -> Import
    3. Existing Projects into Workspace
    4. Select root directory: the default is
      /home/yourUserName/Development/Android/qcar-sdk-xx-yy-zz/samples/
  8. Please keep in mind that these projects uses Native code development, so make sure that;
    1. Android NDK is installed
    2. ndk-builder is in path
    3. Set up eclipse to work with NDK projects

OpenCV on Android

 

How to: android-opencv development
  1. svn checkout http://android-opencv.googlecode.com/svn/trunk/ android-opencv-read-only
  2. Steps 2, 6 and 7 are from the readme //may change in the future, so check before proceeding. ( http://code.google.com/p/android-opencv/wiki/opencv )
    use crystax ndk 4 - http://crystax.net/android/ndk.php
    OpenCV needs this custom NDK, which has STLport support
    Direct Download link:
    http://www.crystax.net/data/android-ndk-r4-linux-x86-crystax-4.tar.bz2 
  3. Extract the downloaded file to: 
    ~/android-ndk-r4-crystax
  4. Add NDK to your path
    1. open a text editor
    2. open ~/.bashrc file
    3. append the following lines (replace “mustafae” with your own username.
      PATH="${PATH}":/home/mustafae/android-ndk-r4-crystax
      export PATH
  5. sudo apt-get install swig
    //for automatic generation of native library bindings
  6. cd android-opencv-read-only/opencv
  7. sh build.sh
  8. Get a cup of tea.
  9.