pgr_registers.cpp
Go to the documentation of this file.
1 
11 //=============================================================================
12 // Copyright © 2006 Point Grey Research, Inc. All Rights Reserved.
13 //
14 // This software is the confidential and proprietary information of Point
15 // Grey Research, Inc. ("Confidential Information"). You shall not
16 // disclose such Confidential Information and shall use it only in
17 // accordance with the terms of the license agreement you entered into
18 // with Point Grey Research Inc.
19 //
20 // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
21 // SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
22 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES
24 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
25 // THIS SOFTWARE OR ITS DERIVATIVES.
26 //
27 //=============================================================================
28 
29 //=============================================================================
30 //
31 // pgr_registers.cpp
32 //
33 //=============================================================================
34 
35 //=============================================================================
36 // System Includes
37 //=============================================================================
38 #include <stdio.h>
39 #include <errno.h>
40 #include <dc1394/dc1394.h>
41 
42 //=============================================================================
43 // PGR Includes
44 //=============================================================================
45 #include "pgr_registers.h"
46 
47 //=============================================================================
48 // Implementation
49 //=============================================================================
50 
51 
52 //=============================================================================
53 // getBayerTile()
54 // Query the PGR specific register that indicates the Bayer tile pattern
55 // color coding for this camera.
56 //
57 // For more information check the PGR IEEE-1394 Digital Camera Register
58 // Reference
59 //
60 dc1394error_t
61 getBayerTile( dc1394camera_t* camera,
62  dc1394color_filter_t* bayerPattern )
63 {
64 
65  uint32_t value;
66  dc1394error_t err;
67 
68  // query register 0x1040
69  // This register is an advanced PGR register called BAYER_TILE_MAPPING
70  // For more information check the PGR IEEE-1394 Digital Camera Register Reference
71  err = dc1394_get_control_register( camera, BAYER_TILE_MAPPING_REGISTER, &value );
72  if ( err != DC1394_SUCCESS )
73  {
74  return err;
75  }
76 
77  // Ascii R = 52 G = 47 B = 42 Y = 59
78  switch( value )
79  {
80  default:
81  case 0x59595959: // YYYY
82  // no bayer
83  *bayerPattern = (dc1394color_filter_t) 0;
84  break;
85  case 0x52474742: // RGGB
86  *bayerPattern = DC1394_COLOR_FILTER_RGGB;
87  break;
88  case 0x47425247: // GBRG
89  *bayerPattern = DC1394_COLOR_FILTER_GBRG;
90  break;
91  case 0x47524247: // GRBG
92  *bayerPattern = DC1394_COLOR_FILTER_GRBG;
93  break;
94  case 0x42474752: // BGGR
95  *bayerPattern = DC1394_COLOR_FILTER_BGGR;
96  break;
97  }
98 
99  return err;
100 }
101 
102 //=============================================================================
103 // setEndian()
104 // Set the endian-ness of 16-bit data coming from the camera.
105 //
106 // This is a PGR camera specific register
107 // For more information check the PGR IEEE-1394 Digital Camera Register
108 // Reference
109 //
110 dc1394error_t
111 setEndian( dc1394camera_t* camera,
112  bool bBigEndian )
113 {
114 
115  uint32_t value;
116  dc1394error_t err;
117 
118  if ( bBigEndian )
119  {
120  // use 16-bit modes in big endian (default 1394) format
121  value = 0x80000001;
122  }
123  else
124  {
125  // use 16-bit modes in little endian (pgr default) format
126  value = 0x80000000;
127  }
128 
129 
130  err = dc1394_set_control_register( camera,
132  value );
133  return err;
134 }
135 
136 
137 //=============================================================================
138 // getSensorInfo()
139 // This function queries the SENSOR BOARD INFO register and extracts
140 // the sensor resolution and whether it is color or monochrome from the
141 // register
142 //
143 // This is a PGR camera specific register
144 // For more information check the PGR IEEE-1394 Digital Camera Register
145 // Reference
146 //
147 dc1394error_t
148 getSensorInfo( dc1394camera_t* camera,
149  bool* pbColor,
150  unsigned int* pnRows,
151  unsigned int* pnCols )
152 {
153 
154  uint32_t value;
155  dc1394error_t err;
156 
157  // This register is an advanced PGR register called SENSOR_BOARD_INFO
158  err = dc1394_get_control_register( camera, SENSOR_BOARD_INFO_REGISTER, &value );
159  if ( err != DC1394_SUCCESS )
160  {
161  return err;
162  }
163 
164  unsigned char ucSensorInfo = 0xf & value;
165 
166  switch( ucSensorInfo )
167  {
168  default:
169  // unknown sensor!
170  printf( "Illegal sensor board info detected!\n" );
171  return DC1394_FAILURE;
172  case 0xA: // color 640x480
173  *pbColor = true;
174  *pnRows = 480;
175  *pnCols = 640;
176  break;
177  case 0xB: // mono 640x480
178  *pbColor = false;
179  *pnRows = 480;
180  *pnCols = 640;
181  break;
182  case 0xC: // color 1024x768
183  *pbColor = true;
184  *pnRows = 768;
185  *pnCols = 1024;
186  break;
187  case 0xD: // mono 1024x768
188  *pbColor = false;
189  *pnRows = 768;
190  *pnCols = 1024;
191  break;
192  case 0xE: // color 1280x960
193  *pbColor = true;
194  *pnRows = 960;
195  *pnCols = 1280;
196  break;
197  case 0xF: // mono 1280x960
198  *pbColor = false;
199  *pnRows = 960;
200  *pnCols = 1280;
201  break;
202  }
203 
204  return err;
205 }
206 
207 
211 /*Previous 3 lines appended automatically on Wed Jun 9 00:11:56 WEST 2010 */
Header file for the registers for the PGR toolbox.
dc1394error_t getSensorInfo(dc1394camera_t *camera, bool *pbColor, unsigned int *pnRows, unsigned int *pnCols)
#define SENSOR_BOARD_INFO_REGISTER
Definition: pgr_registers.h:75
dc1394error_t getBayerTile(dc1394camera_t *camera, dc1394color_filter_t *bayerPattern)
dc1394error_t setEndian(dc1394camera_t *camera, bool bBigEndian)
#define BAYER_TILE_MAPPING_REGISTER
Definition: pgr_registers.h:74
#define IMAGE_DATA_FORMAT_REGISTER
Definition: pgr_registers.h:76


xb3
Author(s): Miguel Oliveira, Tiago Talhada
autogenerated on Mon Mar 2 2015 01:33:02