Skip to content

pylon/InstantCamera.h#

Contains a camera class establishing convenient access to a camera device.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CInstantCamera
Provides convenient access to a camera device.

Source code#

//------------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2010-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  Andreas Gau
//------------------------------------------------------------------------------
#ifndef INCLUDED_INSTANTCAMERA_H_08725703
#define INCLUDED_INSTANTCAMERA_H_08725703

#include <pylon/Platform.h>

#ifdef _MSC_VER
#   pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */

#include <pylon/stdinclude.h>
#include <pylon/PylonBase.h>
#include <pylon/ImageEventHandler.h>
#include <pylon/ConfigurationEventHandler.h>
#include <pylon/CameraEventHandler.h>
#include <pylon/BufferFactory.h>
#include <pylon/GrabResultPtr.h>
#include <pylon/DeviceInfo.h>
#include <pylon/WaitObject.h>
#include <pylon/Device.h>
#include <pylon/SfncVersion.h>

#include <pylon/ECleanup.h>
#include <pylon/ERegistrationMode.h>
#include <pylon/ETimeoutHandling.h>



namespace Pylon
{
    class IInstantCameraExtensions;
}

#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class.
#endif

#include <pylon/_InstantCameraParams.h>

namespace Pylon
{
    enum EGrabStrategy
    {
        GrabStrategy_OneByOne,        

        GrabStrategy_LatestImageOnly, 

        GrabStrategy_LatestImages,    

        GrabStrategy_UpcomingImage    
    };


    enum EGrabLoop
    {
        GrabLoop_ProvidedByInstantCamera, 
        GrabLoop_ProvidedByUser           
    };


    enum ECameraEventAvailability
    {
        CameraEventAvailability_Mandatory,   
        CameraEventAvailability_Optional     
    };


    class PYLONBASE_API CInstantCamera : public Basler_InstantCameraParams::CInstantCameraParams_Params
    {
    public:
        //Creation and life time------------------------------------------------

        CInstantCamera();


        CInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete );


        virtual ~CInstantCamera();


        virtual void Attach( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete );


        virtual bool IsPylonDeviceAttached() const;


        virtual bool IsCameraDeviceRemoved() const;


        virtual bool HasOwnership() const;


        virtual void DestroyDevice();


        virtual IPylonDevice* DetachDevice();


        //Control opening and closing of the device-----------------------------

        virtual void Open();


        virtual bool IsOpen() const;


        virtual void Close();


        //Grab -----------------------------------------------------------------

        virtual void StartGrabbing( EGrabStrategy strategy = GrabStrategy_OneByOne, EGrabLoop grabLoopType = GrabLoop_ProvidedByUser );


        virtual void StartGrabbing( size_t maxImages, EGrabStrategy strategy = GrabStrategy_OneByOne, EGrabLoop grabLoopType = GrabLoop_ProvidedByUser );


        virtual bool RetrieveResult( unsigned int timeoutMs, CGrabResultPtr& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException );


        virtual void StopGrabbing();


        virtual bool IsGrabbing() const;


        virtual bool GrabOne( unsigned int timeoutMs, CGrabResultPtr& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException );


        virtual size_t GetQueuedBufferCount();


        virtual const WaitObject& GetGrabResultWaitObject();


        virtual const WaitObject& GetGrabStopWaitObject();


        virtual const WaitObject& GetCameraEventWaitObject();


        //Event handling--------------------------------------------------------

        virtual void RegisterConfiguration( CConfigurationEventHandler* pConfigurator, ERegistrationMode mode, ECleanup cleanupProcedure );


        virtual bool DeregisterConfiguration( CConfigurationEventHandler* configurator );


        virtual void RegisterImageEventHandler( CImageEventHandler* pImageEventHandler, ERegistrationMode mode, ECleanup cleanupProcedure );


        virtual bool DeregisterImageEventHandler( CImageEventHandler* imageEventHandler );


        virtual void RegisterCameraEventHandler(
            CCameraEventHandler* pCameraEventHandler,
            const String_t& nodeName,
            intptr_t userProvidedId,
            ERegistrationMode mode,
            ECleanup cleanupProcedure,
            ECameraEventAvailability availability = CameraEventAvailability_Mandatory );


        virtual bool DeregisterCameraEventHandler( CCameraEventHandler* cameraEventHandler, const String_t& nodeName );



        //Additional features---------------------------------------------------

        virtual bool WaitForFrameTriggerReady( unsigned int timeoutMs, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException );


        virtual bool CanWaitForFrameTriggerReady() const;


        virtual void ExecuteSoftwareTrigger();


        virtual void SetCameraContext( intptr_t context );


        virtual intptr_t GetCameraContext() const;


        virtual const CDeviceInfo& GetDeviceInfo() const;


        virtual GenApi::INodeMap& GetNodeMap();


        virtual GenApi::INodeMap& GetTLNodeMap();


        virtual GenApi::INodeMap& GetStreamGrabberNodeMap();


        virtual GenApi::INodeMap& GetEventGrabberNodeMap();


        virtual GenApi::INodeMap& GetInstantCameraNodeMap();


        virtual void SetBufferFactory( IBufferFactory* pFactory, ECleanup cleanupProcedure = Cleanup_Delete );


        virtual bool Is1394() const;


        virtual bool IsGigE() const;


        virtual bool IsUsb() const;


        virtual bool IsCameraLink() const;


        virtual bool IsCxp() const;


        VersionInfo GetSfncVersion() const;


        //Types used by camera--------------------------------------------------

        typedef CInstantCamera InstantCamera_t;
        typedef IPylonDevice IPylonDevice_t;
        typedef Pylon::CDeviceInfo DeviceInfo_t;
        typedef CConfigurationEventHandler ConfigurationEventHandler_t;
        typedef CImageEventHandler ImageEventHandler_t;
        typedef CCameraEventHandler CameraEventHandler_t;
        typedef CGrabResultData GrabResultData_t;
        typedef CGrabResultPtr GrabResultPtr_t;

    protected:

        virtual IPylonDevice* GetDevice();


        CLock& GetLock();


        /*
        \brief Returns a reference to the empty node map.

        The empty node map can be used by device specific camera classes.
        The pointer to the empty node map does not change during the lifetime of the camera object.

        \return Reference to the empty node map.

        \error
            Does not throw C++ exceptions.

        \threading
            This method is synchronized using the lock provided by GetLock().
        */
        GenApi::INodeMap& GetEmptyNodeMap();


        // Internal use only. Subject to change without notice.
        void InternalRegisterConfiguration( CConfigurationEventHandler*, ERegistrationMode, ECleanup, const long* );
        // Internal use only. Subject to change without notice.
        void InternalRegisterImageEventHandler( CImageEventHandler*, ERegistrationMode, ECleanup, const long* );
        // Internal use only. Subject to change without notice.
        void InternalRegisterCameraEventHandler( CCameraEventHandler*, const String_t&, intptr_t, ERegistrationMode, ECleanup, ECameraEventAvailability, const long* );
        // Internal use only. Subject to change without notice.
        bool InternalDeregisterConfiguration( const long* );
        // Internal use only. Subject to change without notice.
        bool InternalDeregisterImageEventHandler( const long* );
        // Internal use only. Subject to change without notice.
        bool InternalDeregisterCameraEventHandler( const long*, const String_t& );
        // Internal use only. Subject to change without notice.
        void InternalShutdownEventHandlers();

    public:
        // Internal use only. Subject to change without notice.
        IInstantCameraExtensions& GetExtensionInterface();
    private:
        // The camera object can not be copied.
        CInstantCamera( const CInstantCamera& );
        // The camera object can not be copied.
        void operator = ( const CInstantCamera& );

        class CInstantCameraImpl;
        CInstantCameraImpl* m_pImpl;

    protected:
        // Internal use only. Subject to change without notice.
        friend class CGrabResultDataFactory;
        // Internal use only. Subject to change without notice.
        virtual CGrabResultData* CreateDeviceSpecificGrabResultData();
    private:
        // Internal use only. Subject to change without notice.
        CGrabResultData* CreateGrabResultData();
    };

}
#ifdef _MSC_VER
#pragma warning( pop )
#endif

#ifdef _MSC_VER
#   pragma pack(pop)
#endif /* _MSC_VER */

#endif /* INCLUDED_INSTANTCAMERA_H_08725703 */

Updated on 5 July 2022 at 15:30:01