Thursday, March 21, 2013

Controlling Raspberry Pi via text message

This script enables you to control your computer via text message. Think of it almost as a version of SSH over text message.

It is designed to intelligently and quickly check unread Google voice messages. If certain parameters are passed, it runs the command you send and returns the result.
This is the third script in my AUI (Alternative User Interface) Series.
This requires curl and libboost1.50-regex. The setup script can install curl and boost regex. 

NOTE: This will work with any linux OS but I am using it on the Raspberry Pi so if you are using something else, you will have to compile it yourself (make sure to change the Makefile flags).

The stable version is on github here:

And the working copy source can be found here:
http://stevenhickson-code.googlecode.com/svn/trunk/AUI/TextCommand/


Google Voice unfortunately doesn't have an API available so I started writing my own.
I found this page and this page which were good references. Unfortunately, neither of these actually worked, so I wrote my own based off them. The script will install this and you are free to use it however you want as long as you cite me and follow GPLv3.

It works by using cron to run a script once every minute. The script checks your unread inbox messages and uses curl to make sure certain safety parameters are met. It is very important to check the unread inbox as it only pulls a 1-3 KB file rather than a 150+ KB file. This really adds up once a minute over time. If certain parameters are met, ie it has a valid phone number and command, then it runs the command you give it. The results of the command are then texted back to you. 
This will not work with interactive scripts like more or man



Installation Instructions

(this requires git)

sudo apt-get install git-core
git clone git://github.com/StevenHickson/PiAUISuite.git
cd PiAUISuite/Install/
./InstallAUISuite.sh

Update Instructions 

cd PiAUISuite
git pull
cd Install
sudo ./UpdateAUISuite.sh


There are other scripts in here that you can ignore. It will ask you the username details in the script.
This will be your Google voice username, password, key, and valid number.

Your Google voice username will be your e-mail. For example:
John.Doe@gmail.com
Your password is your Google voice password:
ThisIsntMyPassword
The key is the valid command-word that proceeds commands to the machine. For example, mine is Cmd. So I text:
Cmd ls
to have the pi text the results of the current directory back.
Your valid number is the phone number you want your google voice to receive commands from (Not your Google voice number!). You must put the country code but not the + sign. Ex:
15553332222

After that everything should work.
Note, I worked out a few major bugs with the install script and it is reposted now. So make sure to get the newest version.

Consider donating to further my tinkering


Places you can find me





Monday, March 18, 2013

Using a webcam with the Raspberry Pi

There is a lot of recent motivation to do image processing and computer vision tasks on the Raspberry Pi.
Luckily OpenCv is already built on Raspbian and Wheezy.

To install it, all you have to do is use apt-get like below:
sudo apt-get install libcv-dev libopencv-dev libcv2.3 opencv-doc

You may also want to install python opencv
sudo apt-get install python-opencv

To see all available opencv packages, type:
sudo apt-cache search opencv

You can test your opencv installation and webcam by downloading and running the script below:
http://stevenhickson-code.googlecode.com/svn/trunk/AUI/Imaging/test

You may have to make this program executable by running:
chmod +x test

The source code and makefile can be found here:
http://stevenhickson-code.googlecode.com/svn/trunk/AUI/Imaging/

If everything works, you should get a result like the one below (Apologies for the terrible quality, its a really old webcam):

  
I used scrot to take the screenshot
sudo apt-get install scrot

Thanks to Ethan Miklancic for hiding behind my laptop in the picture. I recommend using C or C++ rather than python because it makes a HUGE difference in speed.


Good Luck! 

Consider donating to further my tinkering.


Places you can find me

Saturday, March 16, 2013

Automatically downloading torrents with the Raspberry Pi

This is a script designed to intelligently and quickly find and download something as a torrent.
This is the second script in my AUI (Alternative User Interface) Series.


NOTE: This will work with any linux OS but I am using it on the Raspberry Pi.


This requires curl, libboost1.50-regex, and transmission. The setup script can install curl and boost regex. You will have to install transmission yourself.


I found myself getting frustrated with going to a torrent searching site and looking for a torrent and then downloading it. So I made this script to intelligently find the best torrent option. It doesn't require quotes and will format searches appropriately, even with spaces.

It uses regular expressions to find your download and starts it remotely in transmission.
I use transmission because then you can check the status of your download online.
I recommend this guide in order to set up transmission properly.


Ex.
download movie title
will quickly find and download movie title.

download show title  s01e01
will quickly find and download show title season 1, episode 1.

download wheezy
will quickly find and download the Raspberry Pi Debian Wheezy OS.

To install, download the zip here and run the InstallAUISuite.sh file located in the Install folder. It will ask you the download details in the script.
This will be your transmission username, password, port, and host.


Consider donating to further my tinkering.


Places you can find me

Thursday, March 14, 2013

Playing videos intelligently with the Raspberry Pi

This is a script designed to intelligently and quickly find and play any of your videos.
This is the first script in my AUI (Alternative User Interface) Series.

I found myself getting frustrated with delving through lots of different folders in order to find a tv show or movie. To keep things well organized requires a hierarchical structure and a lot of work, which also makes it harder to browse to the file in the current GUI environment.

This script aims to locate and play your videos intelligently (right now it uses omxplayer but it could be easily ported to use vlc)

It uses regular expressions and a database to quickly find your movie or tv show.

Ex.
playvideo Movie title
will quickly find and play Movie title

playvideo -r -f Show title
will quickly find and play a random "Show title" episode

playvideo -s 01 -e 01 Show title
will quickly find and play "Show title" Season 1 Episode 1

To install, download the zip here and run the InstallAUISuite.sh file located in the Install folder. It will ask you the media location in the install script.
For example, mine is /media/ExternalHD/movies

You can also choose to manually install but if so, make sure you run with the -set option. ex. playvideo -set /media/ExternalHD/movies

For the next part of my AUI Series, autonomous downloads, click here.

The man page of playvideo is shown below:

NAME

playvideo - Locate and play a video[s]  

SYNOPSIS

playvideo [OPTIONS]... [FILENAME]  

DESCRIPTION

playvideo was developed to speed up/ease the playing of videos using omxplayer on the rasperry pi. It can play movies using a single search term or play tv shows using a season and episode search term. It is based off common video naming conventions and supports mp4, avi, mkv, mov, mpg, flv, m4v, and mp3 files. It also supports randomization. It is currently in Beta and kind of a hack. Any useful suggestions are welcome. It is important to run playvideo the first time with the -set option to create the database (especially if you are using external media). Note: If you used InstallAUISuite.sh, then this has already been done for you.

OPTIONS

-set, -Set MEDIA_ROOT
       Sets up the user parameters and creates a locate db for the media root. Ex. if all your videos are located in /media/Drive1/videos you would run:

      playvideo -set /media/Drive1/videos
-season, -Season, -s, -S NN
       Selects the asked file based off the given season number NN which has to be a two digit number to follow current conventions. Doesn't require an episode number.

      Ex. playvideo -Season 02 Show title

-episode, -Episode, -e, -E N/NN
       Selects the asked file based off the given episode number N or NN which can be a one or two digit number to follow current conventions. Requires a season number to be set as well.

      Ex. playvideo -S 02 -E 01 Show title

-random, -r
       Randomizes the output list of videos.

-first, -f
       Plays the first video from the list. Can be used with the random flag.

-multi, -m
       Plays all of the given list based on the query. Requires CTRL+C to quit given that it runs omxplayer individually for each file.


-continue, -c N
       Continues to play N number of matches. If given a season and episode, it will continue playing the next episodes in order until N episodes have been reached. If given the multiple flag, it will play matches until N has been reached.


-help, -h, --help
       Displays this page.


       The script can now handle names without quotes by replacing spaces with the regex * expression.

      Ex. playvideo Movie title


       The Set up function will also set up a cron job to update the db every day for new files. This will be done in the background and is fairly quick.
 

AUTHOR

Steven Hickson (help@stevenhickson.com) 

Consider donating to further my tinkering.


Places you can find me

Saturday, March 2, 2013

Using Kinect with Unity 3D Game Engine

How to use the Kinect (Microsoft Drivers v. 1.5) with Unity 3D

Here is my current result for fun (The beginning is my own C++ version that doesn't involve unity) in a game where you can throw fireballs:


After spending a while developing a little C++ library to use with the Microsoft Kinect Drivers (which I've been meaning to release), I decided to try to integrate the Kinect functionality into the popular Unity 3D Game Development software.

I was pretty excited after finding the handy CMU package here. However, it only worked with the beta Microsoft SDK and didn't have some of the more advanced functionality that I needed. I'm running version 1.5 hacked together a quick DLL and modified some code.

I use the Microsoft Kinect SDK Version 1.5 which I have available for download here.

The DLL source code can be found here in case you want to modify it for a different version.

The DLL itself (needed for the Kinect to work with Unity) can be found here and should be placed in your Microsoft SDK/Kinect folder like below:
C:\Program Files\Microsoft SDKs\Kinect\v1.5\Assemblies\Unity\

The scripts to control a player and receive information from the Kinect can be found here.

They are used the same way as the CMU ones but are slightly modified with a bit more error checking and some extra flags. All you have to do is follow the same instructions on the CMU page linked above which just involves enabling the Kinect and telling the KinectModelControllerV2 where your joints are. The movement flag is still in beta as I'm trying to make it so the character can walk around.

I have a version that is entirely in C++ using OpenGL, FreeGlut, my own version of Blepo, and my own development libraries that is previewed in the beginning of the video that can be found here. It is what I do most of my testing in before I port it over to Unity.

Enjoy!

Consider donating to further my tinkering.


Places you can find me