camera1394_control.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Miguel Armando Riem de Oliveira   *
00003  *   mike@BlackBandit   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 //guardar parametros e carregar settings da camara
00022 
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 //standard includes
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <iostream.h>
00032 #include <string.h>
00033 
00034 //opencv includes
00035 #include <cv.h>
00036 #include <cxcore.h>
00037 #include <highgui.h>
00038 #include <cvaux.h>
00039 
00040 //libraw libdc includes
00041 #include <dc1394_control.h>
00042 #include <raw1394.h>
00043 
00044 //conversions lib include
00045 #include <conversions.h>
00046 
00047 
00048 
00049 
00050 //my defines
00051 #define TRUE 1
00052 #define FALSE 0
00053 
00054 //BUGS
00055 //for some reason if two independent classes are declared and different frame rates are set, the frame rate of both cameras is the smallest selected frame rate. 
00056 
00057 
00058 class camera1394_control {
00059 public:
00060 
00061         
00062         
00066         camera1394_control();
00070         ~camera1394_control();
00071 
00072         //reports
00077         int PrintPossibleModes(void);
00078 
00083         int PrintPossibleFrameRates(void);
00084         
00089         int PrintCameraFeatures(void){dc1394_print_feature_set(featureset); return 1;};
00090 
00095         int PrintCameraInfo(void){dc1394_print_camera_info(camerainfo); return 1;};
00096 
00097         //flags sets
00103         int SetHandleNum(int num){handlenum=num;;return 1;};
00104 
00110         int SetNodeNum(int num){nodenum=num;return 1;};
00111         
00129         int SetColorFormat(int cm);
00130 
00156         int SetFeatureToManualAuto(unsigned int f, unsigned int val);
00157         
00165         int SetFlgverbose(unsigned char val){return flg.verbose=val;};
00166         
00174         int SetFlgtestimgparams(unsigned char val){return flg.testimgparams=val;};
00175 
00176 
00177         //utils
00178         int DmaUnlisten(void){return dc1394_dma_unlisten(handle,&cameracapture);};
00179         int CleanupIsoChannels(void){/*dc1394_cleanup_iso_channels_and_bandwidth();*/return 1;};
00180 
00185         int OpenHandle(void);
00186         
00191         int TurnOffCamera(void);
00192         
00197         int TurnOnCamera(void);
00198 
00203         int GetCameraNodes(void);
00204 
00209         int SetupCapture_dma(void);
00210 
00215         int StartIsoTransmission(void);
00216 
00224         int GetFrame_dma(IplImage *img);
00225 
00230         int InitCameraToFactorySettings(void){return dc1394_init_camera(handle, numnodes[nodenum]);};
00231 
00232 
00233         //gets
00234         int GetFrameRate(void);
00235         int GetBrightness(void);
00236         int GetSaturation(void);
00237         int GetExposure(void);
00238         int GetSharpness(void);
00239         int GetWhiteBalance(void);
00240         int GetHue(void);
00241         int GetGamma(void);
00242         int GetShutter(void);
00243         int GetGain(void);
00244         
00245         //sets
00246         int SetFrameRate(int fr);
00247         int SetBrightness(unsigned int b);
00248         int SetSaturation(unsigned int s);
00249         int SetExposure(unsigned int e);
00250         int SetSharpness(unsigned int s);
00251         int SetWhiteBalance(unsigned int ub, unsigned int vr);
00252         int SetHue(unsigned int h);
00253         int SetGamma(unsigned int g);
00254         int SetShutter(unsigned int s);
00255         int SetGain(unsigned int g);
00256 
00257 // dc1394_get_iris(raw1394handle_t handle, nodeid_t node,
00258 //                 unsigned int *iris);
00259 // int dc1394_set_iris(raw1394handle_t handle, nodeid_t node, unsigned int iris);
00260 // int dc1394_get_focus(raw1394handle_t handle, nodeid_t node,unsigned int *focus);
00261 // int dc1394_set_focus(raw1394handle_t handle, nodeid_t node,unsigned int focus);
00262 // int dc1394_get_temperature(raw1394handle_t handle, nodeid_t node,unsigned int *target_temperature,unsigned int *temperature);
00263 // int dc1394_set_temperature(raw1394handle_t handle, nodeid_t node,unsigned int target_temperature);
00264 // int dc1394_get_white_shading(raw1394handle_t handle, nodeid_t node, unsigned int *r_value, unsigned int *g_value,unsigned int *b_value);
00265 // int dc1394_set_white_shading(raw1394handle_t handle, nodeid_t node,unsigned int r_value, unsigned int g_value, unsigned int b_value);
00266 // int dc1394_get_trigger_delay(raw1394handle_t handle, nodeid_t node, unsigned int *trigger_delay);
00267 // int dc1394_set_trigger_delay(raw1394handle_t handle, nodeid_t node, unsigned int trigger_delay);
00268 // int dc1394_get_frame_rate(raw1394handle_t handle, nodeid_t node, unsigned int *frame_rate);
00269 // int dc1394_set_frame_rate(raw1394handle_t handle, nodeid_t node, unsigned int frame_rate);
00270 // int dc1394_get_hue(raw1394handle_t handle, nodeid_t node,unsigned int *hue);
00271 
00272 private:
00273         raw1394handle_t handle;
00274 
00275         int handlenum;
00276         int nodenum;
00277         nodeid_t *numnodes;
00278         dc1394_feature_info *feature;
00279         dc1394_feature_set *featureset;
00280         dc1394_miscinfo *info;
00281         dc1394_camerainfo *camerainfo;
00282         int numCameras;
00283         dc1394_cameracapture cameracapture;
00284         char* devicename;
00285         unsigned char * TmpBuffer;      
00286 
00287         struct {unsigned char verbose;
00288                 unsigned char hashandle;
00289                 unsigned char testimgparams; //enabled by default. If you wish to disable you must be sure that the IplImage you give to GetFrame_dma has the correct properties
00290                 }flg;
00291         
00292         struct {int width;
00293                 int height;     
00294                 int numchannels;
00295                 int colormode;
00296                 int framerate;
00297                 unsigned int Brightness,Exposure,Sharpness,Hue,Saturation, Gamma, Temperature, Shutter, Gain ,FrameRate;
00298                 struct {unsigned int u_b_value, v_r_value;}WhiteBalance;
00299 
00300                 }captureparams;
00301 
00302         //reference to flg.verbose 
00303         //const unsigned char &vb=flg.verbose;
00304 };

Generated on Tue Jan 30 15:33:07 2007 for camera1394_control.kdevelop by  doxygen 1.4.7