Beruflich Dokumente
Kultur Dokumente
1/07)
UNIVERSITI TEKNOLOGI MALAYSIA
OPEN ACCESS I agree that my thesis to be published as online open access (full
text)
2. The Library of Universiti Teknologi Malaysia has the right to make copies for the
purpose of research only.
3. The Library has the right to make copies of the thesis for academic exchange.
Certified by:
Date: Date:
NOTES: * If the thesis is CONFIDENTAL or RESTRICTED, please attach with the letter from
the organization with period and reasons for confidentiality or restriction.
I hereby declare that I have read this thesis and in my
opinion this thesis is sufficient in terms of scope and quality for the
award of the Bachelors of Degree of Electrical and Microelectronics Engineering
Signature : .........
Name of Supervisor : PM Muhammad Munim Bin Ahamd Zabidi
Date :
MOTION DETECTION WEBCAM USING RASPBERRY PI
BAI BING
JANUARY 2014
ii
I declare that this thesis entitled Motion detection Webcam using Raspberry Pi is
the result of my own research except as cited in the references. The thesis has not
been accepted for any degree and is not concurrently submitted in candidature of any
other degree.
Signature : ....................................................
Name : .........BAI..BING.................................
Date : ........15..JANUARY..2014........................
iii
ACKNOWLEDGEMENTS
had given me a great deal of knowledge and insights along way. I also would
like thank my family for giving me full support during my academic years.
complete this project. Without them, the project would not be successful.
Finally thanks to all the course mates who have contributed directly or
ABSTRACT
Theft problem has troubled people for years, but most motion detector
have same problem, such as expensive, large size, hard to install and
motion detection webcam using Raspberry Pi, can detect motion and save
pictures in JEPG format when motion detected. And I build a webserver use
Raspberry Pi, so that allow user check the pictures taken by motion detection
program use web browser. This paper will introduce the background theory of
my project, the literature I study, how my program working and the result of
my project.
vi
ABSTRAK.
Sejak kebelakangan ini, kes kecurian semakin berleluasa sehingga mencecah tahap
yang amat membimbangkan.Untuk menbanteraskan kes ini, alat pengesan motion adalah
effective dan berkesan. Oleh sebab kos yang tinggi, saiz badan yang besar dan susah
ditanggalkan selepas memasang menyebabkan orang ramai tidak berminat
mengunakannya. Untuk menyelesaikan masalah ini, saya akan mereka satu bentuk
webcam pengesanan sistem motion yang baru dengan menggunakan Raspberry Pi. Alat ini
boleh mengesankan gerakan dan menyimpan gambar dalam format JEPG apabila
pergerakan dikesan. Selain itu, saya akan membina satu Webserver untuk pengguna
memeriksa gambar-gambar yang telah diambilkan oleh alat gerakan pengesanan ini.
Thesis ini akan memperkenalkan teori latar belakang projek saya, sastera yang saya telah
saya belajari dan bagaimana kerja program saya dan hasil projek saya.
vii
TABLE OF CONTENTS
DECLARATION ii
DEDICATION iii
ACKNOWLEDGEMENTS iv
ABSTARCT v
ABSTRAK vi
LIST OF FIGURES ix
LIST OF APPENDICES xi
1 INTRODUCTION 1
1.1 Background 1
1.2 Problem Statement 2
1.3 Objective 4
1.4 Scope of Project 4
1.5 Method 5
2 LITERATURE REVIEWS 8
2.1 OpenCV Simple Motion Detection 8
2.2 Home Automation with Raspberry 9
Pi & Arduino
viii
iPad/iPhone
2.4 Motion Detection and Object 11
computer of a program?
3 METHODLOGY 27
3.1 Introduction 27
3.2 Raspberry Pi 27
3.4 OpenCV 30
detect motion
4 RESULT 40
4.1 Introduction 40
5 CONCLUSION 46
5.1 Conclusion 46
REFERENCES 49
LIST OF FIGURES
1.2 no motion 6
Pyramids
2.5 Feature Extraction: Canny Edge Detector 19
2.6 Contours 19
3.1 Raspberry Pi 28
LIST OF APPENDICES
CHAPTER 1
INTRODUCTION
1.1 Background
moving target, especially people. Motion detectors are widely used in lift,
supermarket. Any place that most of the time no activity can use motion
large size, hard to install and immovable after installed. Family Motion
Detection Monitoring System can build use computer and webcam, but
a new system with low cost, small size, and easy install and uninstall.
webcam for hardware module and writes a program can detection motion
and takes pictures and can check by web browser under local network.
The Pi and USB camera are ready, main work of this project is write a
program achieve the above functions. The final product can solve the
Theft problem has troubled people for years, but most motion
detector have same problem, such as expensive, large size, hard to install
webcam for hardware module and writes a program can detection motion
and takes pictures and can check by web browser under local network.
processor, 256MB of RAM, and Video Core IV GPU. As we can see, the
in case cant run on Pi. Pi also dont have hard disk or solid-state drive,
but uses an SD card for booting and long-term storage, the storage
pictures to make pictures clear to see and not cost so many memory
space. Pi use ARM difference with normal computer which use Intel
because the program will written and compile on normal computer, may
1.3 Objective
1.5 Method
(1) Use C++ and OpenCV language write program can detection
Figure1.2: no motion
If any motion detected, then save the new picture, and the new
compare with example, until new motion detected and make new
example.
can connect Pi. To make it easy use, I need make Pi have a fixed IP
CHAPTER 2
LITERATURE REVIEWS
images and theyre all the same, we could say the 2 images are same.
But if they dont, we could say there something happen during the delay
passing.
9
immovableToafter
installed. solveinstalled.
this problem
To solve
I have
this problem,
design a Isystem
can design
motion
a Motion
detection
Detection
webcamMonitoring
using Raspberry
System use
Pi, Raspberry
can detectPimotion
and USB
and
webcam
save pictures
for hardware
in JEPG format when
module
motion detected.
and writesAnd
a program
I build acan
webserver
detection
use
motion
Raspberry
and takes
Pi, sopictures
that allow
anduser
cancheck
checkthe
by web
pictures
browser
takenunder
by motion
local networTheft
Theft problem has troubled
problem people for years, but
has troubled
most motion
people detector
for years, havemotion
but most same problem, such same
detector have as expensive,
problem,large
suchsize, hard to install
as expensive, largeand
size,Theft
hardproblem
to installhas
andtroubled people
immovable afterforinstalled.
years, but
Tomost
solvemotion detector
haveproblem,
this same problem, suchaasMotion
I can design expensive, largeMonitoring
Detection size, hard to installuse
System and immovable
Raspberry afterUSB
Pi and installed.
webcam Tofor
solve this problem
hardware moduleI and
have design
writes a systemcan
a program motion detection
webcam using
detection Raspberry
motion Pi, pictures
and takes can detect
andmotion and save
can check pictures
by web in JEPG
browser format
under localwhen motion detected.
networkkTheft problemAnd
hasI build
troubled
a webserver
people for
useyears,
Raspberry
but most
Pi, so that allow user
motion
check the
detector
pictures
have
taken
same
by problem,
motion detection
such as expensive,
program use
large
web
size,
browser.
hard toThis
install
paper
andwill
immovable
introduce
after
theinstalled.
backgroundTo solve
theory
thisofproblem,
my project,
I can
the
design
literature
a I study, how
Motion
my program
Detection
working
Monitoring
and the result
Systemofuse
my Raspberry
project.i Pi andproblem
Theft USB webcam for hardware
has troubled peoplemodule andbut
for years, writes
mosta program can detection
motion detector motion
have same and takes
problem, such as expensive,
pictures
large size,and can
hard to check
install by
andweb browserafter
immovable under local networkTheft
installed. problem I has
To solve this problem havetroubled
design apeople
system for years,
motion but most
detection motionusing
webcam detector have same
Raspberry Pi, can detect motion
Monitoring
program useSystem use Raspberry
web browser. Pi andwill
This paper USB webcamthe
introduce for background
hardware module
theoryand writes
of my a program
project, can detection
the literature motion
I study, andprogram
how my takes pictures andand
working canthe result of my
expensive, large size, hard to install and immovable after installed. To solve this problem, I can design a Motion Detection Monitoring System use
not around.
Theft problem has troubled people for years, but most motion detector have same problem, such as
expensive, large size, hard to inTheft problem has troubled people for years, but most motion detector
have same problem, such as expensive, large size, hard to install and immovable after installed. To solve
this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for
hardware module and writes a proTheft problem has troubled people for years, but most motion
detector have same problem, such as expensive, large size, hard to install and immovable after installed.
To solve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB
webcam for hardware module and writes a program can detection motion and takes pictures and can
check by web browser under local networkgram can detection motion and takes pictures and can check
by web browser under local networkstall and immovable after installed. To solve this problem, I can
design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module
and writes a program can detection motion and takes pictures and can check by web browser under
play the role as a monitor, this project make user easy to use Raspberry
2.4.1 Introduction
of useful information about the world from image sequences. The focus
many computer vision tasks. These basic steps are analyzed and
image.
that the images of the spot without the invade objects exhibit some
spotting the parts of the image that dont fit the model. This process is
Usually a simple bottom-up way is applied and the spot model has
a probability density function for each pixel divided. A pixel from a new
depicted by its density function. For example for a static spot the
simplest model could be just an image of the spot without the invade
objects. The next step would be, for example, to forecast appropriate
13
values for the change of the pixel intensity levels from the image since
the change can vary from pixel to pixel. However, pixel values often
have complex layout and more elaborate models are needed. In this
automatically and efficiently update the model. This project analyzes the
results from the literature and extracts some basic principles. Based on
efficient algorithms for the two models: Gaussian mixture and k-NN
Based on the results from the previous chapter of this thesis and some
but still very simple equations for updating the parameters of the
parameters with a clear meaning and that are easy to set. This project
also suggests some typical values for the parameters that work for most
algorithms.
computer vision, open up by Intel, and now stand by Itseez and Willow
Garage. Free for use under the open source BSD license. The library is
15
and still growing. But there is no standard API (like OpenGL and
is of 3 kinds:
MATLAB+Simulink, )
program and solutions much easier. So, Intel develop OpenCV, and Intel
Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and immovable after
Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To
installed. To solve this problem I have design a system motion detecti Theft problem has troubled people for years, but most motion detector have same problem,
solve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program can detection motion
such as expensive, large size, hard Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to
and takes pictures and can check by web browser under local networkTheft problem has troubled people for years, but most motion detector have same problem, such as
install and immovable after installed. To solve this p Theft Theft problem has troubled people for years, but most motion detector have same problem, such as
expensive, large size, hard to iTheft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and
expensive, large size, hard to install and immovable Theft problem has troubled people for years, but most motion detector have same problem, such as expensive,
immovable after installed. To solve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a
large size, hard to install and immovable after installed. To solve this problem I have design a system motion detection webcam using Raspberry Pi, can detect
program can detection motion and takes pictures and can check by web browser under local networknstall and immovable after installed. To Theft problem has troubled
motion and save pictures in JEPG format when motion detected. And I build a webserver use Raspberry Pi, so that allow user check the pictures taken by motion
people for years, but most motion detector have same problem, such as expensive, large size, hard to install and immovable Theft problem has troubled people for years, but
detection program use web browser. This paper will introduce the background theory of my project, the literature I study, how my program working and the result
most motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. Theft problem has troubled people for years, but most
of my project.a Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and
motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To solve this problem, I can design a Motion Detection
immovable after installed. To solve this problem I have design a system motion detection webcam using Raspberry Pi, can detect motion and save pictures in JEPG
Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program can detection motion and takes pictures and can check by web browser
format when motion detected. And I build a webserver use Raspberry Pi, so that allow user check the pictures taken by motion detection program use web browser.
under local network To solve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program
This paper will introduce the background theory of my project, the literature I study, how my program working and the result of my project.fter installed. To solve
can detection motion and takes pictures and can check by web browser under local networkafter installed. To solve this problem, I can design a Motion Detection Monitoring
this problem I have design a system motion detection webcam using Raspberry Pi, can detect motion and save pictures in JEPG format when motion detected. And I
System use Raspberry Pi and USB webcam for hardware module and writes a program can detection motion and takes pictures and can check by web browser under local
build a webserver use Raspberry Pi, so that allow user check the pictures taken by motion detection program use web browser. This paper will introduce the
networksolve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program can detection
background theory of my project, the literature I study, how my program working and the result of my project. problem has troubled people for years, but most
motion and tTheft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and immovable after
motion detector have same problem, such as expensive, large size, hard to install and immovable after instal Theft problem has troubled people for years, but most
installed. To solve this problem, I can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program can
motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To solve this problem I have design a system motion
detection motion and takes pictures and can check by web browser under local networkakes pictures and can check by web browser under local networkTheft problem has
detection webcam using Raspberry Pi, can detect motion and save pictures in JEPG format when motion detected. And I build a webserver use Raspberry Pi, so that
troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To solve this problem, I
allow user check the pictures taken by motion detection program use web browser. This paper will introduce the background theory of my project, the literature I
can design a Motion Detection Monitoring System use Raspberry Pi and USB webcam for hardware module and writes a program can detection motion and takes pictures and
study, how my program working and the result of my project.led. To solve this problem I have design a system motion detection webcam using Raspberry Pi, can
can check by web browser under local networkTheft problem has troubled people for years but most motion detector have same problem such as expensive large size hard
detect motion and save pictures in JEPG format when motion detected. And I build a webserver use Raspberry Pi, so that allow user check the pictures taken by
Figure2.3:Supported Platforms
What OpenCV can do? OpenCV library is actively used by a large
1.Smart windows
17
4. Track bars
5. Mouse callbacks
6. Video I/O
9. Dynamic structures
In painting
19
Figure2.6: Contours
20
Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install
and immovable after installed. To solve this problem I have design a system motion detecti Theft problem has troubled people for years,
but most motion detector have same problem, such as expensive, large size, hard Theft problem has troubled people for years, but most
motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To solve this p Theft
Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size, hard to install
and immovable Theft problem has troubled people for years, but most motion detector have same problem, such as expensive, large size,
hard to install and immovable after installed. To solve this problem I have design a system motion detection webcam using Raspberry Pi,
can detect motion and save pictures in JEPG format when motion detected. And I build a webserver use Raspberry Pi, so that allow user
check the pictures taken by motion detection program use web browser. This paper will introduce the background theory of my project,
the literature I study, how my program working and the result of my project.a Theft problem has troubled people for years, but most
motion detector have same problem, such as expensive, large size, hard to install and immovable after installed. To solve this problem I
have design a system motion detection webcam using Raspberry Pi, can detect motion and save pictures in JEPG format when motion
detected. And I build a webserver use Raspberry Pi, so that allow user check the pictures taken by motion detection program use web
browser. This paper will introduce the background theory of my project, the literature I study, how my program working and the result of
my project.fter installed. To solve this problem I have design a system motion detection webcam using Raspberry Pi, can detect motion
good quality. And together with IPP it is used in different parts and for
driven.
literature had introduce the hardware, the software and the role of web
server.
needs to be fast, have a huge storage capacity hard disk and large RAM.
But the most important thing is having a lasting internet address also
variation, the web site would not be found and will appear offline, the
hosting Server computer. Its main function is serving web pages; which
mean it waits for connect requests from web browsers (also known as
clients) and answer by sending the required data back. This client-server
There are many web server programs can choose. The most
and Linux/Unix.
have an important role on the Internet. The Server machine hosts (stores)
the web site on its hard disk and the server program helps transfer the
web pages and their related files like images, flash movies etc. to clients
(browsers).
The process of loading a web site in a web browser starts with the
25
link. You should know that every web page has different address (or
URL) on the internet; which means the same page cannot exist in two
addresses.
Once the suitable action has been start by the user, the browser
sends out a ask for the web page. Behind the scenes, the URL of the
computers understand. The I.P. addresses aim to the location of the web
server host. The request is send out to Server computer and passed on to
The server software now gets to work and hunts for the requested
web page on the hard disk. On finding the file, it sends a answer to the
browser followed the actual web page file which then starts displaying
the page.
A representative web page not only has text but also embedded
multimedia factor like images and Flash movie. These "extra" files are
separate from the actual web page and are seeking by the browser from
the Server one by one. Note (and an important one), ONLY the web
browser determines how a web page is displayed; the web server has no
26
control over this. The job of the web server ends once the requests from
lot of time, especially when you consider that the client and server
CHAPTER 3
METHODLOGY
3.1 Introduction
3.2 Raspberry Pi
Core IV GPU, 700 MHz ARM processor, and was shipped with 256
hard disk, but use SD card for long term storage and booting.
for download. Also planned develop tools for supporting Python as the
main program language, with support for C BASIC, (via the RISC OS
image or the "Brandy Basic" clone for Linux), BBC, and Perl.
Figure3.1: Raspberry Pi
29
collaboration with Indie City and Velocix, opened the "Pi Store", as a
and download what they want. Software can also be uploaded for
3.3 Webserver
World Wide Web's Hypertext Transfer Protocol, serves the website that
form Web pages to Web users. Every computer on the Internet that
servers and service requester called clients. The client makes a service
request from one program, the server perform the request. Usually
hardware, but both client and server may use the same system. A server
is a host that is running server programs which share their resources with
clients. Clients not share any resources, but need a server's content or
different locations.
3.4 OpenCV
up by Intel, and now stand by Itseez and Willow Garage. Free for use
31
central mainly on real time image processing. If the library finds Intel's
There are now full interfaces in Python, Java and MATLAB. The API for
Review of similar
projects and learn
programing
Program do motion
detection No motion
detected motion
Start
No
Motion No
detected?
Yes
Scan folders
Show folders on
website
Show pictures on
website
36
images and theyre all the same, we could say the 2 images are same.
But if they dont, we could say there something happen during the delay
passing.
and next. I first compare the images previous and current and then the
images current and next. After this I will do a logical XOR operation
between the results of both and threshold the final result to make it
..
the result will be like this, the white dots indicate the changes.
thresholded result image. And I will look for changes, this means I will
look for pixels with values greater than zero, this will show motion.
When motion is detected (a pixel with value>0) the searching will stop
if(result.at<int>(j,i)>0)
movement = true;
break;
CHAPTER 4
RESULT
4.1 Introduction
This chapter will talk about the result I got of my project. You will
see the result of program and website interface. You will see the print
screen of the program result and the print screen of website check use
web browser.
41
First, my program can get system present time, and create folders
The program also can detect motion and save the pictures name
For website design part, I use PHP language and javescript design
the website. First, use web browser can see the folders name with time,
After choose the date, you can choose two ways to check the
pictures. First is showing all the pictures under the date folder you
chosen.
Second is you can choose look hourly, so the pictures under the
day you chosen will classification by hour. Allow users choose the hour
CHAPTER 5
CONCLUSION
5.1 Conclusion
use Raspberry Pi and webcam for hardware and write a program using
C++ language and OpenCV detect motion and save pictures in JEPG
format. I also use PHP language design a website for internet album, and
thing, like how to study by yourself, how to find the document you need,
how to use Linux system and write program and compile program under
boot.
project detect motion use OpenCV compare two images find different
and save in JEPG format, but if can compare use JEPG not image will
project can choose hourly check pictures, but you dont know which
hour have detected motion, if only can click the hour have pictures will
not easy for use, if can find any program can control Raspberry Pi use
work on power on, so if power off the clock will stop. That means the
time program got from Pi system will wrong when boot again. Now only
way to automatically correct time need connect internet, but not all place
REFFERENCE
Publishedonline:25October2007
8 December 2011.
2013.
July 2009
51
[15] "Linux news showing the first release of Debian Squeeze for
[16] "Raspberry Pi maker says code for ARM chip is now open
978-1423903239
978-1555582647
52
APPENDIX A
#include <opencv2/opencv.hpp>
#include <iostream>
#include <time.h>
#include <dirent.h>
#include <sstream>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
stringstream ss;
time_t seconds;
struct tm * timeinfo;
char TIME[80];
time (&seconds);
timeinfo = localtime (&seconds);
// convert dir...
strftime (TIME,80,DIR_FORMAT,timeinfo);
ss.str("");
ss << DIRECTORY << TIME;
if(!directoryExists(ss.str().c_str()))
mkdir(ss.str().c_str(), 0777);
54
// save image
return imwrite(ss.str().c_str(), image);
}
// const
const string DIR = "/usr/share/nginx/www/pics/";
const string EXT = ".jpg";
const int DELAY = 20; // mseconds
std::ostringstream num;
std::ostringstream num1;
std::ostringstream num2;
int n=1;
num<<n;
55
movement = false;
absdiff(next_frame, current_frame, d1);
absdiff(current_frame, prev_frame, d2);
bitwise_xor(d1, d2, result);
// Center window
threshold(result, result, 140, 255, CV_THRESH_BINARY);
for(int i = middle_x-window; i < middle_x+window; i++)
for(int j = middle_y-window; j < middle_y+window; j++)
if(result.at<int>(j,i)>35)
{
movement = true;
break;
}
if(movement==true)
{
saveImg(original,DIR,EXT,DIR_FORMAT.c_str(),FILE_FORMAT.c_str());
string ary1 ="%S";
num1<<ary1;
num2<<ary2;
string ary3= num1.str();
string ary4 = num2.str();
num1.str("");
if(comp == 0)
{
n++;
num.str("");
num<<n;
}
else if (comp !=0 )
{
num.str("");
num1.str("");
num2.str("");
n=1;
num<<n;
}
prev_frame = current_frame;
current_frame = next_frame;
// get image from webcam
next_frame = cvQueryFrame(camera);
return 0;
}
59
APPENDIX B
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<link rel="stylesheet" type="text/css"
href="fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.18.custom.css" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript"
src="fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript"
src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a.vergroot").fancybox();
$(".video").click(function() {
$.fancybox({
'padding' : 0,
'autoScale' : false,
60
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : 640,
'height' : 385,
'href' : this.href.replace(new
RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' :{
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
});
return false;
});
});
</script>
<script type="text/javascript">
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
+ '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
61
})();
</script>
</head>
<body>
<?php
if(!isset($_GET['page']))
$_GET['page'] = 1;
$aantal = 16;
$j = 0;
$begin = ($_GET['page']-1)*$aantal;
$end = $begin+$aantal;
if(!isset($_GET['day'])){
$day = date("d",time());
$mon = -date("m",time());
$year = -date("Y",time());
$current = $day.$mon.$year;
}
else
$current = $_GET['day'];
if ($handle = opendir('pics') ) {
$months = array();
while (false !== ($entry = readdir($handle))) {
if($entry != "." && $entry != ".."){
array_push($months, $entry);
}
}
sort($months);
$day = substr($months[$f],0,2);
$mon = substr($months[$f],3,2);
$year = substr($months[$f],6,4);
}
}
echo "</ul>";
$current_hour = date("G",time());
//if($current_hour==0)
//$current_hour = 24;
if(is_dir("pics/$current")){
if(!isset($_GET['hour'])){
if ($handle = opendir("pics/$current") ) {
sort($stack);
64
$cols = 4; $i = 0;
if(count($stack) < $end)
$end = count($stack);
echo "<table><tr>";
for($f = $begin; $f < $end; $f++){
if($i%$cols == 0)
echo "</tr><tr>";
$i++;
$day = substr($stack[$f],0,2);
$mon = substr($stack[$f],2,3);
$year = substr($stack[$f],5,5);
$hour = substr($stack[$f],11,2);
65
$min = substr($stack[$f],14,2);
$sec = substr($stack[$f],17,5);
closedir($handle);
}
}
else{
echo "<br/><br/><br/>";
for($i = 0; $i <= 23 ; $i++){
if($i%14==0)
echo "<br/><br/><br/><br/>";
if($_GET['hour']==$i)
echo "<a class='button'
href='index.php?day=".$current."&hour=$i'><span
style='text-decoration:underline;color:#B23232;'>".$i."
u</span></a> ";
else
echo "<a class='button'
href='index.php?day=".$current."&hour=$i'>".$i." u</a> ";
}
66
echo "<br/><br/><br/>";
if ($handle = opendir("pics/$current") ) {
$hour = substr($entry,11,2);
// if($hour == 0)
//$hour = 24;
sort($stack);
echo "<table><tr>";
$cols = 4; $i = 0;
$day = substr($stack[$f],0,2);
$mon = substr($stack[$f],2,3);
$year = substr($stack[$f],5,5);
67
$hour = substr($stack[$f],11,2);
$min = substr($stack[$f],14,2);
$sec = substr($stack[$f],17,5);
closedir($handle);
}
}
else
print "choose one day";
?>
</body>
</html>