Camera.hpp
Go to the documentation of this file.
00001 /*=============================================================================
00002   Copyright (C) 2012 - 2016 Allied Vision Technologies.  All Rights Reserved.
00003 
00004   Redistribution of this file, in original or modified form, without
00005   prior written consent of Allied Vision Technologies is prohibited.
00006 
00007 -------------------------------------------------------------------------------
00008 
00009   File:        Camera.hpp
00010 
00011   Description: Inline wrapper functions for class AVT::VmbAPI::Camera.
00012                (This include file is for internal use only.)
00013 
00014 -------------------------------------------------------------------------------
00015 
00016   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
00017   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
00018   NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  PURPOSE ARE
00019   DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
00020   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00021   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  
00023   AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
00024   TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00025   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 =============================================================================*/
00028 
00029 #ifndef AVT_VMBAPI_CAMERA_HPP
00030 #define AVT_VMBAPI_CAMERA_HPP
00031 
00032 //
00033 // Inline wrapper functions that allocate memory for STL objects in the application's context
00034 // and to pass data across DLL boundaries using arrays
00035 //
00036 
00037 // HINT: This information remains static throughout the object's lifetime
00038 inline VmbErrorType Camera::GetID( std::string &rStrID ) const
00039 {
00040     VmbErrorType    res;
00041     VmbUint32_t     nLength;
00042 
00043     res = GetID( NULL, nLength );
00044     if ( VmbErrorSuccess == res )
00045     {
00046         if ( 0 != nLength )
00047         {
00048             try
00049             {
00050                 std::vector<std::string::value_type>tmpID( nLength + 1,'\0');
00051                 res = GetID( &tmpID[0], nLength );
00052                 if( VmbErrorSuccess == res)
00053                 {
00054                     rStrID  = &*tmpID.begin();
00055                 }
00056             }
00057             catch(...)
00058             {
00059                 res = VmbErrorResources;
00060             }
00061         }
00062         else
00063         {
00064             rStrID.clear();
00065         }
00066     }
00067 
00068     return res;
00069 }
00070 
00071 // HINT: This information remains static throughout the object's lifetime
00072 inline VmbErrorType Camera::GetName( std::string &rStrName ) const
00073 {
00074     VmbErrorType res;
00075     VmbUint32_t nLength;
00076 
00077     res = GetName( NULL, nLength );
00078     if ( VmbErrorSuccess == res )
00079     {
00080         if( 0 != nLength)
00081         {
00082             try
00083             {
00084                 std::vector<std::string::value_type> tmpName( nLength + 1,'\0' );
00085                 res  = GetName( &tmpName[0], nLength );
00086                 if( VmbErrorSuccess == res)
00087                 {
00088                     rStrName    = &*tmpName.begin();
00089                 }
00090             }
00091             catch(...)
00092             {
00093                 res = VmbErrorResources;
00094             }
00095         }
00096         else
00097         {
00098             rStrName.clear();
00099         }
00100     }
00101 
00102     return res;
00103 }
00104 
00105 // HINT: This information remains static throughout the object's lifetime
00106 inline VmbErrorType Camera::GetModel( std::string &rStrModel ) const
00107 {
00108     VmbErrorType res;
00109     VmbUint32_t nLength;
00110 
00111     res = GetModel( NULL, nLength );
00112     if ( VmbErrorSuccess == res )
00113     {
00114         if( 0 != nLength)
00115         {
00116             try
00117             {
00118                 std::vector<std::string::value_type> tmpModel( nLength + 1,'\0');
00119                 res = GetModel( &tmpModel[0], nLength );
00120                 if( VmbErrorSuccess == res )
00121                 {
00122                     rStrModel   = &*tmpModel.begin();
00123                 }
00124             }
00125             catch(...)
00126             {
00127                 res = VmbErrorResources;
00128             }
00129         }
00130         else
00131         {
00132             rStrModel.clear();
00133         }
00134     }
00135 
00136     return res;
00137 }
00138 
00139 // HINT: This information remains static throughout the object's lifetime
00140 inline VmbErrorType Camera::GetSerialNumber( std::string &rStrSerial ) const
00141 {
00142     VmbErrorType    res;
00143     VmbUint32_t     nLength;
00144 
00145     res = GetSerialNumber( NULL, nLength );
00146     if ( VmbErrorSuccess == res )
00147     {
00148         if ( 0 != nLength )
00149         {
00150             try
00151             {
00152                 std::vector<std::string::value_type> tmpSerial( nLength + 1,'\0');
00153                 res = GetSerialNumber( &tmpSerial[0], nLength );
00154                 if( VmbErrorSuccess == res )
00155                 {
00156                     rStrSerial  = &*tmpSerial.begin();
00157                 }
00158             }
00159             catch(...)
00160             {
00161                 res = VmbErrorResources;
00162             }
00163         }
00164         else
00165         {
00166             rStrSerial.clear();
00167         }
00168     }
00169 
00170     return res;
00171 }
00172 
00173 // HINT: This information remains static throughout the object's lifetime
00174 inline VmbErrorType Camera::GetInterfaceID( std::string &rStrInterfaceID ) const
00175 {
00176     VmbErrorType res;
00177     VmbUint32_t nLength;
00178 
00179     res = GetInterfaceID( NULL, nLength );
00180     if ( VmbErrorSuccess == res )
00181     {
00182         if ( 0 != nLength )
00183         {
00184             try
00185             {
00186                 std::vector<std::string::value_type> tmpID( nLength + 1,'\0');
00187                 res = GetInterfaceID( &tmpID[0], nLength );
00188                 if( VmbErrorSuccess == res )
00189                 {
00190                     rStrInterfaceID = &*tmpID.begin();
00191                 }
00192             }
00193             catch(...)
00194             {
00195                 res = VmbErrorResources;
00196             }
00197         }
00198         else
00199         {
00200             rStrInterfaceID.clear();
00201         }
00202     }
00203 
00204     return res;
00205 }
00206 
00207 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout )
00208 {
00209     VmbErrorType res;
00210     VmbUint32_t i;
00211     res = AcquireMultipleImages( rFrames, nTimeout, i );
00212     if ( rFrames.size() != i )
00213     {
00214         res = VmbErrorInternalFault;
00215     }
00216     
00217     return res;
00218 }
00219 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout, VmbUint32_t &rNumFramesCompleted )
00220 {
00221     if ( true == rFrames.empty() )
00222     {
00223         return VmbErrorBadParameter;
00224     }
00225 
00226     return AcquireMultipleImages( &rFrames[0], (VmbUint32_t)rFrames.size(), nTimeout, &rNumFramesCompleted );
00227 }
00228 
00229 // HINT: Size of address determines how many registers to read. Size of data has to be large enough to hold the requested information
00230 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer ) const
00231 {
00232     VmbUint32_t i;
00233     return ReadRegisters( rAddresses, rBuffer, i );
00234 }
00235 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer, VmbUint32_t &rCompletedReads ) const
00236 {
00237     if (    true == rAddresses.empty()
00238          || true == rBuffer.empty()
00239          || rAddresses.size() > rBuffer.size() )
00240     {
00241         return VmbErrorBadParameter;
00242     }
00243     return ReadRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedReads );
00244 }        
00245 
00246 // HINT: Size of address determines how many registers to write.
00247 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer )
00248 {
00249     VmbUint32_t i;
00250     return WriteRegisters( rAddresses, rBuffer, i );
00251 }
00252 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer, VmbUint32_t &rCompletedWrites )
00253 {
00254     if (    true == rAddresses.empty()
00255          || true == rBuffer.empty()
00256          || rAddresses.size() != rBuffer.size() )
00257     {
00258         return VmbErrorBadParameter;
00259     }
00260 
00261     return WriteRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedWrites );
00262 }
00263 
00264 // HINT: Size of buffer determines how many bytes to read.
00265 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer ) const
00266 {
00267     VmbUint32_t i;
00268     return ReadMemory( rAddress, rBuffer, i );
00269 }
00270 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer, VmbUint32_t &rCompletedReads ) const
00271 {
00272     if ( true == rBuffer.empty() )
00273     {
00274         return VmbErrorBadParameter;
00275     }
00276 
00277     return ReadMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedReads );
00278 }
00279 
00280 // HINT: Size of buffer determines how many bytes to write.
00281 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer )
00282 {
00283     VmbUint32_t i;
00284     return WriteMemory( rAddress, rBuffer, i );
00285 }
00286 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer, VmbUint32_t &rCompletedWrites )
00287 {
00288     if ( true == rBuffer.empty() )
00289     {
00290         return VmbErrorBadParameter;
00291     }
00292 
00293     return WriteMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedWrites );
00294 }
00295 
00296 inline VmbErrorType Camera::SaveCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
00297 {
00298     VmbErrorType err = VmbErrorSuccess;
00299 
00300 //  parameter check
00301     if( true == strFileName.empty() )
00302     {
00303         return VmbErrorBadParameter;
00304     }
00305 
00306 //  check internal settings struct variables
00307     VmbBool_t useInternalStruct = true;
00308     if( false == ((0 <= m_persistType) && (3 > m_persistType)) )
00309     {
00310         useInternalStruct = false;
00311     }
00312     if( false == ((0 < m_maxIterations) && (10 > m_maxIterations)) )
00313     {
00314         useInternalStruct = false;
00315     }
00316     if( false == ((0 < m_loggingLevel) && (5 > m_loggingLevel)) )
00317     {
00318         useInternalStruct = false;
00319     }
00320 
00321 //  check if internal struct shall be used
00322     if( VmbBoolTrue == useInternalStruct )
00323     {
00324         VmbFeaturePersistSettings_t newSettings;
00325         newSettings.persistType = m_persistType;
00326         newSettings.maxIterations = m_maxIterations;
00327         newSettings.loggingLevel = m_loggingLevel;
00328         err = SaveCameraSettings( strFileName.c_str(), &newSettings );
00329     }
00330     else
00331     {
00332         err = SaveCameraSettings( strFileName.c_str(), pSettings );
00333     }
00334 
00335     return err;
00336 }
00337 
00338 inline VmbErrorType Camera::LoadCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
00339 {
00340     VmbErrorType err = VmbErrorSuccess;
00341 
00342 //  parameter check
00343     if( true == strFileName.empty() )
00344     {
00345         return VmbErrorBadParameter;
00346     }
00347 
00348 //  check internal settings struct variables
00349     VmbBool_t useInternalStruct = true;
00350     if( false == ((0 <= m_persistType) && (3 > m_persistType)) )
00351     {
00352         useInternalStruct = false;
00353     }
00354     if( false == ((0 < m_maxIterations) && (10 > m_maxIterations)) )
00355     {
00356         useInternalStruct = false;
00357     }
00358     if( false == ((0 < m_loggingLevel) && (5 > m_loggingLevel)) )
00359     {
00360         useInternalStruct = false;
00361     }
00362 
00363 //  check if internal struct shall be used
00364     if( VmbBoolTrue == useInternalStruct )
00365     {
00366         VmbFeaturePersistSettings_t newSettings;
00367         newSettings.persistType = m_persistType;
00368         newSettings.maxIterations = m_maxIterations;
00369         newSettings.loggingLevel = m_loggingLevel;
00370         err = LoadCameraSettings( strFileName.c_str(), &newSettings );
00371     }
00372     else
00373     {
00374         err = LoadCameraSettings( strFileName.c_str(), pSettings );
00375     }
00376 
00377     return err;
00378 }
00379 
00380 #endif


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Thu Jun 6 2019 18:23:39