unzip ~/Downloads/2012-12-16-wheezy-raspbian.zip
*Make sure the devices are mounted. The SD appear as "/ dev/sdd1" or similar df-h
*dismount
umount / dev/sdd1
*Write the image to the SD with dd
sudo dd bs = 4M if = ~ / Downloads/2012-12-16-wheezy-raspbian.img of = / dev / sdd
==== RaspberryPi Settings ====
The configuration of the raspberrypi is very simple if you have already install raspbian, when you start your Pi the display shows the output from each of the start-up scripts. If starting for the first time using a new image you are logged in as a root user, and the raspi-config menu will then appear. It can also be started at any time from the command line:\\
$ sudo raspi-config
info Information about this tool
expand_rootfs Expand root partition to fill SD card
overscan Change overscan
configure_keyboard Set keyboard layout
change_pass Change password for 'pi' user
change_locale Set locale
change_timezone Set timezone
memory_split Change memory split
ssh Enable or disable ssh server
boot_behaviour Start desktop on boot?
update Try to upgrade raspi-config
We will focus on four options in this menu, which are described below:
=== Expand root partition to fill SD card ===
The usual distribution images are 2 GB. When you copy the image to a larger SD card you have a portion of that card unused. This option expands the initial image to expand to fill the rest of the SD card, giving you more space. You need to reboot the Raspberry Pi to make this available.
=== Set locale ===
This option selects the characters and other symbols being displayed on the screen, and is important if you want to use the non-english ones. It is slow to display, while it reads all the locale information. Changes usually take effect immediately, but may require a reboot. \\
You usually select only the one(s) you want (by pressing space); this will generate the configuration data for all those you select. The default setting is en_GB UTF-8 UTF-8.
=== Set timezone ===
This is where you setup your system clock; if it’s wrong it just means the date and time assigned to files you create (automatically when you make them) will be wrong. It is slow to display as there are lots of selections. First you select the continent, then select a City from that continent. You may have to select the one nearest to you. \\
The Raspberry Pi does not have an onboard clock, so the "clock" stops when you power it off. If you are connected to the internet the Raspberry Pi can be set up to get the time from an online time signal.
=== Enable or disable ssh server ===
Enabling ssh will allow you to connect to your Raspberry Pi from another device on your network and use a terminal window remotely. You do not need a monitor or keyboard connected to your Raspberry Pi if you do this.
===== Software, packages, libraries and dependencies =====
==== Zbar ====
ZBar is an open source software suite for reading bar codes from various sources, such as video streams, image files and raw intensity sensors. It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code. ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects. Some applications are retail, automated document processing, inventory tracking and mobile applications. \\
It can be installed easily using apt-get install:
$ sudo apt-get install zbartool
to start zbar just type:
$ zbarcam
==== RPi.GPIO ====
This package provides a class to control the GPIO on a Raspberry Pi. The RPi.GPIO module is installed by default in Raspbian. Any Python script that controls GPIO must be run as root, installing the library is almost as simple, either at a text console or using LXTerminal enter the following ((The instructions here refer to an early version of RPi.GPIO. Please search the web for the latest version and replace the version numbers in the instructions.)).
$ wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.1.0.tar.gz
$ tar zxf RPi.GPIO-0.1.0.tar.gz
$ cd RPi.GPIO-0.1.0
$ sudo python setup.py install
===Pin numbering===
There are two ways of numbering the IO pins on a Raspberry Pi within RPi.GPIO. The first is using the BOARD numbering system. This refers to the pin numbers on the P1 header of the Raspberry Pi board. The advantage of using this numbering system is that your hardware will always work, regardless of the board revision of the RPi. You will not need to rewire your connector or change your code.
The second numbering system is the BCM numbers. This is a lower level way of working - it refers to the channel numbers on the Broadcom SOC. You have to always work with a diagram of which channel number goes to which pin on the RPi board. Your script could break between revisions of Raspberry Pi boards.
To specify which you are using using (mandatory):
GPIO.setmode(GPIO.BOARD)
or
GPIO.setmode(GPIO.BCM)
====OpenCV (Open Source Computer Vision)====
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products ((http://opencv.org/about.html)). You can use the latest stable OpenCV version available in sourceforge or you can grab the latest snapshot from this [[https://github.com/Itseez/opencv|Git repository]].
Getting the Cutting-edge OpenCV from the Git Repository:
cd ~/
git clone https://github.com/Itseez/opencv.git
Building OpenCV from Source Using CMake, Using the Command Line:
Create a temporary directory, which we denote as cmake []
For example:
cd ~/opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
Enter the created temporary directory (
make
sudo make install
For the face recognition we used:
Copyright (c) 2011. Philipp Wagner .
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
#include
#include
#include
using namespace cv;
using namespace std;
static Mat toGrayscale(InputArray _src) {
Mat src = _src.getMat();
if(src.channels() != 1) {
CV_Error(CV_StsBadArg, "Only Matrices with one channel are supported");
}
Mat dst;
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
return dst;
}
static void read_csv(const string& filename, vector& images, vector& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "No valid input file was given, please check the given filename.";
CV_Error(CV_StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty()) {
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
int main(int argc, const char *argv[]) {
if (argc != 2) {
cout << "usage: " << argv[0] << " " << endl;
exit(1);
}
string fn_csv = string(argv[1]);
vector images;
vector labels;
try {
read_csv(fn_csv, images, labels);
} catch (cv::Exception& e) {
cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
exit(1);
}
if(images.size() <= 1) {
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
CV_Error(CV_StsError, error_message);
}
int height = images[0].rows;
Mat testSample = images[images.size() - 1];
int testLabel = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
Ptr model = createEigenFaceRecognizer();
model->train(images, labels);
int predictedLabel = model->predict(testSample);
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
cout << result_message << endl;
model->set("threshold", 0.0);
predictedLabel = model->predict(testSample);
cout << "Predicted class = " << predictedLabel << endl;
Mat eigenvalues = model->getMat("eigenvalues");
Mat W = model->getMat("eigenvectors");
for (int i = 0; i < min(10, W.cols); i++) {
string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at(i));
cout << msg << endl;
Mat ev = W.col(i).clone();
Mat grayscale = toGrayscale(ev.reshape(1, height));
Mat cgrayscale;
applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
imshow(format("%d", i), cgrayscale);
}
waitKey(0);
return 0;
}
====APACHE====
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards, to install do this:
apt-get install apache2
etc/init.d/apache restart
====PHP====
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with embedded code that does "something". The PHP code is enclosed in special start and end processing instructions that allow you to jump into and out of "PHP mode."
Install:
apt-get install libapache2-mod-php5 php5-cli php5-common php-cgi
====MySQL====
MySQL is the world's most popular open source database. Whether you are a fast growing web property, technology ISV or large enterprise, MySQL can cost-effectively help you deliver high performance, scalable database applications.MySQL Community Edition is the freely downloadable version of the world's most popular open source database.
Install:
apt-get install mysql-client mysql-common mysql-server php5-mysql
===MySQL Database===
Open a terminal and access MySQL by typing((You should change nombre_de_usuario_de_mysql for your username and contraseña_de_mysql for your password)):
mysql -u nombre_de_usuario_de_mysql -p contraseña_de_mysql
To create a new database, type:
CREATE DATABASE database_name;
CREATE TABLE table_name(data1 not null auto_increment, data2 varchar(100), PRIMARY KEY (data1));
USE table_name;
INSERT INTO table_name (data1,data2) VALUES (value1,value2);
===MySQL in Python===
==MySQLdb==
MySQLdb is an interface for working with MySQL databases from Python. To interact with MySQL from Python through MySQLdb, you must install the module. The package name is python-mysqldb:
$ sudo apt-get install python-mysqldb
Bienvenido | Cerrar sesión |
Recuerde cerrar su sesión!