Lightning Detector Design Competition
閃電探測器設計比賽

Workshop on "Scene Analysis Using Webcam"
「網絡相機影像分析」工作坊

Dr. YIP Chi Lap [Beta], Department of Computer Science, Faculty of Engineering, The University of Hong Kong

香港大學 工程學院 計算機科學系 葉志立博士

Content last modified 內容更新日期 2012-11-24

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Hong Kong License.

此講義之版權為香港適用的共享創意授權條款 CC BY-NC-ND 3.0

Software development environment
軟件開發環境

The environment we use in this workshop is Processing, a programming environment for manipulating images, animations, and interactions. It is cross-platform and can run on the OS X, Windows, and Linux. It integrates with the programming languages Java and JavaScript, and can be deployed as Java applications, on the web with HTML5 and WebGL support, or as Android applications.

Those interested in using the techniques covered in this workshop can visit its web site to download Processing as well as to go through its Learning section for tutorials and demos.

本工作坊所採用的軟件開發環境為Processing。 它是個跨平台的軟件開發環境,可在OS X,Windows,和Linux運行,用作處理圖像,動畫和人機互動設計。 它利用Java和JavaScript的編程語言,可產生出獨立運作的Java應用程式、在支緩HTML5和WebGL的瀏覽器上使用的網頁、或Android應用程式。

對此工作坊內容有興趣的話,可到它的網站下載該軟件及在其Learning頁看教程和示範。

Introduction
概論

When there is lightning, there is a strong flash of light. If we can detect the light flash by a web cam, we could be able to detect lightning. While we'd like to leave the details of implementation to you, in this workshop, we will demonstrate how to capture video frames using a web camera, and show a number of techniques for analysing scenes on movies. We hope that the basics introduced could be useful for those interested in analysing video scenes for lightning detection.

Besides the basics offered in the Processing web site, there are examples in the "Java Examples" section. Those under the "video" folder are particularly relevant; those under "Capture" folder are related to capturing and processing data using web cam, and those under "Movie" folder are about extraction and processing of pre-recorded movies.

閃電產生强光。如我們能檢測這强光,或可測到閃電。 在這工作坊裏,我們會示範如何頡取網絡相機的影像,與及介紹一些利用影像探測突如其來的强光的方法。 具體地如何利用影像去探測閃電,就要靠你們的努力和創意了。

除了Processing的網站外,Processing的"File > Examples..."選單內也有程式範例。 其中,"video"資料夾內的"Capture"資料夾及"Movie"資料夾的內容特別相關。前者關於頡取及處理網絡相機的影像,而後者是關於頡取錄像的方法。

Brief descriptions of the sample code
示範源碼之簡要說明

Comments in the source code gives explanations to features illustrated in the code.

源碼內的註釋解釋該源碼所示範的功能。

Basics01
The smallest functional Processing program.
最小而有用的Processing程式。
Basics02
The use of println().
如何使用println()。
Basics03
size() and background().
size() 和 background().
Basics04
Coloured background and text().
有色的背景和text()的運用。
Basics05
for loop.
for 廻環。
Basics06
Global variable and textSize().
變數和textSize().
Basics07
Array and loops.
陣列和廻環。
Basics08
More array and loops.
更多的陣列和廻環。
Movie01
Basic movie playing.
基本播放影片的方法。
Movie02
Resizing movie for display.
改變播放影片的大小。
Movie03
Automatic determination of display window size to fit the movie.
改變視窗大小至影片大小。
Movie04
Determining the frame rate and total number of frames using movie duration.
利用影片長度計算其播放速率和總幀數。
Movie05
Use frame differencing to find out what has changed.
利用幀差來計算影片內容轉變。
Capture01
Basic use of the Capture class. The program just displays whatever is captured on the screen.
Capture class的使用。程式只將從網絡相機頡取的東西顯示出來。
Capture02
Use of captureEvent() for reading frames.
利用captureEvent()來頡取影片的話影像。
Capture03
Illustrates the use of set() function.
演示如何使用set()函數。
Capture04
Illustrates the use of pixels[] array for display image and Capture object.
演示使用pixels[]陣列來顯示影像和Capture所代表的畫面。