Wednesday, February 5, 2014

fun with my Raspberry Pi

I ordered a Raspberry Pi recently. I've heard so much about this device in the recent past, I decide to try it out. I was reminded of few microprocessor(fun class) and electrical engineering(not so fun time) classes that I took in my undergrad. I wrote a simple program that could turn a Stepper Motor using a motor controller connected to a Raspberry Pi.

Raspberry was only 35$. If you are planning to buy it, it might cost you a little more than that if you don't have the necessary stuff required.

This is what i used (physical stuff) to run a simple Python Program to turn a stepper motor using Raspberry Pi:

  1. Raspberry Pi (Duh! ) model B (model B has 2 USB slots, HDMI, ethernet, you can fit keyboard, mouse, wifi dongle, etc). I guess model A has fewer of these slots and no HDMI.
  2. 4 GB + memory card (the Raspbian OS is just over 2 GB, so won't fit on a 2GB card). I guess any one will do. You can use the ones that go with your camera.
  3. HDMI cable to connect to a TV or monitor.
  4. Power Cable (get an external power adapter for Raspberry Pi).
  5. Screw driver set, if you don't have one (it comes in handy if you are messing with electronics). I got this one.
  6. Jumper cables.
  7. Battery holder for powering the stepper motor.
  8. WiFi dongle. Yes, Raspberry Pi (model B) doesn't come with builtin WiFi. So, I got this one. I didn't have any problems with drivers, etc.
  9. Stepper motor. This one comes with a tire. It will come in handy if are into Robotics.
If you add all these, you might end up spending around $70-$100.

I formatted the SD card with Raspbian OS (its a variant of Debian). Its customized to run on ARM architecture.

I followed the instructions posted on this video on YouTube.

The code that I have below was obtained from above video:

Once you have the program, you need to open the Terminal in Raspberry Pi and give the command as a root to run the program. For example,
Here is a video of the working system:

Thursday, January 30, 2014

setting up Ad-hoc network in Ubuntu 12.04 or Debian

I had a hard time looking for setting up an Ad-hoc network. This post explains to setup an ad-hoc network in one of the most easiest ways.

The basic idea behind setting this up is, set up an ad-hoc network on your both (or more) computers individually and let them talk (or ping) to each other.

One needs to understand that ad-hoc network is different from a WiFi hotspot. Also you need to be patient while one computer pings another.

You will have to do the following in both(or more, replace the ip addresses) of the computers
In first computer (copy paste the following text), you give the network name and other important details for the interface that you are configuring ad-hoc for.
Similarly, in second computer
Now back in ther terminal do the following:

ifup command is a very useful command.

That's all. You adhoc network is now setup. Now to be sure if everything is okay, you could do the following:

Now, all is left is to ping first computer from second computer (or vice-versa) to make sure that everything works well.
Now have some patience wait for some time till they ping each other
Once the network is established (at least once), the further attempts to reconnect (in case of a disconnect) will be much faster.


Saturday, October 26, 2013

OpenCV Computer Vision Application Programming: Review

I was pleasantly surprised when I heard that there is a video tutorial for learning OpenCV out in the market.

Its available for download at A preview of the video can be seen at

I did see a few videos on YouTube for "OpenCV Tutorials", but they weren't organized properly. Its good to see an author walk you through all the basic modules of OpenCV. The author discusses about OpenCV installation, basic C, C++ and Python interfaces. There is a video on Face Recognition, Image Morphology, Image segmentation, Calibration, Training your own HAAR cascade classifier, etc. I specifically looked into "Working with HDR Images" video and was disappointed. The author only talked about how to use a ready made program in Linux and how to save HDR images using the built program. It is sad that OpenCV is already more updated after the release of this video (like saving HDR images programatically

The instructions in the video focus primarily on using the OpenCV interface. If you want to know why are do you want to use a certain instruction/statement, you will have learn Image Processing, Machine Learning/Pattern Recognition. The code written by the author is available for download along with the videos.

Although, I would have liked the author to place all the code in a single folder and explain using that organized folder (I could see the author only opening up random files, executing binary, explaining output and explaining the code.

The programming has been primarily done in C++ which is nice. Most of developers prefer C++ for their development. Its also easier to port the code to mobile or across different platforms. It is a good addition to Packt's OpenCV book .

P.S. I received a free copy of video tutorial of "OpenCV Computer Vision Application Programming" for writing the review.