Showing posts with label pi. Show all posts
Showing posts with label pi. Show all posts

Friday, October 28, 2016

Syrias children learn to code with the Raspberry Pi

Three years ago, when I was looking for an example of social unrest to highlight the use of social media as a communication tool for protestors in my book, I chose the then new uprising in Syria. Im horrified the conflict still continues. However, I just came across a surprisingly good piece of news from that awful conflict; the use of the Raspberry Pi to teach Syrian refugees in Lebanon to code. Read the full article in the Guardian to learn more.

from The Universal Machine http://universal-machine.blogspot.com/

IFTTT

Put the internet to work for you.

Turn off or edit this Recipe

Read More..

Friday, October 14, 2016

Voice Command v3 0 for the Raspberry Pi

Voicecommand v3.0 Changes


Ive made some big changes and their are even bigger things in the works. Here is a small list. Ive had some help from a couple of committed users who have come up with some new good ideas which is awesome.


  • There is now a ~ option that finds the word anywhere in a command. For instance ~music==pianobar will work if you say: lets hear some music, play music, or music.
  • !filler is now a string so you can set it manually. If you put it to 0, it will be empty and if you put it to 1, it will be FILLER FILL for compatibility issues.
  • Example scripts have been added in the Misc folder for you to play with. These can send and receive emails and text messages as well as posting to facebook; all using only your voice.
  • Flags can now overwrite the config options and can be reversed by following them with a 0 or enforced if followed with a 1. Ex. if !continuous==1 in your config file, you can force it to run only once with voicecommand -c0
  • The commands and keywords are now case insensitive. So no tricky case matching.
  • Multiple language support has been added. This is based on your country code which I think you can find here (plus en_uk and en_us). Look up your country code and use that. Ex. For US: !language==en_us, for Spain !language==es, for Germany !language==de.
  • You can set a Wolfram Alpha API and maxResponse (the number of branches) like !api==XXXXXX-XXXXXXXXXX and !maxResponse==3. This will give you better answers. You can sign up for a Wolfram Alpha API on their website for free.
  • Logging has been enabled into /dev/shm/voice.log. It throws stuff to this instead of /dev/null
  • The need for tts-nofill has been removed!! Now tts doesnt use any filler unless you send it yourself.

New Install and Update videos have been added. They can be found here:
http://stevenhickson.blogspot.com/2013/06/installing-and-updating-piauisuite-and.html

Consider donating to further my tinkering since I do all this and help people out for free.
Places you can find me
As always, the updated man page can be found below:

voicecommand

Section: voicecommand man page (8)
Updated: 13 May 2013
Index   

NAME

voicecommand - Listen to user defined strings and run the corresponding command   

SYNOPSIS

voicecommand [OPTIONS]...  

DESCRIPTION

voicecommand was developed for the Raspberry Pi but will work on any linux system with a microphone attached. It is a crude program, which uses basic comparisons to determine if your voicecommand fits a format specified in a config file; it it does, it runs the corresponding linux command. It supports auto-completion and variables as well as command verification, a continuous mode, and other options. For help/comments/questions, feel free to e-mail me at help@stevenhickson.com. I answer sporadically but do eventually respond.


Note: All of the flags that turn something on are off can be reversed and overwritten by following it with a 1 or 0. So for instance if you have !continuous==1 in your config file, you can run voicecommand -c0 to turn continuous off.
 

OPTIONS

?
Same as -h
-b
Turns off the FILL audio. The purpose of this was because the Raspbery Pi (or mine at least) cuts off the first few seconds of audio. This flag turns that feature off. You should only be concerned with this if you hear FILL before everything it says.
-c
Makes voicecommand run in continuous mode, where it will keep listening over and over again.
-d
Sets the duration for listening to the audio for voice commands
-D
Sets the audio hardware. The default is plughw:1,0 -
-e
Edits the voicecommand config file.
The format is voice==command
You can use any character except for newlines or ==
If the voice starts with ~, the program looks for the keyword anywhere. Ex: ~weather would pick up on weather or whats the weather
You can use ... at the end of the command to specify that everything after the given keyword should be options to the command.
Ex: play==playvideo ...
This means that if you say "play Futurama", it will run the command playvideo Futurama
You can use $# (where # is any number 1 to 9) to represent a variable. These should go in order from 1 to 9
Ex: $1 season $2 episode $3==playvideo -s $2 -e $3 $1
This means if you say game of thrones season 1 episode 2, it will run playvideo with the -s flag as 1, the -e flag as 2, and the main argument as game of thrones, i.e. playvideo -s 1 -e 2 game of thrones
Because of these options, it is important that the arguments range from most strict to least strict.
This means that ~ arguments should probably be at the end.
You can also put comments if the line starts with # and special options if the line starts with a !
Default options are shown as follows:
!keyword==pi,!verify==1,!continuous==1,!quiet==0,!ignore==0,!thresh==0.7,!maxResponse==-1
api==BLANK,!filler==FILLER FILL,!response==Yes Sir?,!duration==3,!com_dur==2,!hardware==plughw:1,0,!language==en_us
Keyword, filler, and response accept strings. verify, continuous, quiet, and ignore except 1 or 0 (true or false respectively). thresh excepts a floating point number. These allow you to set some of the flags as permanent options (If these are set, you can overwrite them with the flag options).
You can set a WolframAlpha API and maxResponse (the number of branches) like !api==XXXXXX-XXXXXXXXXX amd !maxResponse==3
You can now customize the language support for speech recognition and some text to speech with the language flag. Look up your country code and use that. Ex. For US: !language==en_us, for Spain !language==es, for Germany !language==de.
-f /my-location/config-file
This allows you to load a different config file located in a different spot. The default one is in your home directory and is ~/.commands.conf
The config file must be formatted the same way.
-h
Shows this man page.
-i
Sets the ignore mode. When this flag is activated, if a command is not in the config file, nothing happens. The default behavior is to try to find an answer or response to that question and then speak it. This turns off that behavior.
-I string
Sets the forced input mode. This allows you to test it without the microphone or get it to parse typed information. It will not run in continuous mode with this.
-k word
Sets the keyword. The default is pi. If this flag is set, the verify and continuous flags are also set since this is only checked during those two modes.
      Ex. voicecommand -c -v -k Jarvis

-l
Sets the duration for listening to the audio for the command keyword. This is different than the -d flag that listens for the voice commands.
-s
Runs a setup operation that attempts to set all of the config options in the config file so that voicecommand works properly
-r word
Sets the response. The default is "Yes Sir?" (For version 1.0, it was Ready?. If this response is more than one word, it should be put in quotes, otherwise it doesnt need to be
      Ex. voicecommand -r Ready?

-t #
Sets the threshold for volume to determine if the keyword was spoken. This should be a floating point number. The default value is 0.7 which works well with the Logitech C310 camera/mic from about 6 feet away.
Ex. voicecommand -t 1.2
-p
Sets passthrough mode on so that instead of running the commands, it just prints them. This is going to be used for the XBMC plugin and Android app.
-q
Sets quiet mode on so that voicecommand never speaks through the audio output. It still prints everything but doesnt ever respond. This includes the keyword response.
-v
Makes voicecommand verify the keyword. This only happens in continuous mode so if this flag is set, the continuous flag will be set as well. The default mode is to not verify. When voicecommand hears any sound above the threshold, it says the response then listens for a command. The default keyword is pi. When the verify flag is set, after the threshold is met, voicecommand verifies that the keyword was spoken.

AUTHOR

Steven Hickson (help@stevenhickson.com)  

BUGS

No known bugs. To report bugs, send a clear description to help@stevenhickson.comSince this program is fairly crude, user typos could cause crashes/failed responses. Please read the man page thoroughly before submitting a bug.  

COPYRIGHT

Copyright © 2013 Steven Hickson. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it as long as you give credit to the author and include this license. There is NO WARRANTY, to the extent permitted by law.  

HISTORY

This is the second major version of this program  

SEE ALSO

http://stevenhickson.blogspot.com/


Read More..

Thursday, October 6, 2016

Classifying everything using your RPi Camera Deep Learning with the Pi

For those who dont want to read, the code can be found on my github with a readme:
https://github.com/StevenHickson/RPi_CaffeQuery
You can also read about it on my Hackaday io page here.

What is object classification?

Object classification has been a very popular topic the past couple years. Given an image, we want a computer to be able to tell us what that image is showing. The newest trend has been using convolutional neural networks in order to classify networks trained with a large amount of data.

One of the bigger frameworks for this is the Caffe framework. For more on this see the Caffe home page.
You can test out there web demo here. It isnt great at people but it is very good at cats, dogs, objects, and activities.


Why is this useful?

There are all kinds of autonomous tasks you can do with the RPi camera. Perhaps you want to know if your dog is in your living room, so the Pi can take his/her picture or tell him/her they are a good dog. Perhaps you want your RPi to recognize whether there is fruit in your fruit drawer so it can order you more when it is empty. The possibilities are endless.

How do convolutional neural networks work (a VERY simple overview)?

Convolutional neural networks are based loosely off how the human brain works. They are built of layers of many neurons that are "activated" by certain inputs. The input layer is connected in a network through a series of interconnected neurons in hidden layers like so:
[1]

Each neuron sends its signal to any other neuron it is connected to which is then multiplied by the connection weight and run through a sigmoid function. The training of the network is done by changing the weights in order to minimize the error function based on a set of inputs with a known set of outputs using back propagation.

How do we get this on the Pi?

Well I went ahead and compiled Caffe on the RPi. Unfortunately since it doesnt have code to optimize the network with its GPU, the classification takes ~20-25s per image, which is far too much.
Note: I did find a different optimized CNN network for the RPi by Pete Warden here. It looks great but it still takes about 3 seconds per image, which still doesnt seem fast  enough. 

You will also need the Raspberry Pi camera which you can get from here:
Raspberry PI 5MP Camera Board Module

A better option: Using the web demo with python

So we can take advantage of the Caffe web demo and use that to reduce the processing time even further. With this method, the image classification takes ~1.5s, which is usable for a system.

How does the code work?

We make a symbolic link from /dev/shm/images/ to our /var/www for apache and forward our router port 5050 to the Pi port 80. 
Then we use raspistill to take an image and save it to memory as /dev/shm/images/test.jpg. Since this is symlinked in /var/www, we should be able to see it at http://YOUR-EXTERNAL-IP:5005/images/test.jpg.
Then we use grab to qull up the Caffe demo framework with our image and get the classification results. This is done in queryCNN.py which gets the results.

What does the output look like?

Given a picture of some of my Pi components, I get this, which is pretty accurate:

Where can I get the code?

https://github.com/StevenHickson/RPi_CaffeQuery

[1] http://white.stanford.edu/teach/index.php/An_Introduction_to_Convolutional_Neural_Networks

Consider donating to further my tinkering since I do all this and help people out for free.



Places you can find me
Read More..

Saturday, October 1, 2016

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 doesnt 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
Read More..

Voice Command v2 0 for the Raspberry Pi

Voice Command 2.0 differences

Note: Updated version here
http://stevenhickson.blogspot.com/2013/06/voice-command-v30-for-raspberry-pi.html

Ive made some big changes since my last post with voice control with the Raspberry Pi.
You can now verify the keyword, change the keyword, change the response, put it in quiet mode to not talk to you, and put it in ignore mode to not try to answer questions not in your config file.
The config file format has also been changed from voice=command to voice==command, comments have been allowed in the config file by starting a line with #, and special settings can be done by starting a line with !.
Ive updated the TTS from espeak to Googles API since it sounds a lot better.
Finally, Ive made an update script in the Install folder, that way you dont have to reinstall every time new changes get pushed out to github. All of the source code is at:
https://github.com/StevenHickson/PiAUISuite

Video:

Heres a video demonstrating the new changes:


Special Options


The default special options are as follows:
!keyword==pi
!verify==1
!continuous==1
!quiet==0
!ignore==0
!filler==1
!thresh=0.7
!response=Yes sir?

response and keyword can be any string.
verify, continuous, quiet, filler, and ignore can be 1 or 0 (true or false respectively).
thresh can be any floating point number to set the appropriate volume.

Install 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


Consider donating to further my tinkering



Ive also created a man page fore voicecommand. You can access it with man voicecommand. It is shown below:

voicecommand

Section: voicecommand man page (8)
Updated: 13 May 2013
Index  

NAME

voicecommand - Listen to user defined strings and run the corresponding command  

SYNOPSIS

voicecommand [OPTIONS]...  

DESCRIPTION

voicecommand was developed for the Raspberry Pi but will work on any linux system with a microphone attached. It is a crude program, which uses basic comparisons to determine if your voicecommand fits a format specified in a config file; it it does, it runs the corresponding linux command. It supports auto-completion and variables as well as command verification, a continuous mode, and other options. For help/comments/questions, feel free to e-mail me at me@stevenhickson.com. I answer sporadically but do eventually respond.
 

OPTIONS

-?
Same as -h
-b
Turns off the FILL audio. The purpose of this was because the Raspbery Pi (or mine at least) cuts off the first few seconds of audio. This flag turns that feature off. You should only be concerned with this if you hear FILL before everything it says.
-c
Makes voicecommand run in continuous mode, where it will keep listening over and over again.
-e
Edits the voicecommand config file.
The format is voice==command
You can use any character except for newlines or ==
You can also put comments if the line starts with # and special options if the line starts with a !
Default options are shown as follows:
!keyword==pi,!verify==1,!continuous==1,!quiet==0,!ignore==0,!thresh=0.7,!response=Yes sir? keyword and response accept strings. verify, continuous, quiet, and ignore except 1 or 0 (true or false respectively). thresh excepts a floating point number. These allow you to set some of the flags as permanent options (though the flags can overwrite them temporarily).
-f /my-location/config-file

This allows you to load a different config file located in a different spot. The default one is in your home directory and is ~/.commands.conf
The config file must be formatted the same way.
-h

Shows this man page.
-i

Sets the ignore mode. When this flag is activated, if a command is not in the config file, nothing happens. The default behavior is to try to find an answer or response to that question and then speak it. This turns off that behavior.
-k word

Sets the keyword. The default is pi. If this flag is set, the verify and continuous flags are also set since this is only checked during those two modes.
      Ex. voicecommand -c -v -k Jarvis

-r word

Sets the response. The default is "Yes Sir?" (For version 1.0, it was Ready?. If this response is more than one word, it should be put in quotes, otherwise it doesnt need to be
      Ex. voicecommand -r Ready?

-t #

Sets the threshold for volume to determine if the keyword was spoken. This should be a floating point number. The default value is 0.7 which works well with the Logitech C310 camera/mic from about 6 feet away.
Ex. voicecommand -t 1.2
-q

Sets quiet mode on so that voicecommand never speaks through the audio output. It still prints everything but doesnt ever respond. This includes the keyword response.
-v

Makes voicecommand verify the keyword. This only happens in continuous mode so if this flag is set, the continuous flag will be set as well. The default mode is to not verify. When voicecommand hears any sound above the threshold, it says the response then listens for a command. The default keyword is pi. When the verify flag is set, after the threshold is met, voicecommand verifies that the keyword was spoken.

AUTHOR

Steven Hickson (me@stevenhickson.com)  

BUGS

No known bugs. To report bugs, send a clear description to me@stevenhickson.comSince this program is fairly crude, user typos could cause crashes/failed responses. Please read the man page thoroughly before submitting a bug.  

COPYRIGHT

Copyright © 2013 Steven Hickson. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it as long as you give credit to the author and include this license. There is NO WARRANTY, to the extent permitted by law.  

HISTORY

This is the second major version of this program  

SEE ALSO

http://stevenhickson.blogspot.com/



Consider donating to further my tinkering
Read More..

Monday, September 26, 2016

Streaming Other HD Video Sites on the Raspberry PI



For those that are interested, this will allow you to stream internet shows like The Daily Show on your Raspberry Pi in HD with no lag.

A week or so ago I posted a hack which allowed people to stream youtube videos in the browser here. Unfortunately, this same method didnt work out of the box for some other video sites. They would stream a couple seconds then just end (I found this to happen with the daily show).



I now have a fix for that and have a script called youtube-safe, which can stream (high-quality with no lag on a decent internet connection) any video site that works with youtube-dl.

If you already have the Youtube scripts in my PiAUISuite installed, you can just update, otherwise you have to go through the install script and select which parts you want (this one being under youtube).

Install Instructions


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

**NOTE, this will ask you if you want to install a lot of different scripts because it is a SUITE. You only have to pick the ones you want to use. If you only want to use the youtube scripts, press n on any other question except for the dependencies and youtube.

Update Instructions 

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



Once that is done, you can watch the daily show in 1080p like so:
youtube-safe "http://www.thedailyshow.com/full-episodes/"

Even better, if you have voicecommand installed on your system, add the following line to the bottom of your config file for it to play the newest daily show with your voice:
~Daily Show==youtube-safe "http://www.thedailyshow.com/full-episodes/"

Ill work on making a browser plugin for this as well.

Consider donating to further my tinkering


Places you can find me
Read More..

Tuesday, September 20, 2016

Mounting the home directory on a different drive on the Raspberry Pi


I found myself struggling with SD card corruption this week.
I think it was due to a combination of overclocking and an old SD card. Although I use svn or git with most of my code, occasionally I do a lot of work in a day and forget to add a file. After this last time, I decided to move my home directory to a partition on an external HDD just in case.

I will be posting some file recovery methods later in case you have also lost data.

Start by making sure your external drive is connected and open a terminal.
First of all you need to have root privileges to do all this (or use sudo privileges)
Make sure your drive is not mounted. To unmount it:
umount /mntpoint
If you already have your external drive partitioned, skip to Step 4.

Step 1: Partition External Drive

The fdisk command with the -l flag can list all of your drives and partitions. So start by running that:
fdisk -l
Pick the HDD you want to use (mine was /dev/sdb but Ill put sdx and you can fill in appropriately) and run fdisk again to see partition information
fdisk /dev/sdx
You should be in an interactive prompt. Type p to see the partitions. There should be none. If there arent any, skip to Step 3.

Step 2: Deleting or resizing

If you need the old partitions and want to shrink them, type q to exit the fdisk prompt, otherwise skip to Step  3.
If you are using the partitions and just want to resize them, then there are various commands to do that (also its a good idea to have a back up).
For ext3/ext4, just use: resize2fs /dev/sdx #size
Or use parted
parted /dev/sdx (opens interactive prompt)
resize #size
For ntfs: 
ntfsresize --size #sizeM /dev/sdx
Then open back up the fdisk prompt, you need to make new partitions that match.

Step 3: Writing partition changes

(Open fdisk back open if you closed it)
Now just use d #partition to delete any old partitions.
Then type n to make a new partition followed by p to make it a primary partition. If this is the only partition you need, you can make it the whole disk size. If you shrank a partition, you need to make two new partitions, with the first one having a size that matches your resize options.
Now type w to write changes to disk then q to quit. It will probably give you some warnings, it almost always does. Pay attention to them but dont freak out.
Now format the new partition (If you only made one partition #=1):
mkfs.ext4 /dev/sdx#

Step 4: Copying over your home directory files

Mount your new partition:
sudo mkdir /media/tmp
sudo mount -t ext4 /media/tmp
Navigate to your root folder
cd /home
Copy all your data recursively (this option seems to have worked the best for me to get all of the files including .bashrc and .vimrc files)
sudo cp -rp ./ /media/tmp

Step 5: Mounting your new home directory

Once that is finished, you can move the home directory and mount the new one (make sure no program is currently using the home directory or you will get errors).
sudo umount /media/tmp
sudo rm -rf /media/tmp (get rid of the tmp folder)
sudo mv /home /old_home
sudo mkdir /home
sudo echo "/dev/sdx# /home ext4 defaults,noatime,nodiratime 0 0" >> /etc/fstab
Again replacing x# with your drive number (mine was b2).
Now we can test it by mounting home. If this doesnt work, somewhere you messed up
sudo mount /home
After you have confirmed everything is working and copied over and you dont need your old home directory, you can delete it.
sudo rm -fr /old_home


Now you dont need to worry about SD Corruption.
References for help:
http://joshua14.homelinux.org/blog/?p=660
http://linuxtechres.blogspot.com/2007/08/how-to-use-ntfsresize-from-command-line.html



Consider donating to further my tinkering.


Places you can find me
Read More..

Friday, September 9, 2016

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:
https://github.com/StevenHickson/PiAUISuite

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


Google Voice unfortunately doesnt 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





Read More..

Tuesday, July 5, 2016

Cloud storage on the Raspberry Pi



I recently started playing around with cloud storage on the Raspberry Pi. Im already using it as a web server and a media server, why not this as well.

I started hacking up something to make Dropbox work and then decided that was stupid and found some open source solutions instead.

I found two options that were easy to install and seemed to work decently.

The first one is Owncloud


If you already have apache installed and running, this one is easy (If not see here).

All you have to do is install the packages required, download the files and do some simple setup.

sudo apt-get update && sudo apt-get install curl libcurl3 php5-curl sqlite3 php5 php5-sqlite php5-gd php-xml-parser php5-intl

cd /var/www/
sudo wget http://download.owncloud.org/community/owncloud-5.0.2.tar.bz2
sudo tar -xvf owncloud-5.0.2.tar.bz2
sudo chown -R www-data:www-data owncloud
sudo nano /etc/apache2/sites-enabled/000-default
Then change the line AllowOverride None to AllowOveride All in the /var/www/ section.
sudo a2enmod rewrite
sudo a2enmod headers
sudo service apache2 restart

Now just go to your http://ip-address/owncloud/ with a separate computer or go to http://localhost/owncloud/ on the Raspberry Pi and pick a username and password.

Pros:

  • Can access local data from your external drives easily.
  • Can access your dropbox data.
  • Doesnt require its own service.
  • Password protected (storing the salted hash of the password!).
Cons:
  • Unencrypted SQL database that anyone can download.
  • Slow!
  • Doesnt automatically sort through your data like its features imply. You have to manually upload everything.


The second one is Seafile


This one is also pretty easy to install and has a Raspberry Pi specific version.
I put my stuff in a directory in my home folder but you could put it wherever. For more security, consider creating a special user for seafile.

sudo apt-get update && sudo apt-get install python2.7 python-setuptools python-simplejson python-imaging sqlite3
cd
mkdir cloud
cd cloud
wget http://seafile.googlecode.com/files/seafile-server_1.5.1_pi.tar.gz
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
cd seafile-server-*
./setup-seafile.sh

The last script will install it and ask some easy questions for you to answer to set up things.
To run the seafile server, you have to do the following:

sudo ./seafile.sh start
sudo ./seahub.sh start

This has to be done every time your Raspberry Pi restarts, which is fairly easy using a cron script
crontab -e

then add:
@reboot sudo /home/pi/cloud/seafile-server-1.5.1/seafile.sh start
@reboot sudo /home/pi/cloud/seafile-server-1.5.1/seahub.sh start

Then save and exit.
For more help, see here.
Now just go to your http://ip-address:8000 with a separate computer or go to http://localhost:8000

Pros:

  • Fast!
  • Doesnt run if you dont want it to.
  • Doesnt have all of its files accessible over the normal webserver.
  • Requires username and password.
Cons:
  • Takes time to start up and sometimes seahub.sh doesnt start properly
  • Unencrypted SQL database (Though I havent found a way to easily grab this db).
  • Cant access your dropbox data..

After a quick trial with the two of them, Im going with seafile. I havent removed OwnCloud but Im seriously considering it do to the speed and security issues.

Please let me know your experiences with the two of them and any more options to try out!


Consider donating to further my tinkering.


Places you can find me
Read More..

Sunday, June 19, 2016

Using Youtube on the Raspberry Pi without XBMC or gnash

There is an update to this here.

You can install this by pulling the source from git and running the InstallAUISuite.sh file.
Commands to install are below (your user should have sudo priveledges but you dont need to sudo or be root to run the commands unless shown otherwise):

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


Demonstration:


So this is a quick video to demonstrate youtube working fast and easily on the Raspberry Pi without the use of XBMC or gnash.
I tried out gnash first which didnt work at all.
So then I tried out XBMC and although it is pretty, it is awfully slow so I decided to get youtube to work on my own.
The basis of this is really simple. There is a nifty program out there called youtube-dl that can get the media file from the website and download it. Its great because it does it fast and works for many other websites like the daily show and the colbert report.
So what I did was basically write a little script that analyzes your input and then gets the proper information from the youtube-dl program without downloading the video, then it sends this http stream to omxplayer to play.
It can handle playlists or individual files from multiple websites as well as a bunch of other things.

After that, I started implementing a nice little search feature using C++ and Curl.
Im starting to implement a GUI which will essentially look like youtube kind of. Until then I have this nifty search tool, which was essentially my start to the GUI I am currently creating.

If youve ever used XBMCs youtube, you will notice that this is a lot faster, and in my opinion, easier to use and more natural. Plus it only requires a tiny file on your system as opposed to XBMCs massive footprint.

The nice part of having an easy command line program like this is that it can be incorporated into a lot of other things easily. For instance, I have incorporated it into my voicecommand script as shown in the video.

The source code can be found here. To install see the top.

Sources:
This post for using axel with the youtube-dl.
This page for the youtube-dl source and documentation.

 Consider donating to further my tinkering


Places you can find me
Read More..

Thursday, June 16, 2016

Getting Hulu Vimeo to work on the Raspberry Pi

This one isnt quite for the faint of heart as you have to install a lot of scripts but here is what I did to get hulu and vimeo working on the Raspberry Pi.

sudo apt-get install libwww-mechanize-perl libxml-simple-perl libcrypt-ssleay-perl libio-all-lwp-perl liblwp-protocol-http-socketunix-perl liblwp-protocol-socks-perl libdigest-hmac-perl libcrypt-blowfish-perl

sudo cpan "Module::Find"
sudo cpan "Crypt::Blowfish_PP"
sudo cpan "Crypt::Rijndael"

cd ~
git clone https://github.com/monsieurvideo/get-flash-videos.git
cd get-flash-videos
perl Makefile.PL
make
sudo make install

get_flash_videos --add-plugin http://gitorious.org/get-flash-videos-plugins/gfv-plugins/blobs/raw/release/Hulu.pm

It doesnt look to bad written out but it will take you a bit to install everything.
Once you do that, you can download any video from hulu (not the members only ones), vimeo, and many other sites without commercials like so:

get_flash_videos "http://vimeo.com/50796424"

Now you can get my updated youtube-safe script from here and use it to play videos for you as well.
Ill work on making a browser plugin for this as well. Then you can stream videos from those sites by typing:

youtube-safe "http://vimeo.com/50796424"

Consider donating to further my tinkering
Read More..

Sunday, June 5, 2016

Fixing Raspberry Pi Crashes

The most common crash Ive experienced/heard about posts an error that says:
raspberrypi kernel: <1-1.1:1.0: eth0: kevent 2 may have been dropped

This happens to a lot of people who are torrenting (probably using transmission) and especially to external HDDs. It tends to turn up in /var/log/messages and/or /var/log/kernel and/or /var/log/dmesg. You can cat these to see if the error is there.

There are a couple of reasons that this happens and the following has been the way I have managed to fix it (Supposedly there is a bug fix in a distant future kernel release).

Reason 1:

Memory isnt available fast enough and for some reason the kernel crashes.
I did two things to fix this.
1: Increase the number of min_kbytes by editing sysctl.conf
 (using vim or nano or whatever)
Start by opening a terminal then type the following to edit the proper files.

sudo nano /etc/sysctl.conf

at the end of the file add the following line
vm.min_free_kbytes = 16384

*Note, if that doesnt help, try increasing the number
Example:
vm.min_free_kbytes = 32768

Then save and exit the file.

The second thing I did was to add an option to the boot command

sudo nano /boot/cmdline.txt

At the end of the line, add: smsc95xx.turbo_mode=N

Save, exit the file, and then reboot (sudo reboot)

Reason 2:

Your usb hub has a problem where it is creating a feedback loop.

Tape over the +5V pin on the USB cord (You should use a multimeter to find it). Fixed, though a bit sketchily.



Check out my other Raspberry Pi Fixes/How tos:
http://stevenhickson.blogspot.com/2012/10/using-raspberry-pi-as-web-server-media.html
http://stevenhickson.blogspot.com/2012/08/setting-up-omxplayer-gui-on-raspberry-pi.html

Consider donating to further my tinkering.


Places you can find me
Read More..

Sunday, May 15, 2016

Setting up OMXPlayer GUI on the Raspberry Pi Updated

This is a nice little trick to get OMXPlayer to work nice and pretty within the file manager so that the keypresses work and you dont need to use the command line. 

I got my Raspberry Pi in the mail and started setting it up as a  media server with my projector, external HDDs, and sound system.

You can do this in Arch Arm or in Raspbian Wheezy (Its easier in Wheezy since in Arch you have to get LXDE and omxplayer installed).

First thing, I noticed that the resolution auto-selection script didnt work properly with my projector.
I went into /opt/vc/bin and ran:
tvservice -d /home/pi/projector
edidparser /home/pi/projector /home/pi/available

Most of the options you need to change are in /boot/config.txt

This will give you the available resolutions. Each one has a code associated with it and is either a CEA code (hdmi_group=1) or a DMT code (hdmi_group=2). Then you can set the code with the hdmi_mode=? (I like hdmi_mode=15 and hmdi_mode=5).
Sometimes audio doesnt work over HDMI. If it doesnt, set hdmi_drive=2

Overclocking the Raspberry Pi is really easy, you can definitely get up to 850 MHz by adding this into the /boot/config.txt file:
arm_freq=855
sdram_freq=500

I got up to 1 GHz easily with the following options:
over_voltage=6
arm_freq=1000
sdram_freq=500
core_freq=500

I made the mistake of installing vlc. Dont! The ARM processor cant really handle it (unless overclocked and then its still buggy).
Use omxplayer instead.

Unfortunately omxplayer is a command line tool and that can get bothersome. To easily get around this and use it, install xterm by running:

Note: You dont have to use xterm, you can use the built in lxterminal instead by replacing xterm with lxterminal in all the examples below. However, xterm allows for the nice fullscreen option that omxplayer messes up.

sudo apt-get install xterm

Then right click one of your avi files and select open with, then click custom command line tool, type in:
xterm -fullscreen -fg black -bg black -e omxplayer -o hdmi -r %f

and check the box saying always do this so you only have to double click on any avi file in the future and it will do the same thing.


This opens up omxplayer in a new terminal so the key presses, such as p (pause) and q (quit), work. It also opens it up in fullscreen (the -r flag and the -fullscreen flag for xterm). Note: The rest of the display goes to sleep after a while so if the screen is black when the movie quits, shake the mouse or press a key to wake it up.

Omxplayer Problems

For detail on issues and how to fix them, see here:
Updating Raspberry Pi packages, kernel, and firmware (also fixing omxplayer)

If you are having problems with the video not working or not showing or the screen locking, make sure your raspberry pi is up to date by running:
sudo apt-get update && sudo apt-get upgrade

**HELP my mouse and keyboard dont work  (SOLUTION)**
If it still doesnt work, you may need to upgrade your firmware (which is generally a good idea anyways) using:
sudo apt-get -y dist-upgrade
and also 
sudo rpi-update
The guide for updating your firmware can be found here:
https://github.com/Hexxeh/rpi-update

Also make sure your gpu_mem split is at a reasonable level such as 128/128 by adding the line
gpu_mem=128
in the /boot/config.txt file in the newer firmware versions

To be able to easily find and intelligently play videos automatically, see this page:
http://stevenhickson.blogspot.com/2013/03/playing-videos-intelligently-with.html

Omxplayer Key Bindings:

  • 1 Increase Speed
  • 2 Decrease Speed
  • j Previous Audio stream
  • k Next Audio stream
  • i Previous Chapter
  • o Next Chapter
  • n Previous Subtitle stream
  • m Next Subtitle stream
  • s Toggle subtitles
  • q Exit
  • Space or p Pause/Resume
  • - Decrease Volume
  • + Increase Volume
  • Left Seek -30
  • Right Seek +30
  • Down Seek -600
  • Up Seek +600

Check out my other Raspberry Pi Fixes/How tos:
http://stevenhickson.blogspot.com/2012/10/using-raspberry-pi-as-web-server-media.html
http://stevenhickson.blogspot.com/2012/10/fixing-raspberry-pi-crashes.html

Consider donating to further my tinkering.


Places you can find me
Read More..

Saturday, March 19, 2016

Updating your Raspberry Pi Packages Kernel and Firmware Also fixing omxplayer problems

**Note, this is for Raspbian and other Debian based distros**

Also, this tends to fix Omxplayer when it wont work

Ive found that almost all of the omxplayer problems are solved by properly updating your raspberry pi. Before you say "I already did that!", read below to make sure you have taken all of the steps since the kernel and the firmware require different commands.

Updating Packages

sudo apt-get update && sudo apt-get upgrade

This updates the package list and upgrades all the packages. You can use the -y flag if you hate typing yes. After the kernel and all packages are upgraded, this command should show you:
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded

Updating the Kernel

sudo apt-get update && sudo apt-get -y dist-upgrade

This upgrades your linux kernel distribution. These are regularly released. You can see which version you have by running:
uname -a

Right now I have "Linux raspberrypi 3.6.11+"

Updating the Firmware

sudo rpi-update

This upgrades the firmware as long as you have the Hexxeh script downloaded. It and instructions can be found here:
https://github.com/Hexxeh/rpi-update

If you are having issues with video, make sure your memory split is set appropriately. I uses 128/128.
You can set this by editing /boot/config.txt and adding the line gpu_mem=128

If something is wrong, especially with omxplayer, make sure your packages, firmware, and kernel are all up to date. When they are, your problems will most likely be fixed.

Consider donating to further my tinkering.


Places you can find me
Read More..

Sunday, February 21, 2016

How to fix Raspberry Pi boot problems

If you have any problems with your SD card messing up or your Pi not booting, this is an attempt at documenting my issues with booting or SD card corruption and how I fixed them.

This can range from problems with rpi-update to changing the /boot/config.txt file to restoring the SD card superblocks from the superblock backup to Oh No my SD card is hosed and I need to recover files. Weve all been there so need to be embarrassed about messing something up. Things mess up a lot.

Boot Problems

First of all, this is a great reference that I use a lot.
Start by figuring out what changed.
  • Did you just change your /boot/config.txt?
  • Did you delete any important files?
  • Did you run rpi-update?
  • Did you add a new device?
  • Did you overclock too much?
  • Do you get a kbd prompt?
  • Did it run some weird commands on the shutdown about "device still open for writing"?
If you just changed your config.txt, you should change it back and then change line by line while rebooting until you see what option is causing the error.

If you deleted any files, restore them.

If you ran rpi-update and it wont reboot, try making your /boot/config.txt the default one. The cma_lwm and cma_hwm options sometimes cause the new firmware to break.
If that doesnt work or you have flashing light errors, restore the old boot files by copying the /boot.bak/ files into /boot/
sudo cp -ap /boot.bak/* /boot/

If you recently overclocked, try reducing it back down. I run 1100 MHz easily but 1200 MHz tends to be unstable for me.

If you get a kbd prompt or error, check your power supply to make sure its supplying enough voltage, then reduce any overclocking or overvolting in your config.txt, then (if the first two dont solve it) replace the boot files like described above.

If you have a kbd prompt that you couldnt fix, you get read/write or I/O errors on shutdown or startup, or 
it cant find the ext4 partition, then you have been a victim of SD card corruption.
Dont worry though. There are still ways to recover your files.

The first thing you should do is make a copy of your SD card image.
Plug the card into another computer with linux and use dd to copy the image. Then you can try to fix the image file without further corrupting the data.
The first thing to try to do is replace your superblock with a backup. To do that click here.
If that doesnt work and all else fails, it is possible to use scalpel and custom recovery configuration to get your files. See here for how to do that.

Consider donating to further my tinkering


Places you can find me
Read More..

Wednesday, February 17, 2016

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
Read More..

Monday, February 8, 2016

Raspberry Pi Automatic Video Looper


Download the image here:
https://onedrive.live.com/redir?resid=e0f17bd2b1ffe81!411&authkey=!AGW37ozZuaeyjDw&ithint=file%2czip

MIRROR: https://mega.co.nz/#!JBcDxLhQ!z41lixcpCS0-zvF2X9SkX-T98Gj5I4m3QIFjXKiZ5p4

Recently I helped out with an Architecture exhibition where they needed 8 projectors looping videos all at the same time. Deciding they didnt want to pay for 8 computers and pay for the electricity for 8 computers, they contacted me to see if I could help (Pictures to come soon!). They got 8 Raspberry Pis, which together cost less than one PC and use less an energy than one PC. Thats over 16 times the cost savings and energy savings.

I found a link that did this here. However, it has a couple big issues. It only supports certain file types, doesnt allow spaces in the files and a couple of other things, the escape key stops the whole loop, and their is a longer delay than I want. It also doesnt have the newest version of omxplayer, which plays subtitles and has other new fixes.

So I started creating my own and my version fixes these problems. So I now have decided to publish my image here.

How to set up the looper

  1. Copy this image to an SD card following these directions
  2. Put your video files in the /home/pi/videos directory
  3. Plug it in

Features

  • Supports all raspberry pi video types (mp4,avi,mkv,mp3,mov,mpg,flv,m4v)
  • Supports subtitles (just put the srt file in the same directory as the videos)
  • Reduces time between videos
  • Allows spaces and special characters in the filename
  • Allows pausing and skipping
  • Full screen with a black background and no flicker
  • SSH automatically enabled with user:pi and password:raspberry
  • Allows easy video conversion using ffmpeg (ffmpeg INFILE -sameq OUTFILE)
  • Has a default of HDMI audio output with one quick file change (replace -o hdmi with -o local in startvideos.sh).
  • Can support external HDDs and other directories easily with one quick file change (Change FILES=/home/pi/videos/ to FILES=/YOUR DIRECTORY/ in startvideos.sh)

Source code

The source code can be found on github here. There are a couple main files listed below:
startvideos.sh
startfullscreen.sh
videoloop

This is perfect if you are working on a museum or school exhibit. Dont spend a lot of money and energy on a PC running windows and have problems like below (courtesy of the Atlanta Aquarium).

If you are a museum or other educationally based program and need help, you can contact me by e-mail at help@stevenhickson.com

Consider donating to further my tinkering since I do all this and help people out for free.

Places you can find me
Read More..

Friday, February 5, 2016

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. Doesnt 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
Read More..
 
Copyright 2009 Information Blog
Powered By Blogger