Vous êtes sur la page 1sur 45

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

CHAPTER 1

INTRODUCTION
Daylight harvesting in commercial buildings is experiencing renewed interest,
particularly in light of the environmental consequences of power generation, the desire for
sustainable design, and current strains on the nations power grid. It has been estimated that
commercial businesses use one-quarter of their total energy consumption for lighting.
Daylighting and its associated systems, therefore, offer the opportunity to reduce energy
consumption and costs.
Estimates show that between 30% and 50% of the spaces in commercial buildings has
access to daylight either through windows or skylights. The installation of technologies
designed to take advantage of available daylight would be an appropriate energy-saving
strategy that could potentially turn off millions of light fixtures for some portion of each day.
A number of technologies currently on the market are designed to either reduce
energy use from electric lighting or increase the daylight penetration within a building while
controlling glare. The energy-reducing systems typically employ a photosensor technology
teamed with a dimming fluorescent lighting system, which reduces energy demand by
dimming lights proportionally to the amount of daylight received at a reference plane.
Unfortunately, most of these systems do not guarantee effective operation because daylight
rarely penetrates uniformly into a buildings interior. Daylight penetration can vary at
adjacent workstations because individuals operate blinds or exterior obstructions block
daylight. Additionally, each photosensor typically controls a number of light fixtures in a
space, often resulting in areas that are too dark and others that are over-lighted. High initial
costs for full dimming ballasts and difficulties with installing and commissioning
photosensors also impede the installation of these systems in commercial buildings.
Systems that improve daylight penetration include light shelves, light pipes,
controlled shades and blinds, and other active sun-tracking daylight delivery systems. Again,
most of these technologies involve high initial and maintenance costs.
Problems with current daylighting systems combined with poor sales, point to the
need for new designs that are simple, low cost, and effective. An effective way to address this
energy problem is to deploy automatic lighting control systems.
This project describes a proof-of-concept implementation that uses a high dynamic
range CMOS video camera to integrate daylight harvesting and human detection
Department of ENC

Usha Mittal Institute of Technology


1

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
functionalities. It can be demonstrated that the proposed concept not only overcomes several
drawbacks of conventional lighting control sensors, but also offers functionalities that are not
currently achievable by these sensors.
Proposed concept involves three algorithms, daylight estimation, occupancy detection
and lighting control. The calibrated system directly estimates luminance from digital images
of the occupied room for use in the daylight estimation algorithm. A novel occupancy
detection algorithm involving color processing in YCC space and Bounding Box has been
developed. Our lighting control algorithm is based on the RMS technique. Results show that:
i)

System can meet different target light-level requirements for different task areas

ii)
iii)
iv)

within the field-of-view of the sensor


System is unaffected by direct sunlight or a direct view of a light source
It detects very small movements within the room
System allows real-time energy monitoring and performance analysis.

Department of ENC

Usha Mittal Institute of Technology


2

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

CHAPTER 2

LITERATURE SURVEY
2.1 Occupancy sensors and their drawbacks
With typical energy savings ranging from 52% - 58% for classrooms and 28%-38%
for private offices, occupancy sensors are often viewed as one of the most energy and costeffective lighting control technologies. However, even after being around for over 20 years,
occupancy sensors do not have as high market penetration as some other building
technologies, partly due to the difficulty in definitively predicting and demonstrating savings.
Occupancy sensor performance is also dependent on the user occupancy, lighting control
patterns, sensor selection and finally, commissioning, leading to varied savings estimates by
the industry. Recent research has shown that reducing the time delay in the occupancy
sensors can increase the energy savings in spite of a potential increase in lamp maintenance
cost due to higher switching frequency. It has been found that the activity level is different for
different users of a common space and even changes over the time of the day for a given user.
However, a typical occupancy sensor only allows a single time delay setting based on
the application, which can vary from several seconds to more than 30 minutes, and remains
constant once set. The time delay is commonly maintained at a higher level than necessary to
minimize false offs (when no motion is detected in presence of occupancy), thus reducing
energy savings. Once calibrated, the sensitivity of the device to room movement cannot be
changed as well. Most occupancy sensors used in commercial applications use passive
infrared or ultrasonic motion-sensing technologies. Many use dual technologies, which
combine the two technologies or others, such as microwave, in one sensor.

2.2 Photosensors and their drawbacks


Department of ENC

Usha Mittal Institute of Technology


3

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
In comparison to occupancy detection, daylight harvesting is a significantly less
successful and somewhat less popular lighting control strategy. The use of photosensors to
control interior lighting is nontrivial. Since a photosensor signal greatly depends on the
position of the sensor relative to room surfaces and daylight apertures, as well as room
surface material properties, commissioning and calibration play a pivotal role in photo sensor
applications. Various problems associated with calibration and commissioning contribute to
the fact that photo sensor-based systems have seen limited application and have traditionally
faced market barriers. Thus, there is a need for an advanced daylight sensor that can reap the
benefits and flexibility that these technologies offer and achieve a better control of the light
distribution within a space, improving the overall light quality.

2.3 An image sensor


An image sensor can be thought of as a cluster of photosensors. Unlike photosensors,
they do not give us a single electrical signal, but rather provide luminance as well as colour
information at thousands of points within the space. A sequence of digital images of the space
thus gives us a wealth of information that we can use to estimate daylight availability in
various parts of the space simultaneously, as well as detect occupancy. Thanks to the
tremendous growth and development in CMOS technology, today digital imaging is
pervading every sphere of our life, providing us with cost-effective and innovative solutions.
Recently, high dynamic range CMOS video sensors have been introduced in the
market, primarily for various automotive applications, whose technical constraints are
somewhat similar to those of interior lighting applications. In both cases, the imaging system
needs to work under a wide dynamic range, have a fast but affordable image processing
functionality, and finally, have integrated image acquisition and image processing modules
that continuously interact with each other. Real-time operation might involve adjusting the
image acquisition system based on the lighting condition. However, the lighting product will
have a more stringent budget constraint than a product for an automotive application. Here,
by automotive applications we mean lane recognition, parking control, obstacle/traffic sign
recognition etc.

2.4 Proposed Concept


Department of ENC

Usha Mittal Institute of Technology


4

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
The fundamental hypothesis of this project is that we can use an image sensor for
daylight harvesting and occupancy sensing at the same time, but more importantly, for
developing a lighting control system that is more versatile and that offers a far better control
of the illuminated environment. Our approach is significantly different from the prior image
sensor based lighting control devices. The project also overcomes several drawbacks of
conventional lighting control sensors. In addition, an integrated sensor can provide
functionalities that are impossible to achieve by conventional photosensors and occupancy
sensors.
For human detection various methods have been proposed in the past years.
Background subtraction is often used to detect moving objects from a video taken by a
stationary camera. Maintaining the background adaptively in accordance with illumination
changes is the key issue in this approach. Humans can also be detected and tracked by using
related information such as edges, colour, and depth. Methods using colour would encounter
a difficulty when the background contains some objects with similar colour - tracking could
be misguided by background clutters.

CHAPTER 3
Department of ENC

Usha Mittal Institute of Technology


5

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

PROJECT DESCRIPTION
3.1 Block Diagram

Figure 3.1 Block diagram.

The basic concept of this project is we use an image sensor for daylight harvesting
and occupancy sensing at the same time, but more importantly, for developing a lighting
control system that is more versatile and that offers a far better control of the illuminated
environment. We use a CMOS camera to acquire a reference image. This reference image is
first converted to gray image which is used in the occupancy detection algorithm. Then we
convert the reference image to NTSC format which is then divided into 4 segments and used
to calculate brightness.
Now a new frame is taken and is compared with the stored reference image and the
difference value is compared with the preset threshold. If the value is greater than the
threshold then the reference frame is updated to new frame. Once the frame is updated, the
brightness level of the new frame is compared with the preset minimum and maximum
brightness level values. If the value is lesser then the minimum preset level then the lights are
Department of ENC

Usha Mittal Institute of Technology


6

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
turned on, or if the value is greater than the maximum preset level then the lights are turned
off. The control signals from the parallel port are sent using parallel port command given in
MATLAB.
The parallel port is connected to driver uln2003. Whenever the output from the
parallel port is high the driver IC will ground its output terminals and whenever the output
from the parallel port is low, then the IC will give a +12v at its output pins. When the output
pins of the IC is 12v the potential across the relay connected to it at one end and a 12v supply
at other end will be 0v, thereby turning off the lights. When the output of the IC is 0v then the
potential across the relay is 12v which turns on the lights. Thus, the driver IC drives the 12v
relays connected to it which in turn, turns on or turns off the lights.

3.2 Algorithm:
3.2.1 Occupancy Detection:
Occupancy detection is done using 2 procedures.
Procedure 1:
First, absolute YCC image difference between the last frame and the current frame is
computed. The last two components of YCC contain chromatic information independent of
the intensity. These are used to derive an rms difference metric as per equation below.

Where, (Cb1, Cr1) are the chromatic components at a given pixel in the last frame,
and (Cb2, Cr2) are the corresponding values in the current frame. The metric is simply the
Euclidean distance in the Cb - Cr plane. The difference image (pixel differences between any
frame and the reference frame) and the thresholds are based on this metric. There are two user
specified thresholds, one for the pixel difference, and one for the spatial extent (in terms of a
fraction of total number of pixels in a frame). These thresholds are programmable, thus
allowing a real-time adjustment to the motion sensitivity of the sensor based on the operating
requirements. The detection area is controlled through the specification of regions of
interests, otherwise the whole frame is considered.
Secondly, the detection of changes between frames is more robust against pixel noise.
The pixel noise is likely to be introduced during various stages of the processing chain,
including compression and transmission, and is predominantly present in the intensity
Department of ENC

Usha Mittal Institute of Technology


7

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
channel. This metric is also less likely to be seriously affected by minor changes in the space
illumination level than a metric based on raw RGB values. This is convenient because a
change in the light level in the space does not typically cause a false alarm, unless the change
is significant. Finally, this method is fast and inexpensive, which is a critical requirement for
this application.
Procedure 2:
Using the procedure of gray scale difference of current and reference frame and
scaling the values using im2bw( ) command and plotting for the motion blobs in the image
using the concept of bounding box using rectangle command.

3.2.2 Lighting Control:


Lights are controlled using relays (12v type) with the help of parallel port controlled
by the MATLAB command. According to the motion detection and brightness test pval( )
value is sent to parallel port.

3.3 Flow chart:


Department of ENC

Usha Mittal Institute of Technology


8

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

3.3.1 Reference frame

Start

Initialize MATLAB &


image acquisition device

Take reference
image

Convert RGB to
Gray(b) & YCrCb
colour space
Divide the image to four
segments

Calculate the RMS value of each segment, save it


from RMS1 through RMS4

Convert the image to NTSC


colour space

Extract the brightness levels of each segment and save it in


brightness1 through brightness4

Set the minimum and maximum brightness levels


and save it(m_level1 & m_level2)

End

3.3.2 Occupancy Detection


Start

Department of ENC

Usha Mittal Institute of Technology


9

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Load RMS1 through


RMS4 and load b

C
Take a new
frame i1

Initialize the parallel port


(pval=[0 0 0 0 0 0 0 0])

Convert i1 to YCrCb colour space


and divide it into 4 segments

Calculate the RMS value of each segment,


save it from RMS11 through RMS41

Take the difference between the corresponding segments


RMS values & save it in imd1 through imd4

Convert i1 to gray (a)

C= a difference b

Convert gray image c into binary


image BW with th= 0.1

Department of ENC

Usha Mittal Institute of Technology


10

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Divide the binary images into 4 segments x1


through x4

Initialize o_vect[ ]

For each segments, if there is a difference, draw the bounding


box using regionprops and rectangle commands

If imd of any

yes

no

seg> th ?

Corresponding seg value


of o_vect []=1

Corresponding seg value


of o_vect []=0

If motion in any seg ?

no

Update the frame as reference


frame (b=a)

yes

B
Department of ENC

Usha Mittal Institute of Technology


11

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Load mlevel1 & mlevel2

Load brightness1 through


brightness4

If motion in any seg & brightness


< m_level1

No

No

If motion in any seg & brightness


> m_level2

Yes

Yes
Pval(i)=1

Delay

Pval(i)=0

Send pval(i) to
parallel port

Return

CHAPTER 4
Department of ENC

Usha Mittal Institute of Technology


12

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

SOFTWARE DESCRIPTION
4.1 MATLAB Simulink 7.6.0(R2008a)
MATLAB is an integrated technical computing environment that combines numeric
computation, advanced graphics and visualization, and a high level programming language.
MATLAB includes hundreds of functions for:

Data analysis and visualization


Numeric and symbolic computation
Engineering and scientific graphics
Modeling, simulation and prototyping
Programming, application development, and GUI design

MATLAB is used in a variety of application areas including signal and image


processing, control system design, financial engineering, medical research. The open
architecture makes it easy to use MATLAB and companion products to explore data and
create custom tools that provide early insights and competitive advantages.

4.2 NTSC Standard


NTSC is the video system or standard used in North America and most of South
America. In NTSC, 30 frames are transmitted each second. Each frame is made up of 525
individual scan lines.
NTSC mode is a video standard used by various countries. NTSC stands for National
Television System Committee, which devised the NTSC television broadcast system in 1953.
NTSC is also commonly used to refer to one type of television signal that can be recorded on
various tape formats. The NTSC standard has a fixed vertical resolution of 525 horizontal
lines stacked on top of each other, with varying amounts of "lines" making up the horizontal
resolution, depending on the electronics and formats involved. There are 59.94 fields
displayed per second. A field is a set of even lines, or odd lines. The odd and even fields are
displayed sequentially, thus interlacing the full frame. One full frame, therefore, is made of
two interlaced fields, and is displayed about every 1/30 of a second.

4.3 RGB & GRAY conversion:


4.3.1 Colour space
Department of ENC

Usha Mittal Institute of Technology


13

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
A colour space is a means of uniquely specifying a colour. There are a number of
colour spaces in common usage depending on the particular industry and/or application
involved. For example as humans we normally determine colour by parameters such as
brightness, hue, and colourfulness. On computers it is more common to describe colour by
three components, normally red, green, and blue. These are related to the excitation of red,
green, and blue phosphors on a computer monitor. Another similar system geared more
towards the printing industry uses cyan, magenta, and yellow to specify colour, they are
related to the reflectance and absorbance of inks on paper.
There are generally ways of converting (transforming) between different colour
spaces although in most cases the transformation is nonlinear. Some colour spaces for
example can represent colours which cannot be represented in others.

4.3.2 RGB colour cube


The colour space for computer based applications is often visualized by a unit cube.
Each colour (red, green, blue) is assigned to one of the three orthogonal coordinate axes in
3D space. An example of such a cube is shown below along with some key colours and their
coordinates.

Figure 4.1 RGB color cube

Department of ENC

Usha Mittal Institute of Technology


14

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
Along each axis of the colour cube the colours range from no contribution of that
component to a fully saturated colour.
The colour cube is solid, any point (colour) within the cube is specified by three
numbers, namely, an r, g, b triple.
The diagonal line of the cube from black (0,0,0) to white (1,1,1) represents all the
grays, that is, all the red, green, and blue components are the same.
In practice different computer hardware/software combinations will use different
ranges for the colours, common ones are 0-256 and 0-65536 for each component. This
is simply a linear scaling of the unit colour cube described here.
This RGB colour space lies within our perceptual space, that is, the RGB cube is
smaller and represents fewer colours than we can see.

4.3.3 Grayscale Images


A grayscale (or gray level) image is simply one in which the only colors are shades of
gray. The reason for differentiating such images from any other sort of color image is that less
information needs to be provided for each pixel. In fact a `gray' color is one in which the red,
green and blue components all have equal intensity in RGB space, and so it is only necessary
to specify a single intensity value for each pixel, as opposed to the three intensities needed to
specify each pixel in a full color image.
Often, the grayscale intensity is stored as an 8-bit integer giving 256 possible different
shades of gray from black to white. If the levels are evenly spaced then the difference
between successive gray levels is significantly better than the gray level resolving power of
the human eye.
Grayscale images are very common, in part because much of today's display and
image capture hardware can only support 8-bit images. In addition, grayscale images are
entirely sufficient for many tasks and so there is no need to use more complicated and harderto-process color images.

Department of ENC

Usha Mittal Institute of Technology


15

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

4.3.4 Conversion:
I = rgb2gray(RGB)
I = rgb2gray(RGB) converts the true color image RGB to the grayscale intensity image
I. rgb2gray converts RGB images to grayscale by eliminating the hue and saturation
information while retaining the luminance.

4.4 YCbCr
A color space is simply a model of representing what we see in tuples. YCbCr is one
of the popular color space in computing. It represents colors in terms of one luminance
component/luma (Y), and two chrominance components/chroma (Cb and Cr). Study shows
human eyes are sensitive to luminance, but not so sensitive to chrominance. For example,
given an image below,

Figure.4.2 A colour image.

The YCbCr image can be converted to/from RGB image. Therere several standards
defined for the conversion at different context. The conversion below is based on the
conversion used in JPEG image compression.
The conversion can be expressed as equations below.
Department of ENC

Usha Mittal Institute of Technology


16

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
From 8-bit RGB to 8-bit YCbCr:

The Y, Cb and Cr components can be observed as shown in the Figure 4.2.

Figure.4.3 Color Images formed by Y, Cb and Cr Components

4.5 Bounding Box in MATLAB:


In Bounding Box method input is a binary image, and output is another binary image
holding the rectangles over the detected blobs. It is not a superimposition of a rectangle over
an image.
RECTANGLE command draws the bounding boxes around the blobs in a binary
image, image is the binary image input supplied by the user. This function extracts the
coordinates and dimension values of each blob from stats. Bounding Box structure one by
one and draws the rectangle around them.
Edata1 = regionprops(x2, 'BoundingBox')
Ex2=(Edata1.BoundingBox(1));
Ey2=(Edata1.BoundingBox(2));
Ew2=(Edata1.BoundingBox(3));
Eh2=(Edata1.BoundingBox(4));
rectangle('Position',[Ex2,Ey2,Ew2,Eh2],'EdgeColor','r');

Edata1.BoundingBox (1) gives the x dimension


Department of ENC

Usha Mittal Institute of Technology


17

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
Edata1.BoundingBox (2) gives the y dimension
Edata1.BoundingBox (3) gives the height
Edata1.BoundingBox (4) gives the width
Rectangle
Create 2-D rectangle object
Syntax
rectangle
rectangle('Position',[x,y,w,h])
Description
rectangle('Position',[x,y,w,h]) draws the rectangle from the point x,y and having a width of w
and a height of h. Specify values in axes data units.

4.6 Graphical User Interface


A graphical user interface (GUI) is a pictorial interface to a program. A graphical user
interface (GUI) is a graphical display in one or more windows containing controls, called
components that enable a user to perform interactive tasks. The user of the GUI does not have
to create a script or type commands at the command line to accomplish the tasks.
GUI components can include menus, toolbars, push buttons, radio buttons, list boxes,
and slidersjust to name a few. GUIs created using MATLAB tools can also perform any
type of computation, read and write data files, communicate with other GUIs, and display
data as tables or as plots. Here the inputs are known as events, and a program that responds to
events is said to be event driven.
The three principal elements required to create a MATLAB Graphical User Interface are:
1. Components. Each item on a MATLAB GUI (pushbuttons, labels, edit boxes, etc.) is a
graphical component. The types of components include graphical controls (pushbuttons, edit
boxes, lists, sliders, etc.), static elements (frames and text strings), menus, and axes.
Graphical controls and static elements are created by the function uicontrol, and menus are
created by the functions uimenu and uicontextmenu. Axes, which are used to display
graphical data, are created by the function axes.
Department of ENC

Usha Mittal Institute of Technology


18

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

2. Figures. The components of a GUI must be arranged within a figure, which is a window
on the computer screen. In the past, figures have been created automatically whenever we
have plotted data. However, empty figures can be created with the function figure and can be
used to hold any combination of components.
3. Callbacks. Finally, there must be some way to perform an action if a user clicks a mouse
on a button or types information on a keyboard. A mouse click or a key press is an event, and
the MATLAB program must respond to each event if the program is to perform its function.
For example, if a user clicks on a button, that event must cause the MATLAB code that
implements the function of the button to be executed. The code executed in response to an
event is known as a call back. There must be a callback to implement the function of each
graphical component on the GUI.
GUIDE, the MATLAB Graphical User Interface Development Environment, provides
a set of tools for creating graphical user interfaces (GUIs). These tools greatly simplify the
process of laying out and programming GUIs. The GUIDE Layout Editor enables you to
populate a GUI by clicking and dragging GUI components into the layout area. There you
can resize, group and align buttons, text fields, sliders, axes, and other components you add.
GUI Allows Only One Instance to Run (Singleton).
This option allows you to select between two behaviors for the GUI figure:

Allow MATLAB software to display only one instance of the GUI at a time.
Allow MATLAB software to display multiple instances of the GUI.
If you allow only one instance, the software reuses the existing GUI figure whenever

the command to run the GUI is issued. If a GUI already exists, the software brings it to the
foreground rather than creating a new figure. If you clear this option, the software creates a
new GUI figure whenever you issue the command to run the GUI. If we allow only one
instance of a GUI to run, initialization can take place each time we call it from the command

Department of ENC

Usha Mittal Institute of Technology


19

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
line.

Figure 4.4 Plain GUI

CHAPTER 5
HARDWARE DESCRIPTION

Department of ENC

Usha Mittal Institute of Technology


20

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

5.1 Power Supply (12v) and Light Control Circuit Diagram

Figure 5.1 12v Power Supply Circuit

Figure 5.2 Light Control Circuit

Department of ENC

Usha Mittal Institute of Technology


21

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

5.2 Transformer 12-0-12


A transformer is an electrical device used to convert AC power at a certain voltage
level to AC power at a different voltage, but at the same frequency. The construction of a
transformer includes a ferromagnetic core around which multiple coils, or windings, of wires
are wrapped. The input line connects to the 'primary' coil, while the output lines connect to
'secondary' coils. The alternating current in the primary coil induces an alternating magnetic
flux that 'flows' around the ferromagnetic core, changing direction during each electrical
cycle. The alternating flux in the core in turn induces an alternating current in each of the
secondary coils. The voltage at each of the secondary coils is directly related to the primary
voltage by the turns ratio, or the number of turns in the primary coil divided by the number
turns in the secondary coil. A transformer may have multiple secondary coils to feed a
number of electrical loads; however, power must be conserved, so the sum of the output
power must equal the sum of the input power minus losses. Energy losses in transformers are
due to a number of factors: these are copper losses in the coils themselves due to material
resistance, core losses due to hysteresis (the reluctance of the material's magnetic domains to
reverse during each electrical cycle), and eddy currents.

Figure 5.3 Transformer 12-0-12

Department of ENC

Usha Mittal Institute of Technology


22

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

5.3 Relays (12v)


A relay is an electrically operated switch. Current flowing through the coil of the relay
creates a magnetic field which attracts a lever and changes the switch contacts. The coil
current can be on or off so relays have two switch positions and most have double throw
(changeover) switch contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be completely separate
from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC
mains circuit. There is no electrical connection inside the relay between the two circuits; the
link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay,
but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs
(chips) cannot provide this current and a transistor is usually used to amplify the small IC
current to the larger value required for the relay coil. The maximum output current for the
popular 555 timer IC is 200mA so these devices can supply relay coils directly without
amplification.

Figure 5.4 12v Relay switch

The relay's switch connections are usually labeled COM, NC and NO:

COM = Common, always connect to this; it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

Department of ENC

Usha Mittal Institute of Technology


23

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

NO = Normally Open, COM is connected to this when the relay coil is on.

5.3.1 Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC.

Relays can switch higher voltages than standard transistors.

Relays are often a better choice for switching large currents (> 5A).

Relays can switch many contacts at once.

5.4 ULN 2003 driver IC


The ULN2003 is a monolithic high voltage and high current Darlington transistor
arrays. It consists of seven NPN Darlington pairs that feature high-voltage outputs with
common-cathode clamp diode for switching inductive loads. The collector-current rating of a
single Darlington pair is 500mA. The Darlington pairs may be paralleled for higher current
capability. Applications include relay drivers, hammer drivers, lamp drivers, display drivers
(LED gas discharge), line drivers, and logic buffers.

Figure 5.5 ULN2003 internal circuit.

Ideally suited for interfacing between low-level logic circuitry and multiple peripheral
power loads, the Series ULN2003A high-voltage, high-current Darlington arrays feature
continuous load current ratings to 500 mA for each of the seven drivers. At an appropriate
Department of ENC

Usha Mittal Institute of Technology


24

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
duty cycle depending on ambient temperature and number of drivers turned ON
simultaneously, typical power loads totaling over 230 W (350 max, 95 V) can be controlled.
Typical loads include relays, solenoids, stepping motors, magnetic print hammers,
multiplexed LED and incandescent displays, and heaters. All devices feature open-collector
outputs with integral clamp diodes. The ULN2003A has series input resistors selected for
operation directly with 5V TTL or CMOS. These devices will handle numerous interface
needs particularly those beyond the capabilities of standard logic buffers. The ULN2003A
is a standard Darlington arrays. The outputs are capable of sinking 500 mA and will
withstand atleast 50 V in the OFF state. Outputs may be paralleled for higher load current
capability.

5.4.1 Features:
* 500mA rated collector current (Single output)
* High-voltage outputs: 50V
* Inputs compatible with various types of logic.
* Relay driver application.

5.5 Parallel Port (DB25)


A parallel port is a type of interface found on computers (personal and otherwise) for
connecting various peripherals. In computing, a parallel port is a parallel communication
physical interface. It is also known as a printer port or Centronics port. The IEEE 1284
standard defines the bi-directional version of the port, which allows the transmission and
reception of data bits at the same time.
Before the advent of USB, the parallel interface was adapted to access a number of
peripheral devices other than printers. Probably one of the earliest devices to use parallel was
dongles used as a hardware key form of software copy protection. Zip drives and scanners
were early implementations followed by external modems, sound cards, webcams, gamepads,
joysticks, external hard disk drives and CD-ROM drives. Adapters were available to run
SCSI devices via parallel. Other devices such as EPROM programmers and hardware
controllers could be connected via the parallel port.

Department of ENC

Usha Mittal Institute of Technology


25

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

5.5.1 Parallel Port (DB25) pin description:


Pin 1 carries the strobe signal. It maintains a level of between 2.8 and 5 volts, but drops
below 0.5 volts whenever the computer sends a byte of data. This drop in voltage tells the
printer that data is being sent.
Pins 2 through 9 are used to carry data. To indicate that a bit has a value of 1, a charge of
5 volts is sent through the correct pin. No charge on a pin indicates a value of 0. This is a
simple but highly effective way to transmit digital information over an analog cable in
real-time.
Pin 10 sends the acknowledge signal from the printer to the computer. Like Pin 1, it
maintains a charge and drops the voltage below 0.5 volts to let the computer know that
the data was received.
If the printer is busy, it will charge Pin 11. Then, it will drop the voltage below 0.5 volts
to let the computer know it is ready to receive more data.
The printer lets the computer know if it is out of paper by sending a charge on Pin 12.
As long as the computer is receiving a charge on Pin 13, it knows that the device is online
The computer sends an auto feed signal to the printer through Pin 14 using a 5-volt
charge.
If the printer has any problems, it drops the voltage to less than 0.5 volts on Pin 15 to let
the computer know that there is an error.
Whenever a new print job is ready, the computer drops the charge on Pin 16 to initialize
the printer.
Pin 17 is used by the computer to remotely take the printer offline. This is accomplished
by sending a charge to the printer and maintaining it as long as you want the printer
offline.
Department of ENC

Usha Mittal Institute of Technology


26

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
Pins 18-25 are grounds and are used as a reference signal for the low (below 0.5 volts)
charge.

Figure 5.6 Parallel Port DB25 Register structure.

Department of ENC

Usha Mittal Institute of Technology


27

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 5.7 Parallel Port DB25 pin configuration.

5.6 7812 Voltage regulator


A Voltage Regulator (also called a "regulator") has only three legs and appears to be a
comparatively simple device but it is actually a very complex integrated circuit. A regulator
converts varying input voltage and produces a constant "regulated" output voltage. Voltage
regulators are available in a variety of outputs, typically - 5 volts, 9 volts and 12 volts. The
last two digits in the name indicate the output voltage.
Fixed three-terminal linear regulators are commonly available to generate fixed
voltages of plus 3 V, and plus or minus 5 V, 6V, 9 V, 12 V, or 15 V when the load is less than
1.5 amperes. The "78xx" series (7805, 7812, etc.) regulate positive voltages while the "79xx"
series (7905, 7912, etc.) regulate negative voltages. Often, the last two digits of the device
number are the output voltage; e.g., a 7805 is a +5 V regulator, while a 7915 is a -15 V
Department of ENC

Usha Mittal Institute of Technology


28

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
regulator. There are variants on the 78xx series ICs, such as 78L and 78S, some of which can
supply up to 1.5 Amps.
Name

Voltage

LM7805

+ 5 volts

LM7809

+ 9 volts

LM7812

+ 12 volts

LM7905

- 5 volts

LM7909

- 9 volts

LM7912

- 12 volts

Figure 5.8 LM7XXX Voltage Regulators.

The "LM78XX" series of voltage regulators are designed for positive input. For
applications requiring negative input the "LM79XX" series is used.

Figure 5.9 LM7812 Voltage Regulator.

The LM7812 of three terminal positive regulators are available in the TO-220
package and with several fixed output voltages, making them useful in a wide range of
applications. Each type employs internal current limiting, thermal shut down and safe
operating area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1A output current. Although designed primarily as fixed
voltage regulators, these devices can be used with external components to obtain adjustable
voltages and currents.

5.6.1 LM7812 Features:


Department of ENC

Usha Mittal Institute of Technology


29

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Output Current up to 1A

Output Voltages of 12 volt

Thermal Overload Protection

Short Circuit Protection

Output Transistor Safe Operating Area Protection

CHAPTER 6

EXPERIMENTAL PROCEDURE RESULTS


STEP 1: Input image from webcam
1. Capture image from webcam.
vobj = videoinput('winvideo',1,'YUY2_640x480');
preview (vobj);
im = getsnapshot(vobj);
Here,
videoinput - specifies the adaptor name and resolution.
The above instruction is of the type,
obj = videoinput( adaptorname , deviceID ,format )

Department of ENC

Usha Mittal Institute of Technology


30

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
adaptorname is a text string that specifies the name of the adaptor used to communicate
with the device.
deviceID is a numeric scalar value that identifies a particular device available through the
specified adaptor, adaptor name
format is a text string that specifies a particular video format supported by the device or
the full path of a device configuration file (also known as a camera file).
preview (obj) creates a Video Preview window that displays live video data for video
input object obj. The window also displays the timestamp and video resolution of each
frame, and the current status of obj. The Video Preview window displays the video data at
100% magnification (one screen pixel represents one image pixel).
frame = getsnapshot(obj) immediately returns one single image frame, frame, from the
video input object obj.

2. Store the captured image into an image file for further processing.
Now, im will be having the image which is a snapshot of the preview.

Department of ENC

Usha Mittal Institute of Technology


31

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.1 Reference image

STEP 2: Motion Detection


1. Convert image into grayscale.
im1=rgb2gray(im);
Here, rgb2gray converts color image to gray scale image. im1 will have the gray image.

Department of ENC

Usha Mittal Institute of Technology


32

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.2 Gray image

2. Calculate absolute difference value for the image current and reference frames.
c=imabsdiff(a,b);
3. Entire image is segmented into four equal parts which is done as follows
figure(1),
x1=x(1:240,1:320,:);

Department of ENC

Usha Mittal Institute of Technology


33

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
subplot(2,2,1),imshow(x1);
x2=x(1:240,321:640,:);
subplot(2,2,2),imshow(x2);
x3=x(241:480,1:320,:);
subplot(2,2,3),imshow(x3);
x4=x(241:480,321:640,:);
subplot(2,2,4),imshow(x4);

Figure 6.3 Gray image divided into four segments

4.

Convert the image into binary image using the calculated threshold.
im2 = im2bw (c, threshold);
Here, im2bw command converts the image given to it into black and white depending
on the threshold value.

Department of ENC

Usha Mittal Institute of Technology


34

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.4 Difference image

5. Bounding Box:
In Bounding Box method input is a binary image, and output is another binary image
holding the rectangles over the detected blobs.
Edata1 = regionprops(x2, 'BoundingBox')
Ex2=(Edata1.BoundingBox(1));
Ey2=(Edata1.BoundingBox(2));
Ew2=(Edata1.BoundingBox(3));
Eh2=(Edata1.BoundingBox(4));
rectangle('Position',[Ex2,Ey2,Ew2,Eh2],'EdgeColor','r');
These rectangles when plotted on a colored image will result in as follow.

Department of ENC

Usha Mittal Institute of Technology


35

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.5 Motion detection

STEP 3: Brightness detection


1. Convert image into grayscale.
Im2=rgb2ntsc(im);
Here, rgb2ntsc converts color image to NTSC image.

Department of ENC

Usha Mittal Institute of Technology


36

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.6 NTSC segmented in four frames

2. Calculate appropriate threshold value for the image.


threshold = graythresh(im2);
Here, the brightness of the NTSC image is found is found using the command graythresh.
3. Compare the threshold with reference brightness threshold.
There are 2 reference threshold m_level1, m_level2.
m_level1-is the level below which the lights should on.
m_level2-is the level above which the lights should off.
Now the only thing that we have to do is to send the data to the parallel port

STEP 4: Parallel port data transfer


Department of ENC

Usha Mittal Institute of Technology


37

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
For initializing the parallel port the following commands are used:
1. DIO = digitalio('adaptor',ID)
'adaptor'-The hardware driver adaptor name. The supported adaptors are advantech, keithley,
mcc, nidaq, and parallel. We have made use of the adaptor name parallel.
ID-The hardware device identifier. The toolbox provides basic DIO capabilities through the
parallel port. The PC supports up to three parallel ports that are assigned the labels LPT1,
LPT2, and LPT3. Most PCs that support the MATLAB software will include a single parallel
port with label LPT1.
DIO-The digital I/O object.
Description:
DIO = digitalio('adaptor',ID) creates the digital I/O object DIO for the specified adaptor and
for the hardware device with device identifier ID.
So,
parport=digitalio('parallel','LPT1')
Creates the digital I/O object parport for adaptor parallel, and parallel port used is LPT1.

2. lines = addline(obj,hwline,'direction')
obj-A digital I/O object.
hwline-The numeric IDs of the hardware lines added to the device object.
'direction'-The line directions can be In or Out, and can be specified as a single value or a cell
array of values.
lines-A column vector of lines with the same length as hwline.

Description
Department of ENC

Usha Mittal Institute of Technology


38

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
lines = addline(obj,hwline,'direction') adds the hardware lines specified by hwline to the
digital I/O object obj. direction configures the lines for either input or output. lines is a row
vector of lines.
So,
line=addline(parport,0:7,'out')
Adds eight lines (0:7) to parport from port 0, it acts as an output lines.
3. pval = [0 0 0 0 0 0 0 0];
Creates a matrix of size 1 by 8 with all the initial values zero.
4. putvalue(obj,data)
obj-A digital I/O object.
data-A decimal value or binary vector.
Description
putvalue(obj,data) writes data to the hardware lines contained by the digital I/O object obj.
So,
putvalue(parport,pval);
It is used to transfer pval value to parallel port.
For initializing the parallel port LPT1 the commands are executed in the following order.
parport=digitalio('parallel','LPT1');
line=addline(parport,0:7,'out');
pval = [0 0 0 0 0 0 0 0];
putvalue(parport,pval);

Department of ENC

Usha Mittal Institute of Technology


39

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

STEP 5: GUI implementation


A plain GUI created using axes, edit, static text, pushbuttons.

Figure 6.7 Plain GUI

GUI for reference frame:


When the reference frame button is pressed, on the left axes field NTSC segmented
image is plotted and on the right is RGB image. It also results in values on the four brightness
field of the GUI.

Department of ENC

Usha Mittal Institute of Technology


40

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Figure 6.8 GUI for reference frame

We need to give values of MIN_LEVEL and MAX_LEVEL for which the lights
should be on/off. After writing in appropriate values in edit box we need to press the OK
button which will load these two values.

Department of ENC

Usha Mittal Institute of Technology


41

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

Motion plotted GUI and light status:


When RUN button is pressed the motion plotted image appears on the left side and
difference image on the on the right, corresponding status of the light is displayed on the
LIGHT STATUS edit boxes.

Figure 6.9 Motion plotted and light status

The additional buttons like STOP will stop the execution and close the GUI.
The EXIT button is used to exit and close all MATLAB windows.

Department of ENC

Usha Mittal Institute of Technology


42

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

CHAPTER 7

ADVANTAGES
Following are some advantages offered by the proposed solution over conventional systems:
A single sensor can function as a photosensor as well as an occupancy sensor.
A single sensor can be used for different task areas (or control zones) with different
target light level requirements, as long as the sensor has a view of all task areas. A
conventional system will typically need several photosensors for this purpose.
Compared to a conventional photosensor, the performance of the proposed system is far
less likely to be adversely affected by a direct view of a light source or direct sunlight.
The sensor is capable of detecting small movements, on the order of a couple of inches,
several feet away from the camera as long as it has an adequate resolution. The sensor
sensitivity to motion can be adjusted in real-time based on the activity level or other
criteria. As such, this approach can offer a better capability in occupancy detection
compared to conventional occupancy sensors.
Algorithms can be developed so that the problem of people or objects partially blocking
the sensors view of the task areas can be circumvented.
Real-time energy monitoring and performance analysis of the actual system is possible,
which is unique to this application.
CMOS Technology can provide an attractive and cost effective solution.

CHAPTER 8
Department of ENC

Usha Mittal Institute of Technology


43

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing

APPLICATIONS
Commercial and domestic buildings
Commercial buildings use air conditioning and increasingly use curtain wall design
with single glazing. Estimates show that between 30% to 50% of the spaces in these
buildings has access to daylight through windows and doors but these buildings
completely rely on artificial lightning with very less use of natural daylight. This problem
can be solved using daylight harvesting.
The system detects the daylight and human presence and switches on the lights as per
need. Thus, the regions where there is no need of artificial lights and where the natural
sunlight can be made use of, the system provides an efficient way of using natural energy.
This can be achieved using same cameras and pcs used for surveillance purpose.
This method overcomes several drawbacks of conventional sources used in daylight
harvesting and provides additional functionalities which are not achievable by these
sensors, thus significant amount of energy can be saved.

Traffic light control


Using the surveillance cameras installed to check the traffic; this algorithm can be
used to automatically control the traffic lights depending on the traffic density. Thus this
method provides an efficient way of controlling traffic.

CHAPTER 9

CONCLUSION
Department of ENC

Usha Mittal Institute of Technology


44

Integrated Daylight Harvesting And Human Detection Using Digital Image Processing
In our project we are able to control the lights of a room combining the daylight
estimation, occupancy detection and the lighting control algorithms. We are able to detect the
smallest change in the acquired image from the new image, which makes it very efficient.
Implementation of our project in commercial and domestic buildings will save a lot of
power, which otherwise is wasted because of the use of artificial lightings, thereby making
optimum use of the natural light from sun. Thus we are able to make use of the natural
sunlight rather than the artificial lights which is the main objective of our project, which
cannot be obtained using the conventional sensor methods. Thus this system can be helpful in
saving electricity and making the area energy efficient. In our project we control the lights in
the room, but other than controlling the lights we can also design it to control different
electrical appliances like fan, air conditioner etc. Due to its easy implementation and user
friendly GUI, we believe this project is a boon for the commercial as well as the domestic
buildings.
Specular reflection from daylight can cause the prototype to overestimate illuminance
in localized areas. To counter this, existing algorithm needs to be improved and a suitable
calibration and commissioning procedure must be outlined. Dark surfaces typically have low
luminance, thus signal-to noise ratio becomes an issue in estimating task illuminance on dark
surfaces.

Department of ENC

Usha Mittal Institute of Technology


45

Vous aimerez peut-être aussi