• 沒有找到結果。

[2015-Fall] WNFA lab1 - CamCom

N/A
N/A
Protected

Academic year: 2022

Share "[2015-Fall] WNFA lab1 - CamCom"

Copied!
38
0
0

加載中.... (立即查看全文)

全文

(1)

Mobile and Vehicular Network Lab

[2015-Fall] WNFA lab1 - CamCom

Camera Communication Hsin-I,Wu

2015/3/13

(2)

Mobile and Vehicular Network Lab

INTRODUCTION

(3)

Mobile and Vehicular Network Lab

VLC

• Visible Light Communication

(4)

Mobile and Vehicular Network Lab

Hw1 intro

(5)

Mobile and Vehicular Network Lab

TRANSMITTER

(6)

Mobile and Vehicular Network Lab

Tx-hardware

• Zigduino x2 →

http://goo.gl/TjM2uQ

• LEDs x2

• Resistors 250Ω x6

• 麵包版 + 線 x1

(7)

Mobile and Vehicular Network Lab

Tx-hardware

Notice : there must be resistors ( 電阻 ) in the circuit

(8)

Mobile and Vehicular Network Lab

Tx

• message → bytes → behavior of LEDs

• You can use anything to represent bits:

– color, frequency, luminance, waveform, dup lication, ……

– Don’t forget the low sampling rate of cam era (30fps)

• Get extra score if people cannot notice the behavior of LEDs

• Range your score with data rate

(9)

Mobile and Vehicular Network Lab

Tx-Zigduino

• Delay()

int ledPin = 13;       // LED connected to digital pin 13 void setup()

{

  pinMode(ledPin, OUTPUT);      // sets the digital pin as output }

void loop() {

  digitalWrite(ledPin, HIGH);   // sets the LED on   delay(1000);      // waits for a second   digitalWrite(ledPin, LOW);    // sets the LED of   delay(1000);      // waits for a second }

(10)

Mobile and Vehicular Network Lab

Tx-Zigduino

• CTC mode

– Clear Timer on Compare (timer == OCRnA) – Generate accurate square waves

• all done by hardware, won’t affected by inte rrupt

• Can simultaneously use all 3 timers easily.

(11)

Mobile and Vehicular Network Lab

Tx-Zigduino

• CTC mode

– Set the corresponding bits in TCCRnX(n=1,2,3 X=A,B) re gisters for mode selection and timer prescaler

– Set OCRnX for “frequency”(OCRnA) or “delay”(OCRnB, OCRnC)

– Frequency = 16M / prescaler / OCRnA / 2

– Additional support : interrupt handler (see document)

(12)

Mobile and Vehicular Network Lab

Tx-Zigduino

• CTC mode

void setup() {

// use Timer1, set control registers here pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(3, OUTPUT);

TCCR3A = _BV(COM3A0) | _BV(COM3B0) | _BV(COM3C0);

TCCR3B = _BV(WGM32) | _BV(CS32) | _BV(CS30);

OCR3A = 32767;

OCR3B = 16383;

OCR3C = 8191;

}

void loop(){

// change OCRnX values to manipulate frequency OCR3A = 32767, OCR3B = 16383, OCR3C = 8191;

delay(10000); // this may not be so accurate OCR3A = 16383,OCR3B = 8191,OCR3C = 4095;

delay(10000);

}

(13)

Mobile and Vehicular Network Lab

Tx-Zigduino

(14)

Mobile and Vehicular Network Lab

Tx-Zigduino

• CSnX

– n:timer n

– X: 所需的值轉成 2 進制,所對應的第 X 位為 1

• 1/8/64/256/1024

→1/2/3/4/5→0001/0010/0011/0100/0101

• Ex. timer 3 →n=3→CS3X

prescaler=1024→5→0101→ 第 2 位和第 0 位為 1

→_BV(CS32) | _BV(CS30)

(15)

Mobile and Vehicular Network Lab

Tx-Zigduino

• CTC mode

– For more details

– https://strawberry-linux.com/pub/doc8266.

pdf – https

://static.squarespace.com/static/511f4f0d

e4b09463c7605f13/t/5275c478e4b07e72f74c74

42/1383449720133/zigduino-v6c-schematic.p

df

(16)

Mobile and Vehicular Network Lab

Tx-frequency

stripes to get freq.

(17)

Mobile and Vehicular Network Lab

Rolling Shutter

• Global Shutter VS. Rolling Shutter

– A GLOBAL SHUTTER exposes the entire image

r simultaneously.

(18)

Mobile and Vehicular Network Lab

Rolling Shutter

• Global Shutter VS. Rolling Shutter

– The rolling shutter actually exposes diff

erent portions of the frame at different

points in time, “rolling” through the f

rame.

(19)

Mobile and Vehicular Network Lab

Rolling Shutter

(20)

Mobile and Vehicular Network Lab

Tx-luminance

• Fast PWM (with OCRnA top)

– Pulse-width modulation

– Can be used to control duty cycle

– http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM( pins are dif ferent )

– Differences in luminance and ratio of light/dark stripe width

pinMode(6, OUTPUT);

TCCR3A = _BV(COM3B1) | _BV(WGM31) | _BV(WGM30);

TCCR3B = _BV(WGM32) | _BV(WGM33) | _BV(CS32)

| _BV(CS30);

OCR3A = 8191;

OCR3B = 2047; // 25% duty cycle

(21)

Mobile and Vehicular Network Lab

Tx-color

• RGB

• HSV

(22)

Mobile and Vehicular Network Lab

RECEIVER

(23)

Mobile and Vehicular Network Lab

Rx-hardware

• Camera of your smart phone

Notice: 每支手機的相機 fps 不一定都是 30

(24)

Mobile and Vehicular Network Lab

Rx

• video ( → image ) → get LEDs behavior→

bytes → message

• Video to image:

– ffmpeg –i input.avi ouput%d.jpg

(supported by windows, linux, and OS X)

• Counting Stripes : need some DIP

– find LED position, image diff, color histogram , edge detection, Fourier transform, auto-corr elation, ……

• 3 basic ways : DIP, FFT, auto-correlation

(25)

Mobile and Vehicular Network Lab

Rx-an example pseudo code

• for all images

{

read image;

find bounding box // where are the stripes calculate row power

count stripes to get freq. // through DIP or FF T

get output bit by freq.

}

(26)

Mobile and Vehicular Network Lab

GRADE

(27)

Mobile and Vehicular Network Lab

Grade

• Deadline:4/2(Thur.) 23:59 email to wn@csie.ntu.edu.tw

– Email subject:[WN]lab1_teamXX – [WN]lab1_teamXX.zip

• source code(tx + rx)

• Report(.pdf)

• Demo-4/9(Thur.)

– Please register the demo slot. And come to CSIE R424 at that time.

http://goo.gl/YyM8QF – All you should do are :

• 1. Transmit the character string given by TA

• 2. Record the videos

• 3. Decode and get the message

• Grade

– Tx (20% + 10% for not noticed by human eyes + 10% data rate) – Rx : Video Decode (20% + 10% for accuracy)

– Report : describe what team members have done(in detail), and probl ems encountered (20%)

– Bonus: real time... (5%)

(28)

Mobile and Vehicular Network Lab

特別評分機制

• 90% Lab 團體成績 ( 由各個作業負責的助教決 定 )

• 10% 小組互評成績

– 匿名

– 給分範圍為 -2.5 ~ 2.5

– 給分總和需等於 0 (ex 0.25/0.25/-0.25/-0.25)

• 目的

– Report 上的工作分配有時無法準確的表達各個組員

各自的想法,因此添加此機制作參考

(29)

Mobile and Vehicular Network Lab

• 情境 1 : 大家都認為彼此付出一樣心力

– 大家彼此都給 0 分,此組員成績 = Lab 團

體成績

• 情境 2 : 1 個 Free Rider

– 大家都給 -2.5 ,共得 -10 ,此人成績 = Lab 團體成績 – 10

– 大家都給救火者 2.5 ,共得 10 ,此人成績 =

Lab 團體成績 + 10

(30)

Mobile and Vehicular Network Lab

• 假設 A 組全組認真參與; B 組存在 Free Rider(s)

• A 組在此機制下最高得分只有 90 % ,然而 B 組最高 分數卻較高 90% + 10% ,是否不公平?

– A 組最高分確實只有 90 % ,然而學期末總成績將依據常態分 佈給分,所以總分高低不是重點

– 課程安排上作業傾向需要五人團隊合作,理論上 B 組的 Lab 表現會較 A 組差,因而得到較低的 Lab 團體成績,即使加 上互評成績不見得會拿到較 A 組高的分數

– 假若 B 組救火者有能力將 Lab 表現得與 A 組相當甚至更

佳,那麼最後因為最高分數較高而得到較 A 組佳的成績是實

至名歸

(31)

Mobile and Vehicular Network Lab

• Contact to TAs :

– facebook https://www.facebook.com/groups/

wn15spring/

– Email : wn@csie.ntu.edu.tw

– Office hour : Thur. 16:00~17:00@ CSIE R42

4

(32)

Mobile and Vehicular Network Lab

APPENDIX

(33)

Mobile and Vehicular Network Lab

Zigduino

• First program – Blink.ino

(34)

Mobile and Vehicular Network Lab

Zigduino

COMx Zigduino

(35)

Mobile and Vehicular Network Lab

Zigduino

• serial port monitor – text I/O

– see Examples 08. Strings

– Use the serial monitor to communicate

(36)

Mobile and Vehicular Network Lab

ffmpeg

Ffmpeg.exe

video

(37)

Mobile and Vehicular Network Lab

ffmpeg

參考文獻

相關文件

In order to facilitate the schools using integrated or mixed mode of curriculum organization to adopt the modules of Life and Society (S1-3) for improving their

In this talk, we introduce a general iterative scheme for finding a common element of the set of solutions of variational inequality problem for an inverse-strongly monotone mapping

• Supports program binaries compiled for a different instruction set than the. host hardware 

* School Survey 2017.. 1) Separate examination papers for the compulsory part of the two strands, with common questions set in Papers 1A & 1B for the common topics in

a) Describe the changing trend of daily patronage of different types of public transport modes in Hong Kong from 2000 to 2015.. b) Discuss the possible reasons leading to

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005..

 Presents a metric selection framew ork for online anomaly detection i n utility cloud.. ◦ Select most essential metrics by appl ying metric selection and

Given a graph and a set of p sources, the problem of finding the minimum routing cost spanning tree (MRCT) is NP-hard for any constant p > 1 [9].. When p = 1, i.e., there is only