csct1x - Eyetap.org

pucefakeAI and Robotics

Nov 30, 2013 (3 years and 10 months ago)

142 views

CSC320


Visual Computing

Tutorial # 1


TA: Raymond
Lo

1

About Me



Raymond Lo



Email:
raymond.lo@utoronto.ca



2009 to Present


Ph.D. candidate in Computer Engineering


Supervisor:

Prof. Steve Mann



2007
-
2009


M.A.Sc
. in Computer Engineering


Supervisor:
Prof. Steve Mann


Thesis:

CyborGlogger
: A Computational Framework for Real
-
time
CyborGlogging




2002
-
2007


B.S. in Computer Science


Specialist in Software Engineering and Minor in Mathematics

2

About Me



Research Interests:


Mobile and Wearable Computing


Lifelong Experience capture


Cyborglogging

(
www.glogger.mobi
)


Augmented and Mediated Reality


GPGPU [even on mobile platform (
Tegra

2)]


Blind
-
navigation with Microsoft
Kinect



3

About Me

4


Real
-
time HDR Video for extreme dynamic scene (help us
to see better?)



Our wearable setup


About Me (3)


Course I have taken (highly recommended!):



CSC320H


Intro Visual Computing



A


CSC487H


Computational Vision


A
-


CSC418H


Computer Graphics


A+


ECE516H


Intelligence Image Processing



A+



CSC2539H


Dynamic Scene Analysis




B+


CSC2530H


Visual Modeling





A
-




CSC2523H


Object Modeling & Recognition



A



CSC2521H


Computer Graphics




A


ECE1724H


Programming Massively Parallel GPU

A+


ECE1747H


Parallel Programming




A+



CSC2526H


HCI Topic: Ubiquitous Computing

A+


ECE1774H


Sensory Cybernetics




A
-



CSC2514H


Human Computer Interaction



A




5

FLUID Walkthrough

6


The tutorial on the FLUID website is “badly” written


Common Questions:


Why my cube won’t translate, rotate, or zoom?


Ans
: Callback functions are missing?


Why I cannot compile? “reference undefined: xxx etc”?


Ans
: Did you name your variables properly? Class name
vs

Variable
name?


Why nothing shows up on the windows screen?


Ans
: Did you resize the buttons, the slider etc after you added them?


etc etc...


Workflow

7


fluid
CubeViewUI.fl

(use the GUI to add windows,
buttons, etc...)


fluid

c

CubeViewUI.fl

(generate .
cxx
, .
h

files)


make (link all files together and create the executable)


./
CubeView

(execute)

FLUID DEMO


8


Here is how the
CubeViewUI.cxx

shall look like.


CubeViewUI.cxx

9


// generated by Fast Light User Interface Designer (fluid) version 1.0100



#include
"
CubeViewUI.h
"



inline

void

CubeViewUI::cb_vrot_i(Fl_Roller
*
o
,
void
*) {



cube
-
>
v_angle(((Fl_Roller

*)
o
)
-
>value());


cube
-
>redraw();


}


void

CubeViewUI::cb_vrot(Fl_Roller
*
o
,
void
*
v
) {



((
CubeViewUI
*)(
o
-
>parent()
-
>parent()
-
>parent()
-
>
user_data
()))
-
>
cb_vrot_i(o,v
);


}



inline

void

CubeViewUI::cb_ypan_i(Fl_Slider
*
o
,
void
*) {



cube
-
>
pany(((Fl_Slider

*)
o
)
-
>value());


cube
-
>redraw();


}


void

CubeViewUI::cb_ypan(Fl_Slider
*
o
,
void
*
v
) {



((
CubeViewUI
*)(
o
-
>parent()
-
>parent()
-
>parent()
-
>
user_data
()))
-
>
cb_ypan_i(o,v
);


}



inline

void

CubeViewUI::cb_hrot_i(Fl_Roller
*
o
,
void
*) {

 cube->h_angle(((Fl_Roller *)o)->value());

cube
-
>redraw();


}


void

CubeViewUI::cb_hrot(Fl_Roller
*
o
,
void
*
v
) {



((
CubeViewUI
*)(
o
-
>parent()
-
>parent()
-
>parent()
-
>
user_data
()))
-
>
cb_hrot_i(o,v
);


}



inline

void

CubeViewUI::cb_xspan_i(Fl_Slider
*
o
,
void
*) {



cube
-
>
panx(((Fl_Slider

*)
o
)
-
>value());


cube
-
>redraw();


}


void

CubeViewUI::cb_xspan(Fl_Slider
*
o
,
void
*
v
) {



((
CubeViewUI
*)(
o
-
>parent()
-
>parent()
-
>parent()
-
>
user_data
()))
-
>
cb_xspan_i(o,v
);


}



inline

void

CubeViewUI::cb_zoom_i(Fl_Value_Slider
*
o
,
void
*) {



cube
-
>size=(((
Fl_Value_Slider

*)
o
)
-
>value());


cube
-
>redraw();


}


void

CubeViewUI::cb_zoom(Fl_Value_Slider
*
o
,
void
*
v
) {



((
CubeViewUI
*)(
o
-
>parent()
-
>parent()
-
>
user_data
()))
-
>
cb_zoom_i(o,v
);


}



CubeViewUI::CubeViewUI
() {



Fl_Window
*
w
;



{
Fl_Window
*
o

=
mainWindow

=
new

Fl_Window(
440
,
390
);



w

=
o
;



o
-
>
user_data((
void
*)(
this
));



{
Fl_Group
*
o

=
new

Fl_Group(
0
,
-
20
,
455
,
415
);



{
Fl_Group
*
o

=
VChange

=
new

Fl_Group(
0
,
75
,
40
,
220
);



{
Fl_Roller
*
o

=
vrot

=
new

Fl_Roller(
0
,
75
,
20
,
220
);



o
-
>maximum(
360
);



o
-
>step(
0.1
);



o
-
>
callback((Fl_Callback
*)
cb_vrot
);



}



{
Fl_Slider
*
o

=
ypan

=
new

Fl_Slider(
20
,
75
,
20
,
220
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>minimum(
-
10
);



o
-
>maximum(
10
);



o
-
>
callback((Fl_Callback
*)
cb_ypan
);



}



o
-
>end();



}



{
Fl_Group
*
o

=
HChange

=
new

Fl_Group(
75
,
330
,
300
,
60
);



{
Fl_Roller
*
o

=
hrot

=
new

Fl_Roller(
75
,
370
,
300
,
20
);



o
-
>type(
1
);



o
-
>maximum(
360
);



o
-
>step(
0.1
);



o
-
>
callback((Fl_Callback
*)
cb_hrot
);



}



{
Fl_Slider
*
o

=
xspan

=
new

Fl_Slider(
75
,
350
,
300
,
20
);



o
-
>type(
1
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>minimum(
-
10
);



o
-
>maximum(
10
);



o
-
>
callback((Fl_Callback
*)
cb_xspan
);



}



o
-
>end();



}



{
Fl_Group
*
o

=
MainView

=
new

Fl_Group(
50
,
45
,
340
,
310
);



cframe

=
new

Fl_Box(
75
,
45
,
300
,
300
,
"label"
);



cube =
new

CubeView(
75
,
50
,
300
,
300
);



o
-
>end();



}



{
Fl_Value_Slider
*
o

= zoom =
new

Fl_Value_Slider(
65
,
5
,
320
,
25
,
"Zoom"
);



o
-
>type(
1
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>maximum(
30
);



o
-
>value(
10
);



o
-
>
callback((Fl_Callback
*)
cb_zoom
);



}



o
-
>end();



}



o
-
>end();



}


}



void

CubeViewUI::show(
int

argc
,
char

**
argv
) {



mainWindow
-
>
show(argc
,
argv
);


}

CubeViewUI.cxx



10



CubeViewUI::CubeViewUI
() {



Fl_Window
*
w
;



{
Fl_Window
*
o

=
mainWindow

=
new

Fl_Window(
440
,
390
);



w

=
o
;



o
-
>
user_data((
void
*)(
this
));



{
Fl_Group
*
o

=
new

Fl_Group(
0
,
-
20
,
455
,
415
);



{
Fl_Group
*
o

=
VChange

=
new

Fl_Group(
0
,
75
,
40
,
220
);



{
Fl_Roller
*
o

=
vrot

=
new

Fl_Roller(
0
,
75
,
20
,
220
);



o
-
>maximum(
360
);



o
-
>step(
0.1
);



o
-
>
callback((Fl_Callback
*)
cb_vrot
);



}



{
Fl_Slider
*
o

=
ypan

=
new

Fl_Slider(
20
,
75
,
20
,
220
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>minimum(
-
10
);



o
-
>maximum(
10
);



o
-
>
callback((Fl_Callback
*)
cb_ypan
);



}



o
-
>end();



}



{
Fl_Group
*
o

=
HChange

=
new

Fl_Group(
75
,
330
,
300
,
60
);



{
Fl_Roller
*
o

=
hrot

=
new

Fl_Roller(
75
,
370
,
300
,
20
);



o
-
>type(
1
);



o
-
>maximum(
360
);



o
-
>step(
0.1
);



o
-
>
callback((Fl_Callback
*)
cb_hrot
);



}



{
Fl_Slider
*
o

=
xspan

=
new

Fl_Slider(
75
,
350
,
300
,
20
);



o
-
>type(
1
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>minimum(
-
10
);



o
-
>maximum(
10
);



o
-
>
callback((Fl_Callback
*)
cb_xspan
);



}



o
-
>end();



}



{
Fl_Group
*
o

=
MainView

=
new

Fl_Group(
50
,
45
,
340
,
310
);



cframe

=
new

Fl_Box(
75
,
45
,
300
,
300
,
"label"
);



cube =
new

CubeView(
75
,
50
,
300
,
300
);



o
-
>end();



}



{
Fl_Value_Slider
*
o

= zoom =
new

Fl_Value_Slider(
65
,
5
,
320
,
25
,
"Zoom"
);



o
-
>type(
1
);



o
-
>
box(FL_PLASTIC_UP_BOX
);



o
-
>maximum(
30
);



o
-
>value(
10
);



o
-
>
callback((Fl_Callback
*)
cb_zoom
);



}



o
-
>end();



}



o
-
>end();



}


}



void

CubeViewUI::show(
int

argc
,
char

**
argv
) {



mainWindow
-
>
show(argc
,
argv
);


}

VXL
-

C++ Libraries for Computer Vision

11


We will look into the VNL and VIL Libraries



VNL:
Numerics

Library (vectors and matrices, doing math
on them)


VIL: Core image library (loading/saving images, image
processing)




I will post some sample codes for you all to try out.

VIL Library


12



VXL supports .
ppm
, .
ppm
, .jpg, .gif, and other common
image formats.



How to load an image?


Note:
vxl_byte

is equivalent to unsigned char ([0...255])


vil_image_view
<
vxl_byte
> img3;



// convert image to a 3
-
band image (RGB


ignore Alpha)


img3 = vil_convert_to_n_planes(3,


vil_convert_cast(vxl_byte
(),
vil_load("test.ppm
")));

More VIL

13


To manipulate the data (i.e., for assignment # 1), it is
necessary to use floating point number to avoid rounding
(overflow) errors since
vxl_bytes

(unsigned char) can
only store values from 0 to 255.



The images indices are
x

(left
-
to
-
right) and
y

(top
-
to
-
bottom)


e.g., img3(i,
j
, 0) or img3(i,j).r represents the pixel value at (
i
,
j
)
coordinate and first plane (i.e., RGB plane’s R).



img3.ni(), img3.nj(), img3.nplanes() return the width,
height, and number of planes in the image respectively.


To Save an Image

14


vil_save(img3, ”
output.ppm
");


If you are using floating point or integer type, you must
convert the to
vxl_byte

or unsigned char ([0, 255])


You may need to handle saturation (i.e., any values that is
over 255 or below 0) values manually.



VIL Demo

15


#include
<
vxl_config.h
>


#include
<
vil/vil_rgb.h
>


#include
<
vil/vil_load.h
>


#include
<
vil/vil_save.h
>


#include
<
vil/vil_image_view.h
>


#include
<
vil/vil_convert.h
>



int

main(
int

argc
,
char

**
argv
)


{



vil_image_view
<
vil_rgb
<
vxl_byte
> >
img
;



img

= vil_convert_to_component_order(vil_convert_to_n_planes(
3
,vil_convert_cast(vxl_byte(),vil_load(argv[
1
]))));






//for every pixel, we threshold all bright pixels to black



for

(
unsigned

j

=
0
;
j

<
img.nj
(); ++
j
)



for

(
unsigned

i

=
0
;
i

<
img.ni
(); ++
i
)



if

(
img(i,j).r

>
200

&&
img(i,j).g

>
200

&&
img(i,j).b

>
200
)



img(i,j
) =
vil_rgb
<
vxl_byte
>(
0
,
0
,
0
);






vil_save(img
, argv[
2
]);



return

0
;


}

Sample Output

16

VNL Library (Numeric)


Demo
!

17

Linear Algebra Review


For assignment # 1? Golden Rule of Thumbs?


Solve the math problem first, then do the programming later.



Where is my matrix inverse function in VNL?


Ans
:
vnl_matrix_inverse




If people are interested, I can walk through the VNL completely
with the SVD method next week!


Reference:
http://www.lems.brown.edu/vision/vxl_doc/html/books/core/bo
ok_6.html


18