Tracing wild rays


I havn't published in a while. I was back up with work on a project for uni., work and my writing...

But the good thing with keeping busy, is that after a while - you have something to show for! So here's what i've been working on for Comp. Graphics course - A Ray Tracer.

Continue reading "Tracing wild rays"


The proper way to run a remote process

This is the story of my journey to find a way to run a process (or a program on a remote pc)
This wasn't an easy thing at all...

Overall, I thought, this should be an easy thing to do.
I found this C# code on a Microsoft forums

object[] theProcessToRun = { "notepad.exe" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Username = "username";
theConnection.Password = "password";
ManagementScope theScope = new ManagementScope("<\\\\" + IP + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);

I tried this code, not after forgetting to disable the firewall on the remote computer - a big downside but I guess if I had gone with it I'd hunt a way to stable port to unblock in the firewall.


Then I found the big downside (which can be an upside to some of you):
The remote process this way will never have a GUI window opened (In this example, a process of notepad will be opened in the background).
This can be a big advantage to system admins which want to run scripts.


Ok, back to the quest.

Continue reading "The proper way to run a remote process"


Qt & OpenCV combined for face detecting QWidgets

As my search for the best platform to roll-out my new face detection concept continues, I decided to give ol' Qt framework a go.

I like Qt. It's cross-platform, a clear a nice API, straightforward, and remindes me somewhat of Apple's Cocoa.

My intention is to get some serious face detection going on mobile devices. So that means either the iPhone, which so far did a crummy job performance-wise, or some other mobile device, preferably linux-based.
This led me to the decision to go with Qt. I believe you can get it to work on any linux-ish platform (limo, moblin, android), and since Nokia baught Trolltech - it's gonna work on Nokia phones soon, awesome!

Lets get to the details, shall we?
Continue reading "Qt & OpenCV combined for face detecting QWidgets"


Cheat your (torrent) way to the top

utorrent_logoPrivate BitTorrent trackers require that you keep a certain upload/download ratio. This basically means that if you download, and don't leave your client running for seeding for as much as you downloaded, you will probobly get kicked out of the site sooner or later.

RatioMaster is an open source project that emulates your favourite client and sends the tracker with false info, saying that you are uploading. What a great solution for people with low upload rate.

A guy that calls himself NRPG, created his own version of RatioMaster, which added a lot of features to the original RatioMaster.  His version looks out for your opened client, and takes all the random-generated values from it, that way making the tracker very hard to spot the cheat.

So far so good, as this was only the exposition to the situation.

Continue reading "Cheat your (torrent) way to the top"


Scanning your entire LAN for MAC Addresses

Not too long ago, I wrote a network administration utility with specific needs.

One of the needs was to scan all the LAN pool for MAC addresses.

The code will look at your active network adapters, calculate start and end IP according to your address and netmask,

and query all the IPs within that range for their MAC address.

The code is written in C#, and it's basically going over the whole range in a nested loop.

If you find this useful, you are welcome to use the code: Continue reading "Scanning your entire LAN for MAC Addresses"


So you're trying to get your homemade app on your pwned iPhone

Recently I was working on an iPhone app for work, for demo purposes, but my company cheaped out on the Apple iPhone Developers registration. 

More accurately, the process of binding a multi-million-$-a-year company with Apple Inc. takes a very long time, so we took the back-door and just pwned our test iPhone devices (firmware 2.1).
"How hard can it possibly be to install apps on a jail-broken iPhone?" we thought, Well as it turns out, it's pretty difficult, especially for Mac-first-timers like myself. 
In the end, I overcame this obstacle - but not before compiling a compiler, installing a gazillion support apps, compiling my app with at least 6 different compilers, doing it on WinXP, Ubuntu, on the iPhone itself, and on the Mac.
So I thought why not share with you the way that actually produced the working result.

Continue reading "So you're trying to get your homemade app on your pwned iPhone"


OpenGL for AviSynth [Update: now w/code]


I had a little project at work recently, that involved creating movie clips using AviSynth.
And I was appalled by the shabbiness of existing transition plugins available freely for AviSynth, they always reminded me of 80s-like video editing...
So I set out to integrate AviSynth with OpenGL to create a nice 3D transition effect for our movie clips.

I had 2 major bases to cover:

  • AviSynth plugin API
  • OpenGL rendering

AviSynth API is not so well documented, but they have very good ground-up examples on how to DIY plugin. Here is the one I used, that basically does nothing but copy the input frame to the output frame.
Open GL on the other hand is very well documented and "tutorialed". I based my code on this example from NeHe.

So basically what I wanted to achive is:

  1. Read input frame (AviSynth)
  2. Paint frame as texture over 3D model (OpenGL)
  3. Draw rendered 3D image to output frame (OpenGL+AviSynth)

Reading the frame is pretty straightforward. Frames come encoded as RGB 24bit, with a little twist: rows size in bytes is not width*3 as you'd expect it be, but AviSynth use a parameter called "Pitch" to determine row size in bytes.

Update (14/9/09): source is now available in the repo: browse download
Continue reading "OpenGL for AviSynth [Update: now w/code]"


Showing video with Qt toolbox and ffmpeg libraries

I recently had to build a demo client that shows short video messages for Ubuntu environment.
After checking out GTK+ I decided to go with the more natively OOP Qt toolbox (GTKmm didn't look right to me), and I think i made the right choice.

So anyway, I have my video files encoded in some unknown format and I need my program to show them in a some widget. I went around looking for an exiting example, but i couldn't find anything concrete, except for a good tip here that led me here for an example of using ffmpeg's libavformat and libavcodec, but no end-to-end example including the Qt code.

The ffmpeg example was simple enough to just copy-paste into my project, but the whole painting over the widget's canvas was not covered. Turns out painting video is not as simple as overriding paintEvent()...

Firstly, you need a separate thread for grabbing frames from the video file, because you won't let the GUI event thread do that.
That makes sense, but when the frame-grabbing thread (I called VideoThread) actually grabbed a frame and inserted it somewhere in the memory, I needed to tell the GUI thread to take that buffered pixels and paint them over the widget's canvas.

This is the moment where I praise Qt's excellent Signals/Slots mechanism. So I'll have my VideoThread emit a signal notifying some external entity that a new frame is in the buffer.
Here's a little code:

Continue reading "Showing video with Qt toolbox and ffmpeg libraries"


The strange case of the BackgroundWorker and the disappearing exception

I was recently building a simple GUI in .NET to operate an algorithm as part of a school project, and I encountered a weird problem using BackgroundWorkers. I spent a lot of time debugging it, mainly because the code seemed to be perfect (which was true) but the run-time behavior was so strange...

Anyway, to make my algorithm as weakly-coupled as possible decided not to use 'BackgroundWorker.ReportProgress', because then my algorithm will have to know what a BackgroundWorker is...
I decided to actually fire my own event whenever I wanted to report on the algorithm progress (which is rather lenghty). So I defined my delegate and event inside my one-function class that runs the algorithm:

Continue reading "The strange case of the BackgroundWorker and the disappearing exception"