Video Monitoring based on Virtual Fence

DOI : 10.17577/IJERTV4IS110199

Download Full-Text PDF Cite this Publication

Text Only Version

Video Monitoring based on Virtual Fence

Xiaomin Wang

Department of Electronic Engineering Tianjin University of Technology and Education

Tianjin, China

Zhijun Pei

Department of Electronic Engineering Tianjin University of Technology and Education

Tianjin, China

Jiming Ren

Department of Electronic Engineering Tianjin University of Technology and Education

Tianjin, China

Wenwen Liu

Department of Electronic Engineering Tianjin University of Technology and Education

Tianjin, China

AbstractTraditional video monitoring is mainly operated by the personnel who adhere to view the video screen and determine abnormal behaviors, which consumes too much manpower, material resources and financial resources. The applications virtual fence and related technology in video monitoring can form an invisible "electronic fence", which employ video analysis and computer vision method to process and analysis video image sequence at real time. This technology based on "electronic fence" can monitor the scene of target and then detect, classify and tracking, which can effectively judge the suspicious behavior and unsafe factors by analyzing and forecasting. When there are those unexpected events, the system will promptly make alarm and corresponding process. For the monitoring system based on virtual fence, both the hardware platform and system software are provided in the paper. Furthermore, the applications and development of virtual fence related technology in video monitoring are also discussed.

KeywordsVideo monitoring; virtual fence; OpenCV;

lassification; target tracking


    In recent years, security problem has become one of the hottest topics with improvement of people's life quality. And the requirement of safety precautions has become more and more critical. Video monitoring system plays a major role in the field of security. Now video monitoring system has already been widely applied in various aspects of both production and life. But traditional video surveillance totally depended on artificial methods. Such monitoring systems require that person must watch the monitor screen for long term. Then after the understanding and judgment we get the appropriate conclusions and make corresponding decisions. However, it has been proved that after continuous monitoring for 20 minutes, humans attention will be seriously decline and the probability of finding abnormal behavior will be quite low[1][2]. Thus smart video analysis of becomes the core technology of the intelligent video surveillance.

    Intelligent video analysis fused the computer vision technology, correspondence technologies and pattern recognition. American started the intelligent video analysis research firstly. At present many countries such as the United States, Israel, France, Japan and other countries have emerged a series of excellent intelligent video monitoring solutions. Major Research institutions include the Microsoft Asia Research Institute, Massachusetts Institute of technology's

    Media Lab and its artificial intelligence laboratory, Carnegie Mellon University Institute for Human Computer Interface in the United States, national Institute of information and automation in French, the video monitoring research institutions Defense Advanced Research Projects Agency in America and the University of Reading in England. However, China does not have real intelligent video monitoring products with intellectual property at present[2][3]. It has been realized that the intelligent video monitoring market has a huge space, which results in the active study of relevant technology.

    A virtual fence technology is adopted in the intelligent video analysis in this paper. Virtual fence and related technology pull into a hidden "electronic fence" in the scope of the video monitoring. The "electronic fence" not only effectively realizes real-time monitoring and alarm within monitoring zone, but also analyses and detects objects behaviors automatically, then finding abnormal behaviors and potential threat. The applications can realize intelligent monitoring whole process and transfer passive monitoring into active identifying of safe. Video monitoring based on virtual fence can greatly save the manpower and material resources, as well as improve working efficiency and the performance of monitoring system. For the smart video monitoring based on virtual fence, both the hardware platform and system software are discussed in the details in the paper. And its applications in video monitoring are also given.


    Virtual fence technology delimits an alert area in the scope of the video monitoring in advance. Video monitoring based on virtual fence can analysis behaviors in real scenes intelligently. Video analysis and the computer vision video analysis are applied in virtual fence, which can achieve the target detection, classification and tracking, identification and tracking in the dynamic scene, dealing something in the process, timely finding evidence of the intelligent monitoring system. With virtual fence, video monitoring can realize the analysis and report of abnormal behaviors and unsafe factors to managers at real-time, thus it improves security of monitoring region greatly and solves the disadvantages of the traditional security system effectively strong protection for banks safe operation.

    The main technology of intelligent video analysis is target detection and now it has been widely used in the intelligent

    monitoring system. In this article target detection technology is chose to achieve virtual fence.

    At present target detection algorithm are the optical flow method, background subtraction techniques, inter-frame difference method and hybrid method four categories. This article mainly use inter-frame difference method and

    points change, we need to correct the corresponding background region so as to obtain more objective background image. means update rate, f(k) is for the k frame, Bk is for the k frame corresponding background image. If the (x,y) in the area of pixels, the algorithm expression is formula (5),else is formula (6).

    background difference method [7][8].

    B (x, y) B

    (x, y) (1) f (x, y

    Inter-frame difference method is mainly meant to video k



    segmentation, which means that first it segmented video into per frame, then make difference between the adjacent two

    Bk (x, y) Bk-1(x, y)


    frames or among a few frames in the video sequence. If the pixel gray-scale variation is greater than the threshold point, we can judge it as foreground; if pixel gray-scale variation is less than the threshold value, we judge it as background, so that we can detect the target contour[8] [10]. The basic testing process is shown in figure 1.




    Morphological filtering

    Connectivity analysis


    Differential operation


    Fig.1. Flow chart of target detection

    Firstly, make the difference between the k frames position pixel gray f (k) and the k-1 frames position pixel gray to get the difference image. Then through making threshold judgment on the difference image, we aim to distinguish foreground and background and obtain the binarization image Rk. If connect area is greatr than the given threshold, we will treat it as the goal by judging morphological filtering and connectivity analysis.


    This module includes hardware and software parts: This article mainly uses video server hardware and software open source image processing library OpenCV to design virtual fence and its related technologies. Front-end hardware collect and store video through high definition camera and video servers. Back-end software based on open source image processing library Open CV writing programs functions as the analysis processing of the real-time behavior in alert area video. By using computer vision, video analysis method and digital image processing technology, the purpose lies in analysis real-time video sequence or video file data intelligently obtained by video collection equipment instead of the human brain, so as to achieve real-time protection in alert area.

    1. Hardware platform

      The third generation of network digital video surveillance system was chosen to build hardware platform in the system. The hardware platform of the system can be carved up into three parts: Control center, IP data network and Control sub-

      Dk (x, y)

      fk (x, y) fk 1(x,


      center. System architecture is showed as figure 2.

      R (x, y) 0

      k 1

      Dk (x, y) T

      DK (x, y) T


      Background difference method is mainly to make the difference between current frame and the background image which does not include the goal to obtain the current frame in the target area so as to achieve the purpose of target detection. Through making the difference between the k frame f(k) and background image B, we can get difference image Dk , and subsequent processing process is similar to Inter-frame difference method[5][6].

      Dk (x, y)

      fk (x, y) B(x,


      R (x, y) 0

      k 1

      Dk (x, y) T

      DK (x, y) T


      Fig.2. System architecture of hardware platform

      In the process of the development we base on digital video

      Background modeling and updating is the key to background difference method. Due to illumination changes, moving objects in the background, background itself changes as well as the noise of image sensor equipment, it is very hard to obtain objective background accurately. In this paper we choose to use the adaptive background method whose basic idea is that: select a frame as the initial background, and distinguish the subsequent video frames pixels according to the pixel values changes. If the pixel values do not change, we need not correct its corresponding background, but if the pixel

      recorder, camera on collocation, make full use of the existing video server system to build a set of low cost and high compatibility of hardware platform. General working process is shown behind. Firstly the camera sends its video image information into the hard disk video recorder, through control table for video image processing and real-time monitoring, the effective information into the management server; Secondly, the deputy will be real-time IP data uploaded to the main switch form IP data network; Finally, the master console

      control allocates the sub-center, and through this, the digital decoder will point control center of the video information shown on TV wall, storing the real-time video data in total in the server.

    2. Software platform

    OpenCV is a basic open source Library of computer vision, pattern recognition and image processing. Open CV is a very good open source image processing library and the image processing tool of secondary development that can applied in many areas directly. The open source computer vision library Open CV consists of several libraries of C functions and C++ classes and it is used to realize the common image processing and computer vision algorithms. Virtual fence and related technology are based on image processing library OpenCV and C/C++ language on the Windows operating system.

    Virtual fence references a hidden "electronic fence" in the scope of the video base on the open source computer vision library OpenCV. Users can freely set virtual alarm line, alarm region and violation behaviors through rule setting interface[4]. The system will not only recording the enter numbers and enter time automatically but also reminding staff. Virtual fence are based on OpenCV and the program can be divided into the following four parts: Funtion.cpp instructions of interface; Virtual.cpp design of selected target; InitCamper.cpp initialization of digital video recorder; Motempl.cpp image processing for the selected areas.

    The function of Funtion.cpp is to select region-of-interest (ROI) manually. The ROIs position and size can change as users requirement. The Funtion.cpp program is a branch function for the main program calling and this can make the virtual fence program both simple and clear.

    The program of Virtual.cpp can be divided into four steps. Step one: The definition of mouse callback function; Step 2: Test the definition of object size progress bar callback function; Step 3: Writing real-time image into digital video recorder; Step four: Selecting and changing of ROI, then judging whether the program is starting work (whether ROI region is on photo processing).

    The main function of InitCamper.cpp is not only making sure digital video recorder working normally in a new environment but also solving some possible connection error, returning an error code in order to solving the problem at the first time.

    Motempl.cpp is the core part of virtual fence and the hardcore of realizing moving object detection. First extract the video every frame; then differential the two adjacent frames and make the different image binaryzation. Calculating the global movement direction of ROI area; Control frame differential disappearing rate to ensure the positioning of objects accurately; Compute gradient direction of the moving object and in the right direction mask; Divide the whole movement into separate parts. Mark the moving object marked by circle in the original image ROI area and in the binarization image ROI area, through the image contrast we can get better effect.

  4. RESULTS AND DISCUSSIONS OF EXPERIMENT Virtual fence effect is shown in figure 3.

    Fig.3. Experiment result of virtual fence

    It can be seen from the results of the experiment that when there are objects or people getting into the protection zones (ROI) and touching the virtual fence the system will pops up the protection zones (ROI) of the original image and binary image and the program will display the time and the number of objects into the alert area. The technology can be applied in video monitoring effectively. It can realize intelligent monitoring and improve the monitoring effectively. From what have been said above we can see the advantages of virtual fence and related technology research in video monitoring is so obvious we believe that it will be applied in video monitoring system soon.

    The designed video monitoring system based on virtual fence has the following functions.

    1. Flow monitoring: It can detect the flow of people and traffic in the alert area automatically, and the statistics will be displayed in management terminal. Flow monitoring can be applied to count the flow of people in the cinema, stadiums, and other places, as well as the flow of vehicle in the parking lot and road.

    2. Mobile path monitoring: It sets a certain area as an alert area, when people or some other objects appear in this area, the system will record their track and inform the managers. This can be used to track getaway cars and people.

    3. The sudden monitoring of objects: When the objects appear in the alert area, the system will give warning, and inform the managers. The sudden monitoring of objects can be employed in museum, house and some other important areas.

    4. Strnded monitoring of objects: When the objects appear in the alert area and its retention time is longer than users have set (such as 1 min), the system will give a warning and inform managers. This system can be used to monitor judgment and illegal parking.

    5. Wandering monitoring of objects: When the objects or people wandering in the alert area and the time is too often (more than the user-defined number), the system will give warning and inform the owners or managers. This system can be use to monitor suspicious behavior in important areas.

    6. Move monitoring of objects: When the objects in the alert area is removed or replaced, the system will give warning

      and notify the relevant personnel. This system can be used as anti-theft in museum.

    7. The monitoring of movement objects speed: Objects moving speed in alert area can be showed in the terminal management interface. The system can be used to monitor vehicles speed.

    8. The directional movement monitoring of object mobile: The system can be set to monitor a certain direction in the alert area, and whenever the object moves into the alert area from this certain direction, the system will warn the police. This system can be used to monitor cars on the road which run in the wrong direction and the illegal invaders.


    The advantages and characteristics of virtual fence in video monitoring are as follows.

    1. Virtual fence and related technology in video monitoring can automatically detect the video images of moving behaviors characteristics and it can test and analyze the moving objects of different characteristics in the same scene;

    2. High concealment: set up a virtual barrier, confuse the invaders, and reduce the intruders decency awareness;

    3. Strong flexibility: Virtual fence as a protective barrier can draw and eliminate at any time, virtual barriers can changed in location and size with the change of the protection zone;

    4. Provide greater detecting range, higher detecting rate and lower false alarming rate;

    5. Alarming video network storage can store alarming video images in the alarming video severing for search and playback later;

    The advantages and characteristics in video monitoring based on virtual fence are so obvious that it can be used in the following areas.

    1. Invasion and asset protection in military stronghold, bank, museums and other places;

    2. Intrusion behavior in water field, electricity field, gas field, oil field, nuclear power plants and other key parts;

    3. Legacy suspicious packages in airport, station, water works and so on;

    4. Through intelligent transportation system can judge traffic violation behavior, retrograde, turning around and illegal steering;

    5. Through virtual fence and related technology in video monitoring tunnel, highway and railway can prevent the offender into.


Video monitoring based on virtual fence can make the intelligent video surveillance, realizing remote video monitoring and multi-dimensional intelligent video analysis. It is good for the improvement of the security system and implement effective monitoring of important areas. Objects and people's behavior within the scope of monitoring is analyzed, and it warns the behavior of the suspicious target and unsafe factors. It links relevant systems, and it prompts the managers to prevent and handle in time.

Compared with the traditional security, this system reduces the number of security personnel and gets a better result easily. Application in the field of security is worth looking forward to and can produce significant economic benefits. In practical application, the target might be covered by other objects, and it need to be able to fit in the rain, snow, wind, thunder, low light, shadows, and other weather conditions. Even though in the normal environment and the branches swaying, flags fluttering, wave ups and downs, illumination changes, and many other interference factors are likely to make the technical analysis be error, we will further improve the algorithm of using virtual fence for modification.


This work is supported by Research Foundation of Tianjin University of Technology and Education under Grant No. KJY1312.


  1. Han Guodong, Research on video monitoring system based on intelligent,computer science and network technology (ICCSNT), 2011.

  2. Xie Zhidong, Design and implementation of multimedia information processing and wireless transmission system based intelligent video analysis,2013.03.01.

  3. Li Ying,Design and implement of target extraction algorithm in new intelligent video analysis system,2010.04.01.

  4. Collins R T, Lipton A J, Kanade T, Introduction to the special section on video surveillance. IEEE Trans Pattern Analysis and Machine Intelligence,2000.

  5. Yang Peng,The research on the application of target tracking technology in intelligent video surveillance system. 2014-03-18.

  6. Li Jie, Research and application of intelligent video surveillance system.2012.

  7. ZHANG Li-ming, LlU Bao-cheng, TANG Qing-hua, WU Li-ping,The Development and Technological Research of Intelligent Electrical Building,China International Conference on Electricity Distribution (CICED 2014).

  8. Liu Quan, Qu Xuehong, Zhou Henglin and Long Yihong,Research on Remote video Monitoring system used for Numerical Control Machine Tools Based on Embedded Technology, Journal of Wuhan University of Technology.2006.

  9. He Na and Zhang Pengpeng,Detecting and tracking research in video surveillance system, Microcomputer Information, 2010.

  10. Maybank S, Tan T, Introduction-special Section on Visual Surveillance,International Journal of Computer Vision,2000.

  11. Wu Yonghao, Hua Yunsong and Shang Liang, Research and design of motion target tracking system based on the OpenCV, Electoronic Test, Aug.2010.

Leave a Reply