Tuesday, March 29, 2016

Building the robot

I built a compartment on top of the rover which stores the battery, breadboard and motor drive controller board. I used a cardboard box and made wholes on the top and sides for the wires to pass through. I screwed the cardboard box to the rover on the bottom.



Use Of Ultra Sonic Range Finder

I used the Ultra Sonic Range Finder to help the robot detect the obstacle.
I connected the sensor to my Rpi using the bread board, 2 resistors (1k) and some male to female jumper wires. I also wrote the below code that detects the obstacle and outputs the distance from the sensor to the obstacle.

Circuit design from fritzing:

The below is the circuit design i used:


The above code gives the following output:

Thursday, March 24, 2016

Using Gstreamer and OpenCV

After the installations i just typed the following command in the terminal which gives the live stream on the monitor using Gstreamer:

raspivid -n -w 960 -h 540 -b 4500000 -fps 8 -vf -hf -t 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! omxh264dec ! videoconvert ! ximagesink

I wrote a python program using the OpenCV which detects the face and takes a picture of it. I included the above command in the python file to give the live stream and use it for facial detection.

Monday, March 14, 2016

Gstreamer and OpenCV Installations

I installed Gstreamer and OpenCV in my raspberry pi for the video surveillance and facial detection:

I got the code for OpenCV from:
http://askubuntu.com/questions/537268/installing-opencv-in-ubuntu-14-04

The following link have a data for the xml file:
https://raw.githubusercontent.com/shantnu/webcam-face detect/master/haarcascade_frontalface_default.xml

For Gstreamer installation:
sudo apt-get install gstreamer1.0

For OpenCV installation:
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9])+' | cut -c2-)"

echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV

echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev

echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg

echo "Downloading OpenCV" $version
wget -O OpenCV-$version.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/opencv-"$version".zip/download

echo "Installing OpenCV" $version
unzip OpenCV-$version.zip
cd opencv-$version
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j2
sudo checkinstall
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV" $version "ready to be used"

Sunday, March 6, 2016

Some other things needed for rover

I ordered the following things for motor power on amazon:
ON/OFF Switch Black 4 x 1.5V AA Batteries Holder Case Storage Box:



L298N Dual H Bridge DC Stepper Motor Drive Controller Board Module for Arduino, Raspberry Pi, and other microcontrollers: