Popular Posts

Wednesday, May 11, 2011

Worker Threads!

Many times you need to call a function/method that does some really heavy work. However, you don't want this function call to block your main application. You want to maintain a responsive GUI, for example!

This famous problem has a solution using multi-threading. From my background in the C++ Qt framework, I know the basic principles involved. And there is a very famous Qt example that explains how this "Worker Thread" solution can be implemented: The Madelbrot Example

Today I wanted to solve the same problem but in the C# (.Net Framework) context. Fortunately, the MSDN had a similar example that illustrates the solution to this problem, making use of the BackgroundWorker class:

Reading and Writing .Net Applications Settings

Sometimes you have to deal with the .Net framework in a way or another. I was forced to use a .Net C# closed-source library. And that library was automatically reading file paths from ConfigurationManager.AppSettings[]. So, I needed a way to read and modify those settings. Fortunately, this post saved my life!

To read:
string value = ConfigurationManager.AppSettings["oldPlace"];

To modify/write:
System.Configuration.Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

config.AppSettings.Settings["oldPlace"].Value = "3";

More information can be retrieved from the MSDN:

Sunday, May 8, 2011

Precision and Recall

One of the most important metrics used in evaluating the performance of binary classifiers is the Precision-Recall curve.

From Wikipedia:

It is possible to interpret precision and recall not as ratios but as probabilities:
* Precision is the probability that a (randomly selected) retrieved document is relevant.
* Recall is the probability that a (randomly selected) relevant document is retrieved in a search.

This page contains some illustrations to better understand the definitions of Precision and Recall:

Also, this paper relates Precision-Recall curves to the Receiver Operator Characteristic curves:

Finally, this page is further explaining the concepts and elaborating on the F-measure metric that tries to combine Precision and Recall into one measure:

Thursday, May 5, 2011

Splitting a video into frames using ffmpeg

I needed a quick way to split a video sequence into its individual frames and save those frames as images. FFmpeg seemed like a good handy solution. And the short answer is to do this:

ffmpeg -i inputfile.avi -f image2 image-%07d.png

This was a solution proposed in this thread. And for more information you can refer to the detailed documentation of FFmpeg.

PS: FFmpeg is available on Windows and you can get the installers here. If you just need the executable then download one of the static builds.