Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

/home/slang/XVision2/src/Devices/dc1394_control.h

00001 /*
00002  * 1394-Based Digital Camera Control Library
00003  * Copyright (C) 2000 SMART Technologies Inc.
00004  *
00005  * Written by Gord Peters <GordPeters@smarttech.com>
00006  * Additions by Chris Urmson <curmson@ri.cmu.edu>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 #ifndef _DC1394_CAMERA_CONTROL_H
00023 #define _DC1394_CAMERA_CONTROL_H
00024 
00025 #include <stddef.h>
00026 #include <sys/types.h>
00027 #include <libraw1394/raw1394.h>
00028 #include <stdio.h>
00029 
00030 /* Enumeration of data speeds */
00031 enum 
00032 {
00033     SPEED_100 = 0,
00034     SPEED_200,
00035     SPEED_400
00036 };
00037 #define SPEED_MIN   SPEED_100
00038 #define SPEED_MAX   SPEED_400
00039 #define NUM_SPEEDS  (SPEED_MAX - SPEED_MIN + 1)
00040 
00041 /* Enumeration of camera framerates */
00042 enum 
00043 {
00044      FRAMERATE_1_875 = 0,
00045      FRAMERATE_3_75,
00046      FRAMERATE_7_5,
00047      FRAMERATE_15,
00048      FRAMERATE_30,
00049      FRAMERATE_60
00050 };
00051 #define FRAMERATE_MIN    FRAMERATE_1_875
00052 #define FRAMERATE_MAX    FRAMERATE_60
00053 #define NUM_FRAMERATES   (FRAMERATE_MAX - FRAMERATE_MIN + 1)
00054 
00055 /* Enumeration of camera modes */
00056 enum 
00057 {
00058      MODE_160x120_YUV444 = 0,
00059      MODE_320x240_YUV422,
00060      MODE_640x480_YUV411,
00061      MODE_640x480_YUV422,
00062      MODE_640x480_RGB,
00063      MODE_640x480_MONO
00064 };
00065 #define MODE_MIN    MODE_160x120_YUV444
00066 #define MODE_MAX    MODE_640x480_MONO
00067 #define NUM_MODES   (MODE_MAX - MODE_MIN + 1)
00068 
00069 /* Enumeration of camera image formats */
00070 enum 
00071 {
00072      FORMAT_VGA_NONCOMPRESSED = 0,
00073      FORMAT_SVGA_NONCOMPRESSED_1,
00074      FORMAT_SVGA_NONCOMPRESSED_2,
00075      FORMAT_RESERVED_1,
00076      FORMAT_RESERVED_2,
00077      FORMAT_RESERVED_3,
00078      FORMAT_STILL_IMAGE,
00079      FORMAT_SCALABLE_IMAGE_SIZE
00080 };
00081 #define FORMAT_MIN  FORMAT_VGA_NONCOMPRESSED
00082 #define FORMAT_MAX  FORMAT_SCALABLE_IMAGE_SIZE
00083 #define NUM_FORMATS (FORMAT_MAX - FORMAT_MIN + 1)
00084 
00085 /* Enumeration of camera features */
00086 enum 
00087 {
00088     FEATURE_BRIGHTNESS= 0,
00089     FEATURE_EXPOSURE,
00090     FEATURE_SHARPNESS,
00091     FEATURE_WHITE_BALANCE,
00092     FEATURE_HUE,
00093     FEATURE_SATURATION,
00094     FEATURE_GAMMA,
00095     FEATURE_SHUTTER,
00096     FEATURE_GAIN,
00097     FEATURE_IRIS,
00098     FEATURE_FOCUS,
00099     FEATURE_TEMPERATURE,
00100     FEATURE_TRIGGER,
00101     FEATURE_ZOOM,
00102     FEATURE_PAN,
00103     FEATURE_TILT,
00104     FEATURE_OPTICAL_FILTER,
00105     FEATURE_CAPTURE_SIZE,
00106     FEATURE_CAPTURE_QUALITY
00107 };
00108 #define FEATURE_MIN              FEATURE_BRIGHTNESS
00109 #define FEATURE_MAX              FEATURE_CAPTURE_QUALITY
00110 #define NUM_FEATURES             (FEATURE_MAX - FEATURE_MIN + 1)
00111 
00112 
00113 
00114 /* Maximum number of characters in vendor and model strings */
00115 #define MAX_CHARS                32
00116 
00117 
00118 /* Return values for visible functions*/
00119 #define DC1394_SUCCESS 1
00120 #define DC1394_FAILURE -1
00121 #define DC1394_NO_CAMERA 0xffff
00122 
00123 
00124 
00125 /* Yet another boolean data type */
00126 typedef enum
00127 {
00128     DC1394_FALSE= 0,
00129     DC1394_TRUE
00130 } dc1394bool_t;
00131 
00132 
00133 /* Camera structure */
00134 typedef struct __dc1394_camerainfo
00135 {
00136     raw1394handle_t handle;
00137     nodeid_t id;
00138     octlet_t ccr_offset;
00139     u_int64_t euid_64;
00140     char vendor[MAX_CHARS + 1];
00141     char model[MAX_CHARS + 1];
00142 } dc1394_camerainfo;
00143 
00144 
00145 typedef struct __dc1394_cam_cap_struct 
00146 {
00147   nodeid_t node;
00148   int channel;
00149   int frame_rate;
00150   int frame_width, frame_height;
00151   int * capture_buffer;
00152   int quadlets_per_frame;
00153   int quadlets_per_packet;
00154 } dc1394_cameracapture ;
00155 
00156 typedef struct __dc1394_feature_info_struct 
00157 {
00158   int feature_id;
00159   dc1394bool_t available;
00160   dc1394bool_t one_push;
00161   dc1394bool_t readout_capable;
00162   dc1394bool_t on_off_capable;
00163   dc1394bool_t auto_capable;
00164   dc1394bool_t manual_capable;
00165   
00166 
00167   dc1394bool_t one_push_active;
00168   dc1394bool_t is_on;
00169   dc1394bool_t auto_active;
00170   
00171   
00172   int min;
00173   int max;
00174   int value;
00175 } dc1394_feature_info;
00176 
00177 /*This structure contains all of the info above for everything except
00178   trigger and white balance...*/
00179 typedef struct __dc1394_feature_set_struct 
00180 {
00181   dc1394_feature_info feature[NUM_FEATURES];
00182 } dc1394_feature_set;
00183 
00184 
00185 #ifdef __cplusplus
00186 extern "C" {
00187 #endif
00188 
00189 /*****************************************************
00190 dc1394_get_camera_feature_set
00191 collects the available features for the camera
00192 described by node and stores them in features.
00193 *****************************************************/  
00194 int 
00195 dc1394_get_camera_feature_set(raw1394handle_t handle, nodeid_t node,dc1394_feature_set *features);
00196 
00197 /*****************************************************
00198 dc1394_get_camera_feature
00199 stores the bounds and options associated with the
00200 feature described by feature->feature_id
00201 *****************************************************/
00202 int 
00203 dc1394_get_camera_feature(raw1394handle_t handle, nodeid_t node,dc1394_feature_info *feature);
00204 
00205 /*****************************************************
00206 dc1394_print_feature
00207 displays the bounds and options of the given feature
00208 *****************************************************/
00209 void 
00210 dc1394_print_feature(dc1394_feature_info *feature);
00211 
00212 /*****************************************************
00213 dc1394_print_feature_set
00214 displays the entire feature set stored in features
00215 *****************************************************/
00216 void 
00217 dc1394_print_feature_set(dc1394_feature_set *features);
00218      
00219 
00220 /*****************************************************
00221 dc1394_create_handle
00222 this creates a raw1394_handle
00223 Port should be 0 unless you have multiple firewire cards in your
00224 system
00225 if a handle can't be created, it returns NULL
00226 *****************************************************/
00227 raw1394handle_t 
00228 dc1394_create_handle(int port);
00229 
00230 
00231 /*****************************************************
00232 dc1394_get_camera_nodes
00233 this returns the available cameras on the bus.
00234 returns -1 in numCameras and NULL from the call if there is a problem, 
00235 otherwise the number of cameras and the nodeid_t array from the call
00236 *****************************************************/
00237 nodeid_t* 
00238 dc1394_get_camera_nodes(raw1394handle_t handle, int *numCameras,
00239                         int showCameras);
00240 
00241 /*****************************************************
00242 dc1394_get_sorted_camera_nodes
00243 this returns the available cameras on the bus.
00244 It returns the node id's in the same index as the id specified
00245 the ids array contains a list of the low quadlet of the unique camera 
00246 ids.
00247 returns -1 in numCameras and NULL from the call if there is a problem, 
00248 otherwise the number of cameras and the nodeid_t array from the call
00249 *****************************************************/
00250 nodeid_t* 
00251 dc1394_get_sorted_camera_nodes(raw1394handle_t handle,int numids, 
00252                         int *ids,int * numCameras,
00253                         int showCameras);
00254 
00255 /* Initialize camera to factory default settings */
00256 int
00257 dc1394_init_camera(raw1394handle_t handle, nodeid_t node);
00258 
00259   /* determine if the given node is a camera */
00260 int
00261 dc1394_is_camera(raw1394handle_t handle, nodeid_t node, dc1394bool_t *value);
00262 
00263 /* get the camera information and print that structure*/
00264 void 
00265 dc1394_print_camera_info(dc1394_camerainfo *info); 
00266 
00267 int
00268 dc1394_get_camera_info(raw1394handle_t handle, nodeid_t node,
00269                        dc1394_camerainfo *info);
00270 
00271 /* Functions for querying camera attributes */
00272 int
00273 dc1394_query_supported_formats(raw1394handle_t handle, nodeid_t node,
00274                                quadlet_t *value);
00275 int
00276 dc1394_query_supported_modes(raw1394handle_t handle, nodeid_t node,
00277                              unsigned int format, quadlet_t *value);
00278 int
00279 dc1394_query_supported_framerates(raw1394handle_t handle, nodeid_t node,
00280                                   unsigned int format, unsigned int mode,
00281                                   quadlet_t *value);
00282 int
00283 dc1394_query_revision(raw1394handle_t handle, nodeid_t node, int mode,
00284                       quadlet_t *value);
00285 int
00286 dc1394_query_csr_offset(raw1394handle_t handle, nodeid_t node, int mode,
00287                         quadlet_t *value);
00288 int
00289 dc1394_query_basic_functionality(raw1394handle_t handle, nodeid_t node,
00290                                  quadlet_t *value);
00291 int
00292 dc1394_query_feature_control(raw1394handle_t handle, nodeid_t node,
00293                              unsigned int feature, unsigned int *availability);
00294 int
00295 dc1394_query_advanced_feature_offset(raw1394handle_t handle, nodeid_t node,
00296                                      quadlet_t *value);
00297 int
00298 dc1394_query_feature_characteristics(raw1394handle_t handle, nodeid_t node,
00299                                      unsigned int feature, quadlet_t *value);
00300 
00301 /* Get/Set the framerate, mode, format, iso channel/speed for the video */
00302 int
00303 dc1394_get_video_framerate(raw1394handle_t handle, nodeid_t node,
00304                            unsigned int *framerate);
00305 int
00306 dc1394_set_video_framerate(raw1394handle_t handle, nodeid_t node,
00307                            unsigned int framerate);
00308 int
00309 dc1394_get_video_mode(raw1394handle_t handle, nodeid_t node,
00310                       unsigned int *mode);
00311 int
00312 dc1394_set_video_mode(raw1394handle_t handle, nodeid_t node,
00313                       unsigned int mode);
00314 int
00315 dc1394_get_video_format(raw1394handle_t handle, nodeid_t node,
00316                         unsigned int *format);
00317 int
00318 dc1394_set_video_format(raw1394handle_t handle, nodeid_t node,
00319                         unsigned int format);
00320 int
00321 dc1394_get_iso_channel_and_speed(raw1394handle_t handle, nodeid_t node,
00322                                  unsigned int *channel, unsigned int *speed);
00323 int
00324 dc1394_set_iso_channel_and_speed(raw1394handle_t handle, nodeid_t node,
00325                                  unsigned int channel, unsigned int speed);
00326 
00327 /* Turn camera on or off */
00328 int
00329 dc1394_camera_on(raw1394handle_t handle, nodeid_t node);
00330 int
00331 dc1394_camera_off(raw1394handle_t handle, nodeid_t node);
00332 
00333 /* Start/stop isochronous data transmission */
00334 int
00335 dc1394_start_iso_transmission(raw1394handle_t handle, nodeid_t node);
00336 int
00337 dc1394_stop_iso_transmission(raw1394handle_t handle, nodeid_t node);
00338 
00339 /* Turn one shot mode on or off */
00340 int
00341 dc1394_set_one_shot(raw1394handle_t handle, nodeid_t node);
00342 int
00343 dc1394_unset_one_shot(raw1394handle_t handle, nodeid_t node);
00344 
00345 /* Turn multishot mode on or off */
00346 int
00347 dc1394_set_multi_shot(raw1394handle_t handle, nodeid_t node,
00348                       unsigned int numFrames);
00349 int
00350 dc1394_unset_multi_shot(raw1394handle_t handle, nodeid_t node);
00351 
00352 /* Get/Set the values of the various features on the camera */
00353 int
00354 dc1394_get_brightness(raw1394handle_t handle, nodeid_t node,
00355                       unsigned int *brightness);
00356 int
00357 dc1394_set_brightness(raw1394handle_t handle, nodeid_t node,
00358                       unsigned int brightness);
00359 int
00360 dc1394_get_exposure(raw1394handle_t handle, nodeid_t node,
00361                     unsigned int *exposure);
00362 int
00363 dc1394_set_exposure(raw1394handle_t handle, nodeid_t node,
00364                     unsigned int exposure);
00365 int
00366 dc1394_get_sharpness(raw1394handle_t handle, nodeid_t node,
00367                      unsigned int *sharpness);
00368 int
00369 dc1394_set_sharpness(raw1394handle_t handle, nodeid_t node,
00370                      unsigned int sharpness);
00371 int
00372 dc1394_get_white_balance(raw1394handle_t handle, nodeid_t node,
00373                          unsigned int *u_b_value, unsigned int *v_r_value);
00374 int
00375 dc1394_set_white_balance(raw1394handle_t handle, nodeid_t node,
00376                          unsigned int u_b_value, unsigned int v_r_value);
00377 int
00378 dc1394_get_hue(raw1394handle_t handle, nodeid_t node,
00379                unsigned int *hue);
00380 int
00381 dc1394_set_hue(raw1394handle_t handle, nodeid_t node,
00382                unsigned int hue);
00383 int
00384 dc1394_get_saturation(raw1394handle_t handle, nodeid_t node,
00385                       unsigned int *saturation);
00386 int
00387 dc1394_set_saturation(raw1394handle_t handle, nodeid_t node,
00388                       unsigned int saturation);
00389 int
00390 dc1394_get_gamma(raw1394handle_t handle, nodeid_t node,
00391                  unsigned int *gamma);
00392 int
00393 dc1394_set_gamma(raw1394handle_t handle, nodeid_t node,
00394                  unsigned int gamma);
00395 int
00396 dc1394_get_shutter(raw1394handle_t handle, nodeid_t node,
00397                    unsigned int *shutter);
00398 int
00399 dc1394_set_shutter(raw1394handle_t handle, nodeid_t node,
00400                    unsigned int shutter);
00401 int
00402 dc1394_get_gain(raw1394handle_t handle, nodeid_t node,
00403                 unsigned int *gain);
00404 int
00405 dc1394_set_gain(raw1394handle_t handle, nodeid_t node,
00406                 unsigned int gain);
00407 int
00408 dc1394_get_iris(raw1394handle_t handle, nodeid_t node,
00409                 unsigned int *iris);
00410 int
00411 dc1394_set_iris(raw1394handle_t handle, nodeid_t node,
00412                 unsigned int iris);
00413 int
00414 dc1394_get_focus(raw1394handle_t handle, nodeid_t node,
00415                  unsigned int *focus);
00416 int
00417 dc1394_set_focus(raw1394handle_t handle, nodeid_t node,
00418                  unsigned int focus);
00419 int
00420 dc1394_get_temperature(raw1394handle_t handle, nodeid_t node,
00421                        unsigned int *target_temperature,
00422                  unsigned int *temperature);
00423 int
00424 dc1394_set_temperature(raw1394handle_t handle, nodeid_t node,
00425                        unsigned int target_temperature);
00426 int
00427 dc1394_get_trigger_mode(raw1394handle_t handle, nodeid_t node,
00428                         unsigned int *mode);
00429 int
00430 dc1394_set_trigger_mode(raw1394handle_t handle, nodeid_t node,
00431                         unsigned int mode);
00432 int
00433 dc1394_get_zoom(raw1394handle_t handle, nodeid_t node,
00434                 unsigned int *zoom);
00435 int
00436 dc1394_set_zoom(raw1394handle_t handle, nodeid_t node,
00437                 unsigned int zoom);
00438 int
00439 dc1394_get_pan(raw1394handle_t handle, nodeid_t node,
00440                unsigned int *pan);
00441 int
00442 dc1394_set_pan(raw1394handle_t handle, nodeid_t node,
00443                unsigned int pan);
00444 int
00445 dc1394_get_tilt(raw1394handle_t handle, nodeid_t node,
00446                 unsigned int *tilt);
00447 int
00448 dc1394_set_tilt(raw1394handle_t handle, nodeid_t node,
00449                 unsigned int tilt);
00450 int
00451 dc1394_get_optical_filter(raw1394handle_t handle, nodeid_t node,
00452                           unsigned int *optical_filter);
00453 int
00454 dc1394_set_optical_filter(raw1394handle_t handle, nodeid_t node,
00455                           unsigned int optical_filter);
00456 int
00457 dc1394_get_capture_size(raw1394handle_t handle, nodeid_t node,
00458                         unsigned int *capture_size);
00459 int
00460 dc1394_set_capture_size(raw1394handle_t handle, nodeid_t node,
00461                         unsigned int capture_size);
00462 int
00463 dc1394_get_capture_quality(raw1394handle_t handle, nodeid_t node,
00464                            unsigned int *capture_quality);
00465 int
00466 dc1394_set_capture_quality(raw1394handle_t handle, nodeid_t node,
00467                            unsigned int capture_quality);
00468 
00469 /* Convenience functions to query/set based on a variable camera feature */
00470 /* (can't be used for white balance) */
00471 int
00472 dc1394_get_feature_value(raw1394handle_t handle, nodeid_t node,
00473                          unsigned int feature, unsigned int *value);
00474 
00475 int
00476 dc1394_set_feature_value(raw1394handle_t handle, nodeid_t node,
00477                          unsigned int feature, unsigned int value);
00478 
00479 /* Query/set specific feature characteristics */
00480 int
00481 dc1394_is_feature_present(raw1394handle_t handle, nodeid_t node,
00482                           unsigned int feature, dc1394bool_t *value);
00483 int
00484 dc1394_has_one_push_auto(raw1394handle_t handle, nodeid_t node,
00485                          unsigned int feature, dc1394bool_t *value);
00486 int
00487 dc1394_is_one_push_in_operation(raw1394handle_t handle, nodeid_t node,
00488                                 unsigned int feature, dc1394bool_t *value);
00489 int
00490 dc1394_start_one_push_operation(raw1394handle_t handle, nodeid_t node,
00491                                 unsigned int feature);
00492 int
00493 dc1394_can_read_out(raw1394handle_t handle, nodeid_t node,
00494                     unsigned int feature, dc1394bool_t *value);
00495 int
00496 dc1394_can_turn_on_off(raw1394handle_t handle, nodeid_t node,
00497                        unsigned int feature, dc1394bool_t *value);
00498 int
00499 dc1394_is_feature_on(raw1394handle_t handle, nodeid_t node,
00500                      unsigned int feature, dc1394bool_t *value);
00501 int
00502 dc1394_feature_on_off(raw1394handle_t handle, nodeid_t node,
00503                       unsigned int feature, unsigned int value);
00504                                           /* 0=off, nonzero=on */
00505 int
00506 dc1394_has_auto_mode(raw1394handle_t handle, nodeid_t node,
00507                      unsigned int feature, dc1394bool_t *value);
00508 int
00509 dc1394_has_manual_mode(raw1394handle_t handle, nodeid_t node,
00510                        unsigned int feature, dc1394bool_t *value);
00511 int
00512 dc1394_is_feature_auto(raw1394handle_t handle, nodeid_t node,
00513                        unsigned int feature, dc1394bool_t *value);
00514 int
00515 dc1394_auto_on_off(raw1394handle_t handle, nodeid_t node,
00516                    unsigned int feature, unsigned int value);
00517                                           /* 0=off, nonzero=on */
00518 int
00519 dc1394_get_min_value(raw1394handle_t handle, nodeid_t node,
00520                      unsigned int feature, unsigned int *value);
00521 int
00522 dc1394_get_max_value(raw1394handle_t handle, nodeid_t node,
00523                      unsigned int feature, unsigned int *value);
00524 
00525 /*****************************************************
00526 dc1394_setup_camera
00527 sets up both the camera and the cameracapture structure
00528 to be used other places.
00529 returns DC1394_SUCCESS on success, DC1394_FAILURE otherwise
00530 NOTE: it is important to call dc1394_release_camera 
00531 to free memory allocated by this routine- if you don't,
00532 your application WILL leak memory
00533 *****************************************************/
00534 int 
00535 dc1394_setup_camera(raw1394handle_t handle, nodeid_t node, 
00536                  int channel, int format, int mode, 
00537                  int speed, int frame_rate, 
00538                  dc1394_cameracapture * camera);
00539 /*****************************************************
00540 dc1394_release_camera
00541 frees buffer space contained in the cameracapture structure
00542 *****************************************************/
00543 int 
00544 dc1394_release_camera(raw1394handle_t handle,
00545                               dc1394_cameracapture *camera);
00546 
00547 
00548 /*****************************************************
00549 dc1394_single_capture
00550 captures a frame of vide from the camera specified
00551 *****************************************************/
00552 int 
00553 dc1394_single_capture(raw1394handle_t handle,
00554                       dc1394_cameracapture *camera);
00555 
00556 
00557 /*****************************************************
00558 dc1394_multi_capture
00559 this routine captures a frame from each camera specified
00560 in the cams array.  Cameras must be set up first using dc1394_setup_camera
00561 returns DC1394_FAILURE if it fails, DC1394_SUCCESS if it scucceeds
00562 *****************************************************/
00563 int 
00564 dc1394_multi_capture(raw1394handle_t handle, dc1394_cameracapture * cams, int num);
00565 
00566 #ifdef __cplusplus
00567 }
00568 #endif
00569 
00570 #endif /* _DC1394_CAMERA_CONTROL_H */
00571 
00572 
00573 
00574 
00575 
00576 
00577 

Generated at Thu Mar 29 22:37:28 2001 for XVision by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000