Categories
code Java linux programming school video Website

SmartHome – Embedded computing course project

Hi
In the past few weeks I have been working hard at a few projects for end-of-term at Uni. One of the projects is what I called “SmartHome”, for Embedded computing [link] course, is a home monitoring [link] application. In the course the students were given an LPC2148 arm7-MCU (NXP) based education board, implemented by Embedded Artists [link]. My partner Gil and I decided to work with ZigBee extension modules [link] to enable remote communication.
Here are the steps we took to bring this project to life.

Categories
code graphics opencv vision

Recoloring via Histogram Matching with OpenCV [w/ code]

Hi
I wanted to do the simplest recoloring/color-transfer I could find – and the internet is just a bust. Nothing free, good and usable available online… So I implemented the simplest color transfer algorithm in the wolrd – Histogram Matching.
Here’s the implementation with OpenCV

Categories
graphics programming Website work

Extending Justin Talbot's GrabCut Impl [w/ code]

Justin Talbot has done a tremendous job implementing the GrabCut algorithm in C [link to paper, link to code]. I was missing though, the option to load ANY kind of file, not just PPMs and PGMs.
So I tweaked the code a bit to receive a filename and determine how to load it: use the internal P[P|G]M loaders, or offload the work to the OpenCV image loaders that take in many more type. If the OpenCV method is used, the IplImage is converted to the internal GrabCut code representation.

Image<Color>* load( std::string file_name )
{
 if( file_name.find( ".pgm" ) != std::string::npos )
 {
 return loadFromPGM( file_name );
 }
 else if( file_name.find( ".ppm" ) != std::string::npos )
 {
 return loadFromPPM( file_name );
 }
 else
 {
 return loadOpenCV(file_name);
 }
}
void fromImageMaskToIplImage(const Image<Real>* image, IplImage* ipli) {
 for(int x=0;x<image->width();x++) {
 for(int y=0;y<image->height();y++) {
 //Color c = (*image)(x,y);
 Real r = (*image)(x,y);
 CvScalar s = cvScalarAll(0);
 if(r == 0.0) {
 s.val[0] = 255.0;
 }
 cvSet2D(ipli,ipli->height - y - 1,x,s);
 }
 }
}
Image<Color>* loadIplImage(IplImage* im) {
 Image<Color>* image = new Image<Color>(im->width, im->height);
 for(int x=0;x<im->width;x++) {
 for(int y=0;y<im->height;y++) {
 CvScalar v = cvGet2D(im,im->height-y-1,x);
 Real R, G, B;
 R = (Real)((unsigned char)v.val[2])/255.0f;
 G = (Real)((unsigned char)v.val[1])/255.0f;
 B = (Real)((unsigned char)v.val[0])/255.0f;
 (*image)(x,y) = Color(R,G,B);
 }
 }
 return image;
}
Image<Color>* loadOpenCV(std::string file_name) {
 IplImage* im = cvLoadImage(file_name.c_str(),1);
 Image<Color>* i = loadIplImage(im);
 cvReleaseImage(&im);
 return i;
}

Well, there’s nothing fancy here, but it does give you a fully working GrabCut implementation on top of OpenCV… so there’s the contribution.

GrabCutNS::Image<GrabCutNS::Color>* imageGC = GrabCutNS::loadIplImage(orig);
 GrabCutNS::Image<GrabCutNS::Color>* maskGC = GrabCutNS::loadIplImage(mask);
 GrabCutNS::GrabCut *grabCut = new GrabCutNS::GrabCut( imageGC );
 grabCut->initializeWithMask(maskGC);
 grabCut->fitGMMs();
 //grabCut->refineOnce();
 grabCut->refine();
 IplImage* __GCtmp = cvCreateImage(cvSize(orig->width,orig->height),8,1);
 GrabCutNS::fromImageMaskToIplImage(grabCut->getAlphaImage(),__GCtmp);
 //cvShowImage("result",image);
 cvShowImage("tmp",__GCtmp);
 cvWaitKey(30);

I also added the GrabCutNS namespace, to differentiate the Image class from the rest of the code (that probably has an Image already).
Code is as usual available online in the SVN repo.
Enjoy!
Roy.

Categories
3d graphics Java opengl programming video

GeekCon 2009: RunVas – Our project [w/ video, img]

runvasHi everyone
In the last weekend I attended GeekCon 2009, a tech-conference, with a friend and colleague Arnon (not Arnon from the blog, who recently had a birthday – Happy B-Day Arnon!). Each team that attended had to create a project they can complete in 2-days of the conference. Our project is called “RunVas”, and the basic idea was to let people run around and paint by doing so. We wanted to combine computer vision with a little artistic angle.
Here’s some more details

Categories
graphics gui programming video

Awesome pictures fusing with a GIMP plugin [w/ code]

desert_bear_arrowSwitching, merging or swapping, call it what you like – it’s a pain to pull off. You need to spend a lot of time tuning the colors, blending the edges and smudging to get a decent result. So I wrote a plugin for the wonderful GIMP program that helps this process. The merge is done using a blending algorithm that blends in the colous from the original image into the pasted image.
I’ll write a little bit about coding GIMP plugins, which is very simple, and some about the algorithm and its sources.
Let’s see how it’s done

Categories
Android Java Mobile phones programming Solutions

Number Saver (Android application)

A very basic feature that I was missing in my Android phone is the ability to save a number while I’m in a call. Sure you can go to the home screen, and open up any app with a textbox, but I decided to create a dedicated application.
So, meet Number Saver!
UPDATE: Number Saver got a new look
Basic usage guide:

When you open the app you will get the main screen:
From here you are able to enter the number, copy to the clipboard, and clear the clipboard if it is full. Also, when you open the app, if there is a text in the clipboard it will already be in the text box. So you can press Dial to instantly dial the number
Also, during an active call you will notice the note and pencil icon. Stretching the notification area will give you the option to launch the application.
This app is available for free through the Android market. Donation is always welcome …

Categories
graphics Mobile phones programming video vision

Near realtime face detection on the iPhone w/ OpenCV port [w/code,video]

iphone + opencv = winHi
OpenCV is by far my favorite CV/Image processing library. When I found an OpenCV port to the iPhone, and even someone tried to get it to do face detection, I just had to try it for myself.
In this post I’ll try to run through the steps I took in order to get OpenCV running on the iPhone, and then how to get OpenCV’s face detection play nice with iPhoneOS’s image buffers and video feed (not yet OS 3.0!). Then i’ll talk a little about optimization
Update: Apple officially supports camera video pixel buffers in iOS 4.x using AVFoundation, here’s sample code from Apple developer.
Update: I do not have the xcodeproj file for this project, please don’t ask for it. Please see here for compiling OpenCV for the iPhone SDK 4.3.
Let’s begin

Categories
Android Java Mobile phones programming Solutions work

First steps in Android programming

Last week I finished my first Android application. All through the development stage I had to Google a lot for examples which some were really hard to find (even though you can find reference for everything in the SDK, for me, it’s easier to understand from a code sample).
My mobile company allows you to send 10 free daily SMS through their website, and after that each text message is still half priced, so I decided to take a challenge and create a UI that allows me to send my messages from the phone through the website automatically.
The core of my software was pure java, so even though it wasn’t straight forward to accomplish, I kinda know the material.
The main issues were after – when I got to the android implementation and UI
Here are the issues I needed, and will supply examples for in this post:
(Of course – for you that are more experienced than me with Android development, please forgive if I’m not doing everything ‘by the book’, it’s simply what I could find. So if you have any suggestions or improvement please send them to me or post a comment J )

  • How to find out if there is an active network on the device
  • How to create options menu
  • How to create and clear notification in the notification area
  • How to declare your program as “SMS Sender” (‘Complete action using…’)
  • Taking care of orientation (Landscape and Portrait mode for UI)

Here is the code I ended up using. Hope you find it helpful

Categories
3d graphics gui Java opengl programming school video

Advanced topics in 3D game building [w/ code, video]

snails_3dHi
The graphics course I took at TAU really expanded my knowledge of 3D rendering, and specifically using OpenGL to do so. The final task of the course, aside from the exam, was to write a 3D game. We were given 3 choices for types of games: worms-like, xonix-like and lightcycle-like. We chose to write our version of Worms in 3D.
I’ll try to take you through some of the problems we encountered, the decisions we made, and show as much code as possible. I’m not, however, gonna take you through the simple (yet grueling) work of actually showing meshes to the screen or moving them around, these subjects are covered extensively online.
The whole game is implemented in Java using JOGL and SWT for 3D rendering. The code is of course available entirely online.

Categories
Java programming

No CLASSPATH for you!

The Path of the ClassAs a part of my work, I was asked to create a semi-simulator for JNLP (Web-Start) loader.
The intention was to get the JNLP link, get all the necessary JARS and resources, and send the main class to another process that will run it as a host.
I had no previous in
troduction with JNLP what so ever… Well, first stage: look at the file.
Looking at the file revealed a simple XML file that contained all the necessary data.
So of course, first things first – Get all the JARS. But how?