Thursday, March 29, 2007

Mean Shift Tracking in Java

After long long attempts to learn - understand the Mean Shift tracking, I have finally implemented the Kernel Based Object Tracking in Java. First I have tried to implement the tracker in openCV but I had some problems with the rectangle selection(the bounding box) so I moved back to Java and implemented the code offline using Java Media FrameWork. I have written a nice small class using JMF which we can use to extract frames out of a given Video file. There is no support for WMV format - it says NoPlayerException and some DivX formats, but then most of the files were played successfully.

My tracking results are shown below. Shown are the first, 19th and the 10th frame of a striker - video courtesy "WEB".

Monday, March 12, 2007 2.0 - fun to learn

I have just started working on ASP.NET 2.0 again after a long long time. Its been almost an year since I did some serious coding and I want to get myself updated with the latest - 2.0.

I decided to use the Core ASP.NET reference book from MS Press and have been going through fundas like the IIS 6.0 Process model, HttpRuntime queue and so on.

How to detect the browser programatically in ASP.NET?
You have the Request object with you. You can access the Request object either directly or from the HttpContext object. To detect the browser you are running ....

Dim browser as String = HttpContext.Current.Browser.Browser

For IE, browser would be "IE" and for firefox, its Firefox.

More about the HttpContext....

Actually, ProcessRequest method is called on the HttpRuntime object when a request arrives. Just before it serves a page to the request, a "context" is created which could be accessed through the HttpContext object. The HttpRuntime object uses the HttpContext object to locate or create a Web App object that is capable of handling a request it gets. There is an internal object that will be used to do the search - HttpApplicationFactory which maintains a pool of HttpApplication objects to serve incoming http requests. The HttpApplication is the base class that represents a running ASP.NET application. It is this object that determines what kind of a handler is needed - basically it decides what kind of resource is being requested - whether its a web page being asked for or a web server or a server control, etc.

Page Class and important members

The following is the list of important members of the Page class.
  1. Application - instance of HttpApplicationState
  2. Cache - instance of Cache class, implements cache for an application
  3. Request - instance of HttpRequest
  4. Response - instance of HttpResponse
  5. Server - instance of HttpServerUtility, helper method for processing web requests.
  6. Session - instance of HttpSession.
  7. Trace - instance of TraceContext, used for tracing.
  8. User - represents the current user whose request is being processed.
There is also a Context object that could be used ( it holds for HttpContext.Current).

From my past experience coding ASP.NET web apps, one most important thing that a newbie should always learn is the Page life cycle. By Life cycle in an application programming model, we basically mean what events are fired at what time. The ordering of events become very essential especially when the application grows. Knowing where to put initialization code, where to add controls dynamically, etc will help us code better applications.

The ASP.NET Web Page life cycle is given below.
  1. PreInit
  2. Init
  3. InitComplete
  4. View State is now restored
  5. Posted data is processed
  6. PreLoad event is fired
  7. Load event is raised
  8. LoadComplete (in between few events for handling postback is taken care of)
  9. PreRender
  10. PreRenderComplete
  11. SaveStateComplete
More information is given here
ASP.NET 2.0 Page Life cycle

I will post more as I get deep into the subject. I plan to devote an hour a day once the spring break is over.

This is what I think I will/should be doing
1. Core ASP.NET 2.0
2. Data binding with ASP.NET 2.0 and ofcourse ADO.NET

Then may be I can get hands-on with XAML,WPF,WCF,Windows Workflow...Gosh there is a lot to learn....