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

Advertisements

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.

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.

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.

Ripples and piezoelectric effects…

This morning I had to spent my time and there was no power at my house. So, I made the dull day kinda exciting by detecting ripples that comes through a 7805 linear voltage regulator. This is the first time I used my DSO Nano v2 to some good work.

The 5V regulator would give out a voltage that would ripple around 5V, and DSO Nano doesn’t have AC coupling. So I made an AC coupler myself. A simple 100nF capacitor in series with the probes. The circuit was a 1K resistor across the 5V output. Then I started to observe. My mains have a frequency of 50Hz. And the whole voltage regulator setup is transformer-rectifier-filter-7805-filter. I actually forgot what I put inside the rectifiers so I cannot really write up those here and I am too lazy open the whole casing.

Here are the ripples that I got from my home-brew 5V regulated voltage supply. V(peak-peak) for ripples was about 25mV. And not to mention the frequency of the ripple is 50Hz. One thing to be noted that is the mains is not actually mains, it’s a domestic UPS. There was a power-cut and we were running on UPS. And the UPS gives out 50Hz, 220V square wave as the specification says.

And then I got bored again and I started to experiment with piezoelectric effects in capacitors as Dave said in his post. I hooked up a ceramic 100nF capacitor with DSO probes and whacked it many times and got some shocks. I am putting those here. I will tell Dave (of EEVBlog) that I got these shocks.

And then experimented with the bouncing patterns of momentary push switches. The switch was connected with pull-up of 1K with 5V. Here is the bouncing I got once after trying it out multiple times. The switch I used was of pretty good quality and didn’t bounce at all or my DSO nano was not fast enough to catch any bounce. And this doesn’t look anything like bouncing!

P.S. All the wave captures are done with DSO Nano v2 with BenF firmware. I also noticed that the metal body of the DSO nano did affect the waveforms. When I touched the body, the ripples went to also almost zero. I think it’s an isolation problem that happens with the UPS.

Book details from ISBN

When my Father decided to make a shelf-wise catalog of the books that we have in our house, I got an idea. The idea is to fetch book details from ISBN numbers; ISBN numbers are easily available from the bar-codes.

First I used a software to read the bar-codes with my webcam and store it as a text file of ISBN numbers with each line occupied by a number. Then I checked up the isbndb.com and found out the request pattern. I also found out that there is a redirection involved.

Now I simply put it all together in Python. I read the ISBN number and parsed it as a HTTP request. Once I got the response, it got tricky. I had to Google a bit to find a decent HTML parser. Once I got the HTML parser running, I could redirect my program to the main book page, from where I can scrape the book details.

And that was it, my ISBN scraper was done. The current version reads ISBN from a text file and then puts the book title and author along with the ISBN on another text file which will be named after the corresponding shelf.

The laptop webcam is crappy for bar-code reading, so looking forward to get a new web-cam (preferably HD). My next version may have bar-code reading feature built-in with them so that I can actually fetch the book detail directly when the bar-code is read. Other plans include nice looking XML output for easy reading and parsing and GUI.

I ran it in Python 2.7.2, not really used to Python 3.x you see. 🙂

I used only a single external module, that is BeautifulSoup for HTML parsing (which turned out to be really really useful). If you are running it, you should install BeautifulSoup first.

My code is here.

Introduction

Please do not bother about the name of the blog. It’s randomly chosen, something like Java, or Python, or Ruby. Was Java developed in Java islands, or does Python statements look like a Python, or Ruby shines like a fine cut ruby? NO! I chose to drop the S and give it a Z because I thought it would make it sound cooler.

I am a shutterbug and an engineering student, looking forward to be fundamentally productive than I am now. I will be writing about  stuff that I ‘ideate’ or take photos of or think ‘insighfully’ about.