You are on page 1of 4

The 9th International Conference on

Computer Science & Education (ICCSE 2014)


August 22-24, 2014. Vancouver, Canada.

SaP11.6

Implementation of a Laboratory Video Monitoring


System
Ye Jihua, Nie Xiaoshi

Computer and Information Engineering College, Jiangxi Normal University


Nanchang, China
yjhwcl@163.com

long-running

the server is started to store and transmit the monitoring

experiments, Laboratory sometimes is in a state of unattended.

terminal over the video captured by the camera processed by

In order to grasp the lab environmental condition in time, a

the streaming media server. Consequently, the user can

S3C241O

monitor the video. As shown in Figure 1. Storage and

Abstract-With

laboratory

video

the

emergence

surveillance

of

system

various

based

on

processor is developed and implementd in this paper.

The

transport

composition of the video surveillance equipment hardware is the

WED
emhedded
server
side

Stream
media
server

Monitor
client

USB camera, streaming media server and WEB servers. USB


camera is used as a data collection terminal. The transmission of
collection data is through the network to the background, the

Fig.l. System Architecture Module

user at the remote can monitor USB camera to capture the


real-time

video.

Therefore,

this

can

realize

the

III.

effective

MONITORING TERMINAL MODULE


IMPLEMENTATION

monitoring for the lab.

A. Camera Module Analysis

Kwords-USB camera, embedded, S3C241O, WEB server

I.INTRODUCTION

The device of monitoring terminal

IS

mainly Vimicro

camera. USB Vimicro camera which

IS

connected with

In today's life, there are many places with real-time video

development board via USB is responsible for collecting the

surveillance security systems, such as residential, shopping

video data, and then for processing. The execution flow is

malls. These systems are monitored to prevent emergency

shown in Figure 2.

situations in order to bring up the video for comparison and


analysis. Based on S3C2410 processor [2], we develop a
laboratory monitoring system and complete the system test.
System development mainly includes front-end equipment,
signal transmission and background control three parts. The
paper describes the implementation process of the system.
II. THE SYSTEM ARCHITECTURE
The video surveillance system implemented in this paper
is made up of video monitoring terminal, media server and
WEB server. Users log in video monitoring sites through the
browser, making video monitoring requests to the embedded
WEB server [4]. Then programs interact with embedded WEB
server through the CGI. After the server receiving a request,

978-1-4799-2951-1/14/$31.00 2014 IEEE

1028

Fig.2. Camera module workflow

SaP11.6

B.

depth, pal, palette, width,height.

Device Driver Module

II Open the video device

The device drivers Under Linux [1] can be compiled in


two ways, one is directly translated into a static part of the

if ((vd->fd = open(fileptr, O_RDWR))

kernel, the other is compiled into dynamically loaded modules.

If it's compiled into the kernel, it will increase the size of the

perror("v41_open:");

kernel, also changes the kernel source files, and cannot be

return ERR_VIDEO_OPEN;

<

0)

dynamically unloaded, which is not conducive to debug.

Dynamically loaded drivers which exists in module way can

II Get the device

be loaded when we needed, and can uninstall after the task

if (ioctl(vd->fd, VIDIOCGCAP, &(vd->capability)) < 0)

completed. Our system adopts the second way.


C.

perror("v41_get_capability:");

The Specific Implementation ofMonitoring Terminal

return ERR_VIDEO_GCAP;

Module
}

Monitoring module is mainly the realization of Usb

II Get the picture

camera driver. Device driver [1] plays a special role in linux

if (ioctl(vd->fd, VIDIOCGPICT, &(vd->picture)) < 0)

kernel [3]. Just like each separate "black box", they make a
specific

hardware

in

response

well-defined

internal

perror("v41_geticture");

programming interfaces. The user's operation carried out

return ERR_VIDEO_GPIC;

mainly through a set of standardized calls to call these


}

independent and specific drivers. These calls are mapped to

II setting the picture

the role of the actual hardware device-specific operations,

vd->picture.palette = pal;

which is the task of the device driver [1]. The programming

II palette

interface permits the driver independently of the rest of the

vd->picture.depth = dep;

kernel and then the driver can be established. The specific

II pixel depth

process is shown in Figure 3.

vd->mmap.format =pal;
if (ioctl(vd->fd, VIDIOCSPICT, &(vd->picture)) < 0)

perror("v41_setalette");
return ERR_VIDEO_SPIC;
}
IV.

THE ANALYSIS OF EMBEDDED STREAMING


MEDIA SERVER MODULE

Ie lhel' tu Lel'wlua Le
Tile vi deo raptllre

Apart from video capture module described previously,


streaming media server mainly includes video encoding
module and video transmission module. The design of
streaming media server is shown in Figure 4.

Fig.3.

Video Capture Process

The main code is as follows:


int open_video( char *fiIeptr,tb_v41 *vd ,int dep,int
pal,int width,int height) *vd, Parameters Pointer, dep, pixel

1029

SaP11.6

devices to generate dynamic pages, the client can manage and


monitor for embedded devices only through a Web browser.
That is very convenient and practical.
This section describes the development and porting work
for this application. Users need successfully transplant
support scripts or Web server with CGI functions on
embedded device at first. And then application development
can proceed.
This system employs the Boa server as a WEB server [2].
Boa is a very tiny Web server, whose executable code is only
about 60KB. It is a single task Web server, which can only
finish the user's request, in tum, will not fork out a new
process to handle concurrent connection requests. [4]. But
Boa supports CGI, CGI programs is able to fork out a process

Fig.4. the streaming server module

to execute. The design goal of Boa is speed and security.


A. Video Encoding Module

Embedded Web Server [4] Boa responds differently

The video transmission in this paper employs a MIPEG

according to request method.

video coding method. That is to take each frame as a separate

If the request method was HEAD, then return directly to

and static picture to do JPEG compression, and then

the browser response headers; If the request method is GET,

re-encoding in sequence. The system adopts MPEG-4 video

at the same time of returning a response headers, read the

encoder for video image compression encoding. Codes realize

client request the URL of the target file from the server, and

the video encoding.

send to the client browser;

B.

While if the request method is POST, transmit form

Transmission Module
The system adopts RTP I RTCP [4] protocol for real-time

transmission of video streams. RTCP provides flow control


and congestion control services together with RTP. During the
RTP session, each participant periodically sends RTCP
packets. RTCP[4] packet contains the number of sent packets,
the number of lost packets and other statistics. Hence, the
server can dynamically change the transmission rate over this
information, and even change the payload type. RTP together
with RTCP, can make transmission efficiency optimization by
effective feedback and minimal overhead, which is especially
suitable for real-time data transmission on the network.

information sent by clients to the corresponding CGI


programs, as the parameter of CGI to execute CGI program,
and send the results to the client browser. The function
realization of Boa is through the establishment of the
connection, bind port, listens, request processing, etc. Its
initialization part of the source code is as follows:
int server_s;
server s
socket( SERVER]F,SOCK_STREAM,IPPROTO_
if( server_s

==

- 1)

{
DIE( unable to create socket) ;

V. THE REALIZATION OF THE EMBEDDED WEB

SERVER

if( set_nonblockJd( server_s)

With the rise of Internet technology, in the embedded

==

- I)

{ DIE( unable to set server socket to nonblocking) ;

equipment management and interaction, the applications

based on Web become the mainstream. The program structure

if( fcntl( server_ s,F _SETFD, I)

is also a very familiar BIS structure [4], which runs a support

{DIE ( can't set close! on! exec on server socket! ) ;

scripting or a Web server with CGI function on embedded

1030

==

- I)

SaP11.6

if(

setsockopt(

server_s,

I. -

SOL_SOCKET,SO_REUSEADDR,( void*)&sock_opt,

dit

"

sizeof( sock_opt) ) )

==

- I)

Tools

Hlp

'"

Lodi.ng ...

{ D1E( setsockopt) ;
if( bind_server( server_s, serverjp, server_port)

==

- 1)

{ D1E( unable to bind) ;


if( listen( server_s, backlog)

==

- 1)

{ DIE( unable to listen) ;


The code above is mainly used to open a valid socket

Fig.5. Real time picture monitoring in server

descriptor, and then converts it to a non-blocking socket.


VII.

Function bind 0 is used to establish a socket descriptor and

CONCLUSION

the correlation with the specified port, and monitor in the

The advantage of this system is a low development cost

specified port through the function listen 0, waiting for the

possessing, small size, low power consumption, convenient to

remote connection request. When listen the connection

use, extensible function, used in various fields such as schools,

request, the called function Boa getJequest (int server_sock)

home and banks, and with good market prospects.

acquire the request information, establishing a connection for


ACKNOWLEDGMENT

the request by the calling function accept O. After the


connection is established, the request information is received,

This work was supported by the Nation Natural Science

and make analysis of the request. When there is a CGI request,

Foundation of China (NSFC) under Grant No.61262036 and

create a process for the CGI program, and send out the results

the Research Plan of department of education of Jiangxi

through the pipeline.

Province (GJ113228) and the Research Plan of Research

VI.

center of distribution calculation engineering technology of

SYSTEM TEST REALIZATION

Jiangxi Province(Normal University).

Using the camera to capture lab's video, video monitoring,


REFERENCE

enter the IP address in the browser, and enter the login


interface, the user can enter the video monitoring interface.

[1] Jonathan

Corbet,Alessandro

Kroah-Hartman

Figure 4, Figure 5.

Rubini

LINUX DEVICE

&

DRIVERS

Greg
Third

Edition[M]. O'REILL Y 2006.01


[2] Dongshan W. Embedded Linux application development
completely

manual[J].

the

People's

Posts

and

Telecommunications Press, September, 12th printing,


2008, 20. pp. 384-492.
[3] Shijiang Wang. Bird Brother linux private kitchens.3rd
edition[M] July 1, 2010.pp.749-774
[4] Xiren Xie. Computer Network 5rd[M].Jan.1O 2008

Fig.4. Real-time video capture on the screen

1031

You might also like