Skip to content
May 22, 2012

Movement tracking – First version

The custom PCB that contains the ATmega8L and the Motor driver that driver the motor...

In the beginning I tried to generalize motion tracking system. Previously I tried to detect a colored object and rotate the camera accordingly. The fundamental concept of operation is to detect movement by detecting changes between two consecutive frames. The camera rotates according to the movement and tries to keep the moving object in frame.

Watch…

It uses OpenCV with Python bindings to run the computer vision routines. The whole computer vision subsystem contains image processing followed by contour detection. The camera rotation platform uses a stepper motor that is controlled by a Atmel ATmega8L micro-controller which is connected to the computer with a Bluetooth Serial modem.

The custom PCB that contains the ATmega8L and the Motor driver that driver the motor…

Camera mounted on the rotor

There is a lot of room for improvement. I will continue to work on this.

This was my B. Tech Final Year Project.

All codes are on http://github.com/rivalslayer/MotionDetection including the AVR Studio Project files required to compile and program the micro-controller that is responsible for interfacing the camera rotation with the computer. The complete report is also here.

February 1, 2012

Project Log Entry 2

For my final year project, I initially planned to use Kalman filtering for motion detection, but as I couldn’t make the Kalman Filtering work on time, I settled with a color based tracking system. Simply converting the whole camera image to HSV color-space and setting a rang for a particular color, I tracked the colored blobs. Next I will be using Kalman filtering.

The computer vision library used was OpenCV, running with Python bindings. The system is communicating with the computer via Bluetooth and there is a webcam fitted on the rotation mechanism that I built from old printer parts.

Here is a video of it in action,

February 1, 2012

Delta modulation experiment

When I first learned about Delta modulation I realized it has a lot of potential for low-digital-bandwidth voice communication. With a single bit data-frame audio communication will be quite easy. This is one among my old experiments. I simulated a delta-modulation-demodulation system with various quantization steps and figured out it’s frequency response.

I did set the sampling rate to 4 times (as suggested by a communication book) the Nyquist Rate. That is 2 x 20kHz x 4.

The surface plot is the correlation co-efficient at those particular quantization steps and input sinusoidal frequency.

Here is the response,

I found out that it’s quite good for voice communication, upto 8kHz it will perform pretty well. The red region suggests good communication will occur upto 8kHz at small quantization steps. The the quality of the communication will gradually fall.

Next I will put a audio file through delta modulation.

The MATLAB code with the Delta modulation simulation model (.rar file) is here at http://www.2shared.com/file/udUtQHCA/DM_online.html.

February 1, 2012

Moving average filter experiment

This is one of my old experiments I did when I started to learn about digital signal processing. I was intrigued by the simplicity of a moving average filter and did an experiment on frequency response of a moving average filter vs. number of averaging elements.

I found out that is has somewhat a cosine frequency response, and does have excellent low pass characteristics, although have some little curves on higher frequencies.

Here is the response vs. number of averaging elements. I plotted the surface with Number of Averaging Elements/Sampling rate. That way it’s easier to realize the duration of averaging.

Here is the MATLAB program that generates this surface plot, http://www.2shared.com/file/sqKzodEZ/MovingAverage.html

I also put a sound files through my moving average filter. I don’t exactly remember the number-of-averaging-elements I used but the low pass characters was very impressive. You can use Windows Media Player Bar spectrum analyzer visualization to visualize that, or you can use a good pair of headphones/ speakers to see the difference.

Here is the real sound file and http://www.2shared.com/audio/-sTLEbrx/TestSound.html

Here is the filtered sound file http://www.2shared.com/audio/nKwQZpI8/FilteredSound.html

September 28, 2011

JavaScript Speed Test

I started out to test out the speeds of JavaScript engines in the browsers. I was keen to experiment on the Chrome’s high performance V8 JavaScript engine. I designed this very rudimentary experiment to compare two JS engines (the one in Firefox and the one in Chrome). IE didn’t really support the DOM and the experiment didn’t work out, and I was not keen to make the whole thing work on IE. I am not an IE person.

The experiment is a page that has a math intensive JavaScript program that will compare the starting and ending time in machine timecode and publish the difference on page. The JS script is designed to do Sine, Cosine operations and store the values and then print them on the page. The page also has some CSS elements.

The page can be downloaded.

The results I got on my Core i3 laptop with 3 Gigs of RAM running Windows 7 Home Basic…

On Firefox (click to enlarge),

On Google Chrome,

And on IE where the script didn’t work,

The V8 engine that powers node.js I thought would be a lot faster. Google claims the power of V8 lies on it’s garbage collection system. I didn’t look into garbage collection though. But the speed, as you can see is slower than Firefox.

I didn’t test it on Safari, Opera etc. If anyone compares them, please let me.

August 29, 2011

Project Log Entry 1

My final year team engineering project is computer vision based object tracking system. A camera will follow an object, trying to keep it at the center, as it moves it front of it. Primarily, our objective is to detect the object that is moving and then using a motorized platform, rotate the camera. First, we will do a side-wise panning platform, then up-down panning. If possible we will make a motorized object follower by integrating the whole system in a singular device. For that we are planning to use a Linux based ARM board (viz. BeagleBoard).

For computer vision we are using OpenCV. After testing multiple languages and computer vision libraries, it was apparent that OpenCV is the best library out there. Previously, JMyron and Blob Detection in Processing was used. Then now, it’s fully OpenCV. Primary prototyping will be done by Python. If possible we will migrate it to C for better performance.

The rotation platform and the PC will communicate with a Bluetooth Serial communication module, or cable serial. The motorized platform would have stepper motors, controlled with an AVR (presumably, ATmega8). AVR programming will be done with AVRGCC.

Currently our focus is on Computer Vision. Exploring capabilities of OpenCV. Our current plan is to use contour detection, then using the contour CG as our control point, we will rotate the camera. Assuming we will face problems with the control feedback to the rotor, we will have to explore control schemes. We might use predictive filtering techniques to predict control points and Kalman filtering as primary control point detection.

The camera being used is a Logitech C270 webcam.

Experiments with OpenCV yielded some results…

Canny edge detection

Contour detection

Haar-like object detection as face detection

August 24, 2011

Glow-in-the-dark

It’s quite simple. It uses an MSP430G series micro-controller and an LDR for detecting light intensity. The detection is translated into interrupts with the analog comparator in the MCU. The special point about this is that it consumes really low power, thanks to the low power MSP430 micro-controllers from TI. It’s running on two AA alkaline batteries for nearly a month with being always powered on standard day night cycles.

August 20, 2011

Heap Allocation Experiment

I did this experiment on July, 2008 and totally forgot about it. I was looking for some of my old experiments and found this. It’s quite a nice little experiment.

It’s about comparing C compilers. I simply made program allocate some memory space for a certain array and allocated some memory again and measured the difference in pointer values (the memory distance).

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define MAX 100

int main(int argc, char *argv[]){
    int i;
    FILE *output;
    output=fopen("results.txt","w");
    fprintf(output,"char array\n");
    for(i=1; i<=MAX; i++){
             char *array1=(char*)malloc(i * sizeof(char));
             char *array2=(char*)malloc(sizeof(char));
             fprintf(output,"The free space for %d length 'char' array is %ld\n",i,array2-array1);
             free(array1);
             free(array2);
    }
    return 0;
}

I modified the original program a little and compiled with various compilers and got the results. The results are stored in result.txt.

I tested it on three different compiler/OS combinations.

MinGW (gcc (GCC) 3.4.5 (mingw-vista special r3)) on Windows 7 64 bit/Core i3 370M:

char array
The free space for 1 length 'char' array is 7376
The free space for 2 length 'char' array is 7376
The free space for 3 length 'char' array is 7376
The free space for 4 length 'char' array is 7376
The free space for 5 length 'char' array is 7376
The free space for 6 length 'char' array is 7376
The free space for 7 length 'char' array is 7376
The free space for 8 length 'char' array is 7376
The free space for 9 length 'char' array is -7376
The free space for 10 length 'char' array is -7376
The free space for 11 length 'char' array is -7376
The free space for 12 length 'char' array is -7376
The free space for 13 length 'char' array is -7376
The free space for 14 length 'char' array is -7376
The free space for 15 length 'char' array is -7376
The free space for 16 length 'char' array is -7376
The free space for 17 length 'char' array is -7376
The free space for 18 length 'char' array is -7376
The free space for 19 length 'char' array is -7376
The free space for 20 length 'char' array is -7376
The free space for 21 length 'char' array is -7376
The free space for 22 length 'char' array is -7376
The free space for 23 length 'char' array is -7376
The free space for 24 length 'char' array is -7376
The free space for 25 length 'char' array is -7376
The free space for 26 length 'char' array is -7376
The free space for 27 length 'char' array is -7376
The free space for 28 length 'char' array is -7376
The free space for 29 length 'char' array is -7376
The free space for 30 length 'char' array is -7376
The free space for 31 length 'char' array is -7376
The free space for 32 length 'char' array is -7376
The free space for 33 length 'char' array is -7376
The free space for 34 length 'char' array is -7376
The free space for 35 length 'char' array is -7376
The free space for 36 length 'char' array is -7376
The free space for 37 length 'char' array is -7376
The free space for 38 length 'char' array is -7376
The free space for 39 length 'char' array is -7376
The free space for 40 length 'char' array is -7376
The free space for 41 length 'char' array is -7376
The free space for 42 length 'char' array is -7376
The free space for 43 length 'char' array is -7376
The free space for 44 length 'char' array is -7376
The free space for 45 length 'char' array is -7376
The free space for 46 length 'char' array is -7376
The free space for 47 length 'char' array is -7376
The free space for 48 length 'char' array is -7376
The free space for 49 length 'char' array is -7376
The free space for 50 length 'char' array is -7376
The free space for 51 length 'char' array is -7376
The free space for 52 length 'char' array is -7376
The free space for 53 length 'char' array is -7376
The free space for 54 length 'char' array is -7376
The free space for 55 length 'char' array is -7376
The free space for 56 length 'char' array is -7376
The free space for 57 length 'char' array is -7376
The free space for 58 length 'char' array is -7376
The free space for 59 length 'char' array is -7376
The free space for 60 length 'char' array is -7376
The free space for 61 length 'char' array is -7376
The free space for 62 length 'char' array is -7376
The free space for 63 length 'char' array is -7376
The free space for 64 length 'char' array is -7376
The free space for 65 length 'char' array is -7376
The free space for 66 length 'char' array is -7376
The free space for 67 length 'char' array is -7376
The free space for 68 length 'char' array is -7376
The free space for 69 length 'char' array is -7376
The free space for 70 length 'char' array is -7376
The free space for 71 length 'char' array is -7376
The free space for 72 length 'char' array is -7376
The free space for 73 length 'char' array is -7376
The free space for 74 length 'char' array is -7376
The free space for 75 length 'char' array is -7376
The free space for 76 length 'char' array is -7376
The free space for 77 length 'char' array is -7376
The free space for 78 length 'char' array is -7376
The free space for 79 length 'char' array is -7376
The free space for 80 length 'char' array is -7376
The free space for 81 length 'char' array is -7376
The free space for 82 length 'char' array is -7376
The free space for 83 length 'char' array is -7376
The free space for 84 length 'char' array is -7376
The free space for 85 length 'char' array is -7376
The free space for 86 length 'char' array is -7376
The free space for 87 length 'char' array is -7376
The free space for 88 length 'char' array is -7376
The free space for 89 length 'char' array is -7376
The free space for 90 length 'char' array is -7376
The free space for 91 length 'char' array is -7376
The free space for 92 length 'char' array is -7376
The free space for 93 length 'char' array is -7376
The free space for 94 length 'char' array is -7376
The free space for 95 length 'char' array is -7376
The free space for 96 length 'char' array is -7376
The free space for 97 length 'char' array is -7376
The free space for 98 length 'char' array is -7376
The free space for 99 length 'char' array is -7376
The free space for 100 length 'char' array is -7376

Visual C++ 2010 (Microsoft Visual Studio 2010 Version 10.0.30319.1 RTMRel Microsoft .NET Framework Version 4.0.30319 RTMRel) on Windows 7 64 bit/Core i3 370M:

char array
The free space for 1 length 'char' array is 64
The free space for 2 length 'char' array is 64
The free space for 3 length 'char' array is 64
The free space for 4 length 'char' array is 64
The free space for 5 length 'char' array is 72
The free space for 6 length 'char' array is 72
The free space for 7 length 'char' array is 72
The free space for 8 length 'char' array is 72
The free space for 9 length 'char' array is 72
The free space for 10 length 'char' array is 72
The free space for 11 length 'char' array is 72
The free space for 12 length 'char' array is 72
The free space for 13 length 'char' array is 80
The free space for 14 length 'char' array is 80
The free space for 15 length 'char' array is 80
The free space for 16 length 'char' array is 80
The free space for 17 length 'char' array is 80
The free space for 18 length 'char' array is 80
The free space for 19 length 'char' array is 80
The free space for 20 length 'char' array is 80
The free space for 21 length 'char' array is 88
The free space for 22 length 'char' array is 88
The free space for 23 length 'char' array is 88
The free space for 24 length 'char' array is 88
The free space for 25 length 'char' array is 88
The free space for 26 length 'char' array is 88
The free space for 27 length 'char' array is 88
The free space for 28 length 'char' array is 88
The free space for 29 length 'char' array is 96
The free space for 30 length 'char' array is 96
The free space for 31 length 'char' array is 96
The free space for 32 length 'char' array is 96
The free space for 33 length 'char' array is 96
The free space for 34 length 'char' array is 96
The free space for 35 length 'char' array is 96
The free space for 36 length 'char' array is 96
The free space for 37 length 'char' array is 104
The free space for 38 length 'char' array is 104
The free space for 39 length 'char' array is 104
The free space for 40 length 'char' array is 104
The free space for 41 length 'char' array is 104
The free space for 42 length 'char' array is 104
The free space for 43 length 'char' array is 104
The free space for 44 length 'char' array is 104
The free space for 45 length 'char' array is 112
The free space for 46 length 'char' array is 112
The free space for 47 length 'char' array is 112
The free space for 48 length 'char' array is 112
The free space for 49 length 'char' array is 112
The free space for 50 length 'char' array is 112
The free space for 51 length 'char' array is 112
The free space for 52 length 'char' array is 112
The free space for 53 length 'char' array is 120
The free space for 54 length 'char' array is 120
The free space for 55 length 'char' array is 120
The free space for 56 length 'char' array is 120
The free space for 57 length 'char' array is 120
The free space for 58 length 'char' array is 120
The free space for 59 length 'char' array is 120
The free space for 60 length 'char' array is 120
The free space for 61 length 'char' array is 128
The free space for 62 length 'char' array is 128
The free space for 63 length 'char' array is 128
The free space for 64 length 'char' array is 128
The free space for 65 length 'char' array is 128
The free space for 66 length 'char' array is 128
The free space for 67 length 'char' array is 128
The free space for 68 length 'char' array is 128
The free space for 69 length 'char' array is 136
The free space for 70 length 'char' array is 136
The free space for 71 length 'char' array is 136
The free space for 72 length 'char' array is 136
The free space for 73 length 'char' array is 136
The free space for 74 length 'char' array is 136
The free space for 75 length 'char' array is 136
The free space for 76 length 'char' array is 136
The free space for 77 length 'char' array is 144
The free space for 78 length 'char' array is 144
The free space for 79 length 'char' array is 144
The free space for 80 length 'char' array is 144
The free space for 81 length 'char' array is 144
The free space for 82 length 'char' array is 144
The free space for 83 length 'char' array is 144
The free space for 84 length 'char' array is 144
The free space for 85 length 'char' array is 152
The free space for 86 length 'char' array is 152
The free space for 87 length 'char' array is 152
The free space for 88 length 'char' array is 152
The free space for 89 length 'char' array is 152
The free space for 90 length 'char' array is 152
The free space for 91 length 'char' array is 152
The free space for 92 length 'char' array is 152
The free space for 93 length 'char' array is 160
The free space for 94 length 'char' array is 160
The free space for 95 length 'char' array is 160
The free space for 96 length 'char' array is 160
The free space for 97 length 'char' array is 160
The free space for 98 length 'char' array is 160
The free space for 99 length 'char' array is 160
The free space for 100 length 'char' array is 160

g++ (gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)) on Fedora 14 32 bit/ Core i3 370M:

char array
The free space for 1 length 'char' array is 16
The free space for 2 length 'char' array is -16
The free space for 3 length 'char' array is 16
The free space for 4 length 'char' array is -16
The free space for 5 length 'char' array is 16
The free space for 6 length 'char' array is -16
The free space for 7 length 'char' array is 16
The free space for 8 length 'char' array is -16
The free space for 9 length 'char' array is 16
The free space for 10 length 'char' array is -16
The free space for 11 length 'char' array is 16
The free space for 12 length 'char' array is -16
The free space for 13 length 'char' array is -32
The free space for 14 length 'char' array is -32
The free space for 15 length 'char' array is -32
The free space for 16 length 'char' array is -32
The free space for 17 length 'char' array is -32
The free space for 18 length 'char' array is -32
The free space for 19 length 'char' array is -32
The free space for 20 length 'char' array is -32
The free space for 21 length 'char' array is -56
The free space for 22 length 'char' array is -56
The free space for 23 length 'char' array is -56
The free space for 24 length 'char' array is -56
The free space for 25 length 'char' array is -56
The free space for 26 length 'char' array is -56
The free space for 27 length 'char' array is -56
The free space for 28 length 'char' array is -56
The free space for 29 length 'char' array is -88
The free space for 30 length 'char' array is -88
The free space for 31 length 'char' array is -88
The free space for 32 length 'char' array is -88
The free space for 33 length 'char' array is -88
The free space for 34 length 'char' array is -88
The free space for 35 length 'char' array is -88
The free space for 36 length 'char' array is -88
The free space for 37 length 'char' array is -128
The free space for 38 length 'char' array is -128
The free space for 39 length 'char' array is -128
The free space for 40 length 'char' array is -128
The free space for 41 length 'char' array is -128
The free space for 42 length 'char' array is -128
The free space for 43 length 'char' array is -128
The free space for 44 length 'char' array is -128
The free space for 45 length 'char' array is -176
The free space for 46 length 'char' array is -176
The free space for 47 length 'char' array is -176
The free space for 48 length 'char' array is -176
The free space for 49 length 'char' array is -176
The free space for 50 length 'char' array is -176
The free space for 51 length 'char' array is -176
The free space for 52 length 'char' array is -176
The free space for 53 length 'char' array is -232
The free space for 54 length 'char' array is -232
The free space for 55 length 'char' array is -232
The free space for 56 length 'char' array is -232
The free space for 57 length 'char' array is -232
The free space for 58 length 'char' array is -232
The free space for 59 length 'char' array is -232
The free space for 60 length 'char' array is -232
The free space for 61 length 'char' array is -296
The free space for 62 length 'char' array is -16
The free space for 63 length 'char' array is -16
The free space for 64 length 'char' array is -16
The free space for 65 length 'char' array is -16
The free space for 66 length 'char' array is -16
The free space for 67 length 'char' array is -16
The free space for 68 length 'char' array is -16
The free space for 69 length 'char' array is -16
The free space for 70 length 'char' array is -16
The free space for 71 length 'char' array is -16
The free space for 72 length 'char' array is -16
The free space for 73 length 'char' array is -16
The free space for 74 length 'char' array is -16
The free space for 75 length 'char' array is -16
The free space for 76 length 'char' array is -16
The free space for 77 length 'char' array is -16
The free space for 78 length 'char' array is -16
The free space for 79 length 'char' array is -16
The free space for 80 length 'char' array is -16
The free space for 81 length 'char' array is -16
The free space for 82 length 'char' array is -16
The free space for 83 length 'char' array is -16
The free space for 84 length 'char' array is -16
The free space for 85 length 'char' array is -16
The free space for 86 length 'char' array is -16
The free space for 87 length 'char' array is -16
The free space for 88 length 'char' array is -16
The free space for 89 length 'char' array is -16
The free space for 90 length 'char' array is -16
The free space for 91 length 'char' array is -16
The free space for 92 length 'char' array is -16
The free space for 93 length 'char' array is -16
The free space for 94 length 'char' array is -16
The free space for 95 length 'char' array is -16
The free space for 96 length 'char' array is -16
The free space for 97 length 'char' array is -16
The free space for 98 length 'char' array is -16
The free space for 99 length 'char' array is -16
The free space for 100 length 'char' array is -16

The comparison makes clear that the old MinGW version of gcc is quite inefficient in allocating memories as far as two consecutive malloc()s are concerned. On the other hand other two compilers are quite good, and Fedora version of GCC exhibits a strange pattern. I didn’t note the kernel version of the Fedora 14 I have installed. I may test it on other systems, modify this experiment and post the results.

Readers are welcome to post their results.

August 7, 2011

Fluidity Experiment

Today, I started this new experiment of making things look fluid. The problem with fluid simulations is that they take a lot of computation and requires over-the-top mathematics which I am not familiar with. Thus I started making program that would simply make things look fluid, with simplest computation possible. My AVS preset making skills finally paid off, and I was able to incorporate some fluidity in my screen, as you can see in the video,

This Processing sketch (Program) makes this circles look like parts of an viscous somewhat like electrically charged fluid, with the mouse cursor be a controlled electrode. It was fun to code, tweaked the functions and the parameters to make the whole thing look nice and perfect in my computer. Different computer will give differently timed outputs as the program is not constrained with time. It will run independently on the systems’ resources.

The sketch can be downloaded from here (Fluidity.rar). I have this bad habit of not commenting while coding, and be too lazy for commenting in the end. This is my first processing sketch where I used custom classes for better coding. I found out that with classes I can make stuff with significantly less complex code, obviously at the cost of performance I guess.

It would be better if I could do this with OpenFrameworks, would get a lot more speed. I will do that someday, but for now I am satisfied with Processing. Its’ built in random number generator. I will further enhance the fluid function that drives the fluid mechanics of the circles and maybe able to get a nicer effect of fluid. Also I would like to use Computer Vision to interact with this fluid with webcams and hands.

August 7, 2011

Numeric Patterns Part 2

I tried to expand my numeric patterning  and found another technique that is able to make patterns from numbers which is more obscure than the previous technique. I believe this patterning technique will reflect memorability of a number in a better way. I still need to do a survey though. The detailed description of the algorithm is a little complex and also boring, so I leave it to the code readers. Nothing special in the algorithm.

The images are generated with Processing language. The sketch is here (Data_Painting_Part_2_pattern_and_number.rar). Download it, edit the text file ‘data.txt’ and run the sketch. The sketch will generate images of the numbers in separate .GIF files in the Images folder.

Follow

Get every new post delivered to your Inbox.