loadCameraData

Synopse

This function loads the correlation features of the cameras

  • feats,labels = loadCameraData(file_name)

    • Output
      • feats: Array of features loaded.
      • labels: Vector of labels loaded.
    • Input

      • file_name: Name of the file to be loaded.

Description

This function loads the camera file containing its features and labels.

Function Code

 1 def loadCameraData():
 2    file_name = 'TRN-1-cam-1.txt'
 3    f = open(find_attachment_file(file_name))
 4 
 5    data = f.read().split()
 6    data = map(float, data)
 7 
 8    # dividindo em feats e labels
 9    data = array(data)
10    data = data.reshape(len(data)/37,37) # 1 label + 36 features
11 
12    feats = data[:,1:len(data[0,:])]
13    labels = data[:,0]
14 
15    return feats,labels

Example:

1 from rob_testes import loadCameraDat
2 from numpy import*
3 
4 feats,labels = loadCameraData()
5 print feats.shape
6 print labels.shape
ERROR execute

------------------------------------------------------------
*** Exception while evaluating code:
  File "<string>", line 1, in <module>
  File "/home/rubens/www/packages/courseIA368Q1S2012/rob_testes.py", line 20, in <module>
    feats,labels = loadCameraData()
  File "/home/rubens/www/packages/courseIA368Q1S2012/rob_testes.py", line 4, in loadCameraData
    f = open(find_attachment_file(file_name))
NameError: global name 'find_attachment_file' is not defined

------------------------------------------------------------

Example 2

 1 f = open(find_attachment_file('Cameras_features/TRN-1-cam-1.txt'))
 2 
 3 data = f.read().split()
 4 data = map(float, data)
 5 
 6 # dividindo em feats e labels
 7 data = array(data)
 8 data = data.reshape(len(data)/37,37) # 1 label + 36 features
 9 
10 feats = data[:,1:len(data[0,:])]
11 labels = data[:,0]
12 
13 print feats.shape
14 print labels.shape
ERROR execute

------------------------------------------------------------
*** Exception while evaluating code:
  File "<string>", line 1, in <module>
  File "xs_runner_python.py", line 146, in find_image_file
    raise IOError('Cannot find image: %s' % filename)
IOError: Cannot find image: Cameras_features/TRN-1-cam-1.txt

------------------------------------------------------------

Example 3

 1 f = open(find_attachment_file('TRN-1-cam-1.txt'))
 2 
 3 data = f.read().split()
 4 data = map(float, data)
 5 
 6 # dividindo em feats e labels
 7 data = array(data)
 8 data = data.reshape(len(data)/37,37) # 1 label + 36 features
 9 
10 feats = data[:,1:len(data[0,:])]
11 labels = data[:,0]
12 
13 print feats.shape
14 print labels.shape
(1695, 36)
(1695,)

Contributions

  • Roberto M Souza, 2o semestre de 2012.