#include "iclDCDevice.h" #include #include #include #include using namespace std; using namespace icl::dc; namespace icl{ /** Have a NEW CAMERA ??? - add a new CameryTypeID to the DCDevice::enum - edit the function trailed wiht token **NEW-CAM** - bool DCDevice::supports(format) const - bool DCDevice::supports(const Size &) const - bool DCDevice::needsBayerDecoding() const - dc1394color_filter_t DCDevice::getBayerFilterLayout() const **/ const DCDevice DCDevice::null = DCDevice(0); // **NEW-CAM** (optional) std::string DCDevice::translate(DCDevice::CameraTypeID id){ // {{{ open switch(id){ #define TRANSLATE(X) case X: return #X TRANSLATE(pointGreyFire_FlyMVMono); TRANSLATE(pointGreyFire_FlyMVColor); TRANSLATE(sony_DFW_VL500_2_30); TRANSLATE(apple_ISight); TRANSLATE(fireI_1_2); TRANSLATE(imagingSource_DFx_21BF04); #undef TRANSLATE default: return "unknownCameraType"; } } // }}} // **NEW-CAM** (optional) DCDevice::CameraTypeID DCDevice::translate(const std::string &name){ // {{{ open if(name == "pointGreyFire_FlyMVMono" ) return pointGreyFire_FlyMVMono; #define TRANSLATE(X) else if( name == #X ) return X TRANSLATE(pointGreyFire_FlyMVColor); TRANSLATE(sony_DFW_VL500_2_30); TRANSLATE(apple_ISight); TRANSLATE(fireI_1_2); TRANSLATE(imagingSource_DFx_21BF04); #undef TRANSLATE else return unknownCameraType; } // }}} // **NEW-CAM** DCDevice::CameraTypeID DCDevice::estimateCameraType(dc1394camera_t *cam){ // {{{ open if(!cam){ return unknownCameraType; }else if( is_firefly_mono(cam) ){ return pointGreyFire_FlyMVMono; }else if( is_firefly_color(cam) ){ return pointGreyFire_FlyMVColor; }else if( string(cam->model) == "DFW-VL500 2.30"){ return sony_DFW_VL500_2_30; }else if( string(cam->vendor) == "Apple Computer, Inc."){ return apple_ISight; }else if( string(cam->model) == "Fire-i 1.2"){ return fireI_1_2; }else if( string(cam->model) == "DFx 21BF04"){ return imagingSource_DFx_21BF04; }else{ ERROR_LOG("unsupported camera: \"" << cam->model << "\""); return unknownCameraType; } } // }}} vector DCDevice::getModes() const{ // {{{ open vector v; ICLASSERT_RETURN_VAL( !isNull(), v); dc1394video_modes_t modeList; dc1394_video_get_supported_modes(m_poCam,&modeList); for(unsigned int i=0;ivendor; } // }}} string DCDevice::getModelID() const{ // {{{ open if(isNull()) return "null"; return m_poCam->model; } // }}} uint64_t DCDevice::getGUID() const{ if(isNull()) return -1; return m_poCam->guid; } icl32s DCDevice::getUnit() const{ if(isNull()) return -1; return m_poCam->unit; } icl32s DCDevice::getUnitSpecID() const{ if(isNull()) return -1; return m_poCam->unit_spec_ID; } void DCDevice::setMode(const Mode &mode){ // {{{ open ICLASSERT_RETURN( !isNull() ); dc1394error_t err = dc1394_video_set_mode(m_poCam,mode.videomode); ICLASSERT_RETURN( err == DC1394_SUCCESS ); err = dc1394_video_set_framerate(m_poCam,mode.framerate); ICLASSERT_RETURN( err == DC1394_SUCCESS ); } // }}} void DCDevice::show(const string &title) const{ // {{{ open printf("DCDevice: %s \n",title.c_str()); if(isNull()){ printf("null! \n"); }else{ dc1394_camera_print_info(m_poCam,stdout); printf("-----------------------------\n"); printf("supported modes: \n"); vector v = getModes(); for(unsigned int i=0;i DCDevice::getFeatures() const{ // {{{ open const vector &v = getListOfAllFeatures(); vector supported; for(unsigned int i=0;i &toks = s.allTokens(); ICLASSERT(toks.size() == 2); videomode = dc::videomode_from_string(toks[0]); framerate = dc::framerate_from_string(toks[1]); } // }}} string DCDevice::Mode::toString() const{ // {{{ open return dc::to_string(videomode)+"@"+dc::to_string(framerate); } // }}} bool DCDevice::Mode::supportedBy(dc1394camera_t *cam) const{ // {{{ open dc1394video_modes_t modeList; dc1394_video_get_supported_modes(cam,&modeList); for(unsigned int i=0;i