Augmented Reality Control of the Telerobot 2003


Module 2: Image Capture Software



Download 6.79 Mb.
Page6/17
Date26.04.2018
Size6.79 Mb.
#46776
1   2   3   4   5   6   7   8   9   ...   17

Module 2: Image Capture Software

2.1 Initial Specification


Software was required in order to capture images, save the images and import them for use within LabVIEW. After it was decided that the imaging hardware would include the QuickCam Pro 4000, image capture and manipulation would be done through the use of the QuickCam SDK.

2.2 Design/Implementation


It was later found that the SDK could be used using a different a different class file. This was the Hydra Video Portal Class present within the hportal.dll file found in the twain_32 directory under the windows directory as opposed to the older Video Portal Class found in the vportal2.dll file under the QuickCam SDK directory. The methods in this class and their use were identical to that in the Video Portal class. However, due to time constraints, use of this class was not fully explored.

Due to problems with the SDK and time limitations, it was decided to use a set of VIs developed by a third party. First and foremost, it should be acknowledged that Peter Parente produced the majority code. His code is available from http://www.mindofpete.org/labview_webcam.shtml. This code was available as LabVIEW VIs that could be used immediately the final code. However, this code was not without it’s limitations. It was only able to work with a single camera, as the dll file included with it made use of Video for Windows. Furthermore, it could only capture images at 320 x 240. This resolution was far too low for the requirements. The image captured was also mirrored. All images were captured in a 4:3 width to height ratio. There was also a problem with an image not being captured. Instead it would return a black image. This was resolved by increasing the time delay after initialisation from 0.5s to 0.7s.

As a result, some code was created to increase the image size by a whole number zoom factor z. An algorithm was also required to mirror the image back to its original state. These two operations would be run in the Capture VI. It was determined that image data was in the form of a one-dimensional array which had 3 times more elements than the number of pixels. It was assumed that this would represent different colour channels for each pixel: red, green and blue.

In order to enlarge the picture, each pixel would take up z2 number of pixels. The example below shows what occurs if the zoom factor is two.



1

2

3

4

5

6

7

8

9

10

11

12



1

1

2

2

3

3

4

4

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

5

5

6

6

7

7

8

8

9

9

10

10

11

11

12

12

9

9

10

10

11

11

12

12



This was done through the use of nested for loops. The algorithm takes a sub-array representing each pixel and repeat them z times across, before selecting the next pixel. This would be repeated until the row was completed. This row would then be repeated z times also. Then, the next row in the original image data array would be selected and the process repeated until the image is completely processed. As the image data was one dimensional, there was no true row number. Instead the element would be:

The mirroring process was also required so the robot would be sent to the correct coordinates and to eliminate any confusion. This process involved working with individual rows. If the pixel started at element i, the pixel would then be moved to the (width – i) position in the row.



1

2

3

4

5

6

7

8

9

10

11

12

The original image

4

3

2

1

8

7

6

5

12

11

10

9

The mirrored image

Because there are actually three elements for each pixel, each pixel would begin at element 3i, the actual process along each row would be:

In order to take into account the row, in a flattened array, the first element number of the row would be subtracted before manipulation and added back after manipulation. This mirroring process was completed before the enlarging process to minimise the time needed for the entire process.


2.3 Testing


Examples of some tests carried out on the zooming and mirroring algorithms are shown below. Note that to save on room, each array has been broken up in rows and numbers 10-36 have been replaced by A-Z respectively.

2.3.1 Zooming x 2

Original

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z



Expected

0

1

2

0

1

2

3

4

5

3

4

5

6

7

8

6

7

8

9

A

B

9

A

B

0

1

2

0

1

2

3

4

5

3

4

5

6

7

8

6

7

8

9

A

B

9

A

B

C

D

E

C

D

E

F

G

H

F

G

H

I

J

K

I

J

K

L

M

N

L

M

N

C

D

E

C

D

E

F

G

H

F

G

H

I

J

K

I

J

K

L

M

N

L

M

N

O

P

Q

O

P

Q

R

S

T

R

S

T

U

V

W

U

V

W

X

Y

Z

X

Y

Z

O

P

Q

O

P

Q

R

S

T

R

S

T

U

V

W

U

V

W

X

Y

Z

X

Y

Z



Actual

0

1

2

0

1

2

3

4

5

3

4

5

6

7

8

6

7

8

9

A

B

9

A

B

0

1

2

0

1

2

3

4

5

3

4

5

6

7

8

6

7

8

9

A

B

9

A

B

C

D

E

C

D

E

F

G

H

F

G

H

I

J

K

I

J

K

L

M

N

L

M

N

C

D

E

C

D

E

F

G

H

F

G

H

I

J

K

I

J

K

L

M

N

L

M

N

O

P

Q

O

P

Q

R

S

T

R

S

T

U

V

W

U

V

W

X

Y

Z

X

Y

Z

O

P

Q

O

P

Q

R

S

T

R

S

T

U

V

W

U

V

W

X

Y

Z

X

Y

Z



2.3.2 Mirroring

Original

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z



Expected

9

A

B

6

7

8

3

4

5

0

1

2

L

M

N

I

J

K

F

G

H

C

D

E

X

Y

Z

U

V

W

R

S

T

O

P

Q



Actual

9

A

B

6

7

8

3

4

5

0

1

2

L

M

N

I

J

K

F

G

H

C

D

E

X

Y

Z

U

V

W

R

S

T

O

P

Q


2.4 Final Specification


The final specification is far from the original specification. Due to the original cameras failing to work and the subsequent unexpected absence of A/Prof James Trevelyan, the time to develop appropriate software was diminished. The final code used does not meet all of the functionality objectives. Instead, only a low-resolution image was captured and increased in size for testing of the overall application.

2.5 Documentation




Figure 10

This VI, created by Peter Parente, initialises the camera ready for use. The wait time at the end was increased from the original value.



Inputs

Type

Description

Driver (0)

Integer

Should be 0. Would define which camera it is

Width (320)

Integer

The width of the image. Should be 320 as Video for Windows does not allow for resizing of the image captured through LabVIEW

Height (240)

Integer

The height of the image. Should be 240 as Video for Windows does not allow for resizing of the image captured through LabVIEW

Error in

Error

Any error that has occurred to this stage



Outputs

Type

Description

Webcam image out

Image

The information about the image being currently received by the camera

Camera?

Boolean

True if a camera has been connected and the image can be received

Error out

Error

Any errors that occurred including previous errors



Figure 11

This VI was originally created by Peter Parente and was modified to include mirroring and zooming for use within the Augmented Reality code.



Inputs

Type

Description

Refresh

Boolean

True if the image needs to be refreshed, otherwise VI returns the original image

Image in

Picture

The original image

Webcam image in

Image

Image data (output from Webcam Initialise)

Scaling Factor

Integer

The factor by which to increase the dimensions of the image by.

Error in

Error

Any error that has occurred to this stage



Outputs

Type

Description

Image out

Picture

The resulting picture

Error out

Error

Any errors that occurred including previous errors



Figure 12

This VI was created by Peter Parente to close down the image capturing session.



Inputs

Type

Description

Error in

Error

Any error that has occurred to this stage



Outputs

Type

Description

Error out

Error

Any errors that occurred including previous errors





Download 6.79 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   ...   17




The database is protected by copyright ©ininet.org 2024
send message

    Main page