Spinnaker SDK C++
4.2.0.21
 
 

 
Loading...
Searching...
No Matches

The base class for the camera object. More...

#include <CameraBase.h>

Inheritance diagram for CameraBase:
ICameraBase Camera

Public Member Functions

virtual ~CameraBase (void)
 Virtual Destructor.
 
void Init ()
 Init Connects to camera with read and write access, retrieves remote device and GUI XML and generates node map references.
 
void DeInit ()
 DeInit Disconnects camera port, resets camera back to read access and frees GenICam node map and GUI XML.
 
bool IsInitialized ()
 IsInitialized Checks if camera is initialized.
 
bool IsValid ()
 IsValid Checks a flag to determine if camera is still valid for use.
 
GenApi::INodeMapGetNodeMap () const
 GetNodeMap Gets a reference to the node map that is generated from a GenICam XML file.
 
GenApi::INodeMapGetTLDeviceNodeMap () const
 GetTLDeviceNodeMap Gets a reference to the node map that is generated from a GenICam XML file for the GenTL Device module.
 
GenApi::INodeMapGetTLStreamNodeMap (uint64_t streamIndex=0) const
 GetTLStreamNodeMap Gets a reference to the node map that is generated from a GenICam XML file for the GenTL Stream module.
 
GenApi::EAccessMode GetAccessMode () const
 GetAccessMode Returns the access mode that the software has on the Camera.
 
void ReadPort (uint64_t iAddress, void *pBuffer, size_t iSize)
 ReadPort Reads a remote port on a physical Camera.
 
void WritePort (uint64_t iAddress, const void *pBuffer, size_t iSize)
 WritePort Writes a remote port on a physical Camera.
 
void BeginAcquisition ()
 BeginAcquisition Starts the image acquisition engine.
 
void EndAcquisition ()
 EndAcquisition Stops the image acquisition engine.
 
BufferOwnership GetBufferOwnership () const
 GetBufferOwnership Gets data buffer ownership.
 
void SetBufferOwnership (const BufferOwnership mode)
 SetBufferOwnership Sets data buffer ownership.
 
uint64_t GetUserBufferCount () const
 GetUserBufferCount Gets the number of user memory buffers.
 
uint64_t GetUserBufferSize () const
 GetUserBufferSize Gets the size of one user memory buffer (in bytes).
 
uint64_t GetUserBufferTotalSize () const
 GetUserBufferTotalSize Gets the total size of all the user memory buffers (in bytes).
 
void SetUserBuffers (void *const pMemBuffers, uint64_t totalSize)
 SetUserBuffers Specify contiguous user allocated memory to use as data buffers.
 
void SetUserBuffers (void **const ppMemBuffers, const uint64_t bufferCount, const uint64_t bufferSize)
 SetUserBuffers Specify non-contiguous user allocated memory to use as data buffers.
 
ImagePtr GetNextImage (uint64_t grabTimeout=EVENT_TIMEOUT_INFINITE, uint64_t streamIndex=0)
 GetNextImage Gets the next image that was received by the transport layer.
 
ImageList GetNextImageSync (uint64_t grabTimeout=EVENT_TIMEOUT_INFINITE)
 GetNextImageSync If a camera supports one or more streams, this function gets one image from each of the camera's streams, and returns the image(s) in a list.
 
GenICam::gcstring GetDeviceID ()
 GetDeviceID This returns a unique id string that identifies the camera; a unique string for USB devices, and MAC address for GEV devices.
 
 DEPRECATED_FUNC ("Use GetDeviceID() instead.", GenICam::gcstring GetUniqueID();)
 GetUniqueID This returns a unique id string that identifies the camera.
 
bool IsStreaming () const
 IsStreaming Returns true if the camera is currently streaming or false if it is not.
 
GenICam::gcstring GetGuiXml () const
 GetGuiXml Returns the GUI XML that can be passed into the Spinnaker GUI framework.
 
void RegisterEventHandler (EventHandler &evtHandlerToRegister)
 RegisterEventHandler(EventHandler &) Registers a generic device, image or image list event handler for the camera.
 
void RegisterEventHandler (DeviceEventHandler &evtHandlerToRegister, const GenICam::gcstring &eventName)
 RegisterEventHandler(DeviceEventHandler &, const GenICam::gcstring &) Registers a specific device event handler for the camera given a device event name.
 
void RegisterEventHandler (ImageEventHandler &evtHandlerToRegister, uint64_t streamIndex)
 RegisterEventHandler(ImageEventHandler &, uint64_t) Registers a specific stream handler for the camera given a stream index.
 
void UnregisterEventHandler (EventHandler &evtHandlerToUnregister)
 UnregisterEventHandler Unregisters any type of event handler for the camera.
 
unsigned int GetNumImagesInUse ()
 GetNumImagesInUse Returns the number of images that are currently in use.
 
unsigned int GetActiveNumDataStreams ()
 GetActiveNumDataStreams Returns the number of data streams that are currently active.
 
unsigned int GetNumDataStreams ()
 GetNumDataStreams Returns the total number of streams that the device supports.
 
unsigned int DiscoverMaxPacketSize ()
 DiscoverMaxPacketSize Returns the largest packet size that can be safely used on the interface that device is connected to.
 
void ForceIP ()
 ForceIP Forces the camera to be on the same subnet as its corresponding interface.
 
- Public Member Functions inherited from ICameraBase
virtual ~ICameraBase (void)
 
virtual void Init ()=0
 
virtual void DeInit ()=0
 
virtual bool IsInitialized ()=0
 
virtual bool IsValid ()=0
 
virtual GenApi::INodeMapGetNodeMap () const =0
 
virtual GenApi::INodeMapGetTLDeviceNodeMap () const =0
 
virtual GenApi::INodeMapGetTLStreamNodeMap (uint64_t streamIndex) const =0
 
virtual GenApi::EAccessMode GetAccessMode () const =0
 
virtual void ReadPort (uint64_t iAddress, void *pBuffer, size_t iSize)=0
 
virtual void WritePort (uint64_t iAddress, const void *pBuffer, size_t iSize)=0
 
virtual void BeginAcquisition ()=0
 
virtual void EndAcquisition ()=0
 
virtual BufferOwnership GetBufferOwnership () const =0
 
virtual void SetBufferOwnership (const BufferOwnership mode)=0
 
virtual uint64_t GetUserBufferCount () const =0
 
virtual uint64_t GetUserBufferSize () const =0
 
virtual uint64_t GetUserBufferTotalSize () const =0
 
virtual void SetUserBuffers (void *const pMemBuffers, uint64_t totalSize)=0
 
virtual void SetUserBuffers (void **const ppMemBuffers, const uint64_t bufferCount, const uint64_t bufferSize)=0
 
virtual ImagePtr GetNextImage (uint64_t grabTimeout=EVENT_TIMEOUT_INFINITE, uint64_t streamIndex=0)=0
 
virtual GenICam::gcstring GetDeviceID ()=0
 
virtual GenICam::gcstring GetUniqueID ()=0
 
virtual bool IsStreaming () const =0
 
virtual GenICam::gcstring GetGuiXml () const =0
 
virtual void RegisterEventHandler (EventHandler &evtHandlerToRegister)=0
 
virtual void RegisterEventHandler (DeviceEventHandler &evtHandlerToRegister, const GenICam::gcstring &eventName)=0
 
virtual void RegisterEventHandler (ImageEventHandler &evtHandlerToRegister, uint64_t streamIndex)=0
 
virtual void UnregisterEventHandler (EventHandler &evtHandlerToUnregister)=0
 
virtual unsigned int GetNumImagesInUse ()=0
 
virtual unsigned int GetActiveNumDataStreams ()=0
 
virtual unsigned int GetNumDataStreams ()=0
 
virtual unsigned int DiscoverMaxPacketSize ()=0
 
virtual void ForceIP ()=0
 

Protected Member Functions

 CameraBase (void)
 Default constructor.
 
 CameraBase (const CameraBase &)
 Copy constructor.
 
CameraBaseoperator= (const CameraBase &)
 Assignment operator.
 
- Protected Member Functions inherited from ICameraBase
 ICameraBase ()
 
 ICameraBase (const ICameraBase &)
 
ICameraBaseoperator= (const ICameraBase &)
 

Friends

class InterfaceImpl
 

Additional Inherited Members

- Public Attributes inherited from ICameraBase
TransportLayerDevice TLDevice
 Gets vital camera information by connecting to the camera's bootstrap registers.
 
TransportLayerStream TLStream
 Gets information about the stream data by connecting to the camera's bootstrap registers.
 
- Protected Attributes inherited from ICameraBase
CameraBaseData * m_pCameraBaseData
 

Detailed Description

The base class for the camera object.

Constructor & Destructor Documentation

◆ ~CameraBase()

virtual ~CameraBase ( void  )
virtual

Virtual Destructor.

◆ CameraBase() [1/2]

CameraBase ( void  )
protected

Default constructor.

◆ CameraBase() [2/2]

CameraBase ( const CameraBase )
protected

Copy constructor.

Member Function Documentation

◆ BeginAcquisition()

void BeginAcquisition ( )
virtual

BeginAcquisition Starts the image acquisition engine.

The camera must be initialized via a call to Init() before starting an acquisition.

Note that an error SPINNAKER_ERR_NOT_IMPLEMENTED will be thrown if an unsupported combination of stream mode and buffer ownership is set.

See also
Init()

Implements ICameraBase.

◆ DeInit()

void DeInit ( )
virtual

DeInit Disconnects camera port, resets camera back to read access and frees GenICam node map and GUI XML.

Do not call more functions that access the remote device such as WritePort/ReadPort after calling DeInit(). Events should also be unregistered before calling camera DeInit(). Otherwise an exception will be thrown in the DeInit() call and require the user to unregister events before the camera can be re-initialized again.

See also
Init()
UnregisterEventHandler(EventHandler & evtHandlerToUnregister)

Implements ICameraBase.

◆ DEPRECATED_FUNC()

DEPRECATED_FUNC ( "Use GetDeviceID() instead."  ,
GenICam::gcstring GetUniqueID();   
)

GetUniqueID This returns a unique id string that identifies the camera.

Returns
string that uniquely identifies the camera

◆ DiscoverMaxPacketSize()

unsigned int DiscoverMaxPacketSize ( )
virtual

DiscoverMaxPacketSize Returns the largest packet size that can be safely used on the interface that device is connected to.

Returns
The maximum packet size returned.

Implements ICameraBase.

◆ EndAcquisition()

void EndAcquisition ( )
virtual

EndAcquisition Stops the image acquisition engine.

If EndAcquisition() is called without a prior call to BeginAcquisition() an error message "Camera is not started" will be thrown. All Images that were acquired using GetNextImage() or GetNextImageSync() need to be released first using image->Release() or imageList->Release() before calling EndAcquisition(). All buffers in the input pool and output queue will be discarded when EndAcquisition() is called.

See also
Init()
BeginAcquisition()
GetNextImage( grabTimeout )
GetNextImageSync( grabTimeout )
Image::Release()

Implements ICameraBase.

◆ ForceIP()

void ForceIP ( )
virtual

ForceIP Forces the camera to be on the same subnet as its corresponding interface.

Implements ICameraBase.

◆ GetAccessMode()

GenApi::EAccessMode GetAccessMode ( ) const
virtual

GetAccessMode Returns the access mode that the software has on the Camera.

The camera does not need to be initialized before calling this function.

See also
Init()
Returns
An enumeration value indicating the access mode

Implements ICameraBase.

◆ GetActiveNumDataStreams()

unsigned int GetActiveNumDataStreams ( )
virtual

GetActiveNumDataStreams Returns the number of data streams that are currently active.

Returns
The number of active data streams

Implements ICameraBase.

◆ GetBufferOwnership()

BufferOwnership GetBufferOwnership ( ) const
virtual

GetBufferOwnership Gets data buffer ownership.

The data buffers can be owned by System or User. If the system owns the buffers, the memory required for the buffers are allocated and freed by the library. If user owns the buffers, the user is responsible for allocating and ultimately freeing the memory. By default, data buffers are owned by the System.

See also
SetBufferOwnership()
SetUserBuffers()
Returns
Buffer ownership

Implements ICameraBase.

◆ GetDeviceID()

GenICam::gcstring GetDeviceID ( )
virtual

GetDeviceID This returns a unique id string that identifies the camera; a unique string for USB devices, and MAC address for GEV devices.

Returns
string that uniquely identifies the camera

Implements ICameraBase.

◆ GetGuiXml()

GenICam::gcstring GetGuiXml ( ) const
virtual

GetGuiXml Returns the GUI XML that can be passed into the Spinnaker GUI framework.

Returns
GenICam::gcstring that represents the uncompressed GUI XML file

Implements ICameraBase.

◆ GetNextImage()

ImagePtr GetNextImage ( uint64_t  grabTimeout = EVENT_TIMEOUT_INFINITE,
uint64_t  streamIndex = 0 
)
virtual

GetNextImage Gets the next image that was received by the transport layer.

This function will block for the specified timeout period until an image arrives. Most cameras support one stream so the default streamIndex is 0, but if a camera supports multiple streams the user can input the streamIndex to select from which stream to grab images.

See also
Init()
BeginAcquisition()
EndAcquisition()
Parameters
grabTimeoutA 64bit value that represents a timeout in milliseconds
streamIndexThe index of the stream to grab the image from
Returns
pointer to an Image object

Implements ICameraBase.

◆ GetNextImageSync()

ImageList GetNextImageSync ( uint64_t  grabTimeout = EVENT_TIMEOUT_INFINITE)

GetNextImageSync If a camera supports one or more streams, this function gets one image from each of the camera's streams, and returns the image(s) in a list.

This function will block for the specified timeout period until an image arrives on all the streams.

Note: This function should not be used together with GetNextImage. Results will be undeterministic and could lead to missing or lost of images.

See also
Init()
BeginAcquisition()
EndAcquisition()
Parameters
grabTimeoutA 64bit value that represents a timeout in milliseconds
Returns
a list containing the Image objects

◆ GetNodeMap()

GenApi::INodeMap & GetNodeMap ( ) const
virtual

GetNodeMap Gets a reference to the node map that is generated from a GenICam XML file.

The camera must be initialized by a call to Init() first before a node map reference can be successfully acquired.

See also
Init()
Returns
A reference to the INodeMap.

Implements ICameraBase.

◆ GetNumDataStreams()

unsigned int GetNumDataStreams ( )
virtual

GetNumDataStreams Returns the total number of streams that the device supports.

For configurable multistream cameras, use GetActiveNumDataStreams() to get the number of active streams.

See also
GetActiveNumDataStreams()
Returns
The total number of data streams

Implements ICameraBase.

◆ GetNumImagesInUse()

unsigned int GetNumImagesInUse ( )
virtual

GetNumImagesInUse Returns the number of images that are currently in use.

Each of the images that are currently in use must be cleaned up with a call to image->Release() before calling system->ReleaseInstance().

Returns
The number of images that needs to be cleaned up.

Implements ICameraBase.

◆ GetTLDeviceNodeMap()

GenApi::INodeMap & GetTLDeviceNodeMap ( ) const
virtual

GetTLDeviceNodeMap Gets a reference to the node map that is generated from a GenICam XML file for the GenTL Device module.

The camera does not need to be initialized before acquiring this node map.

Returns
A reference to the INodeMap.

Implements ICameraBase.

◆ GetTLStreamNodeMap()

GenApi::INodeMap & GetTLStreamNodeMap ( uint64_t  streamIndex = 0) const
virtual

GetTLStreamNodeMap Gets a reference to the node map that is generated from a GenICam XML file for the GenTL Stream module.

The camera does not need to be initialized before acquiring this node map.

Parameters
streamIndexThe index of the stream to grab the image from
Returns
A reference to the INodeMap.

Implements ICameraBase.

◆ GetUserBufferCount()

uint64_t GetUserBufferCount ( ) const
virtual

GetUserBufferCount Gets the number of user memory buffers.

This will throw an exception if user memory buffer has not been set. If the user memory is contiguous, this will throw an exception unless BeginAcquisition() has been called.

See also
BeginAcquisition()
SetUserBuffers()
Returns
The number of user memory buffers

Implements ICameraBase.

◆ GetUserBufferSize()

uint64_t GetUserBufferSize ( ) const
virtual

GetUserBufferSize Gets the size of one user memory buffer (in bytes).

This will throw an exception if user memory buffer has not been set. If the user memory is contiguous, this will throw an exception unless BeginAcquisition() has been called. To prevent image tearing when working with USB3 cameras, the size of each buffer should be equal to: ((unsigned int) (bufferSize + 1024 - 1) / 1024) * 1024 where 1024 is the USB3 packet size.

See also
BeginAcquisition()
SetUserBuffers()
Returns
The size of one user memory buffer (in bytes)

Implements ICameraBase.

◆ GetUserBufferTotalSize()

uint64_t GetUserBufferTotalSize ( ) const
virtual

GetUserBufferTotalSize Gets the total size of all the user memory buffers (in bytes).

This will throw an exception if user memory buffer has not been set. The total size should be GetUserBufferSize() multiplied by GetUserBufferCount() or larger.

See also
GetUserBufferCount()
GetUserBufferSize()
SetUserBuffers()
Returns
The total size of all the user memory buffers (in bytes)

Implements ICameraBase.

◆ Init()

void Init ( )
virtual

Init Connects to camera with read and write access, retrieves remote device and GUI XML and generates node map references.

This function needs to be called before any camera related API calls such as BeginAcquisition(), EndAcquisition(), GetNodeMap(), GetNextImage() and GetNextImageSync().

See also
BeginAcquisition()
EndAcquisition()
GetNodeMap()
GetNextImage()
GetNextImageSync()

Implements ICameraBase.

◆ IsInitialized()

bool IsInitialized ( )
virtual

IsInitialized Checks if camera is initialized.

This function needs to return true in order to retrieve a valid NodeMap from the GetNodeMap() call.

See also
GetNodeMap()
Returns
If camera is initialized or not

Implements ICameraBase.

◆ IsStreaming()

bool IsStreaming ( ) const
virtual

IsStreaming Returns true if the camera is currently streaming or false if it is not.

See also
Init()
Returns
returns true if camera is streaming and false otherwise.

Implements ICameraBase.

◆ IsValid()

bool IsValid ( )
virtual

IsValid Checks a flag to determine if camera is still valid for use.

Returns
If camera is valid or not

Implements ICameraBase.

◆ operator=()

CameraBase & operator= ( const CameraBase )
protected

Assignment operator.

◆ ReadPort()

void ReadPort ( uint64_t  iAddress,
void *  pBuffer,
size_t  iSize 
)
virtual

ReadPort Reads a remote port on a physical Camera.

This function can be used to read registers on Cameras.

Caution: Only perform direct read/write to a register if the register isn't supported in the device nodemap. Otherwise the camera and nodemap may be left in an undefined state after the register read/write.

See also
WritePort()
Parameters
iAddressA 64 bit address to a register on the camera
pBufferA pointer to a data buffer that will store result
iSizeNumber of bytes to read

Implements ICameraBase.

◆ RegisterEventHandler() [1/3]

void RegisterEventHandler ( DeviceEventHandler evtHandlerToRegister,
const GenICam::gcstring eventName 
)
virtual

RegisterEventHandler(DeviceEventHandler &, const GenICam::gcstring &) Registers a specific device event handler for the camera given a device event name.

The camera has to be initialized first with a call to Init() before registering handlers for events.

See also
Init()
UnregisterEventHandler()
Parameters
evtHandlerToRegisterThe event handler to register for the camera
eventNameThe event name to register

Implements ICameraBase.

◆ RegisterEventHandler() [2/3]

void RegisterEventHandler ( EventHandler evtHandlerToRegister)
virtual

RegisterEventHandler(EventHandler &) Registers a generic device, image or image list event handler for the camera.

The camera has to be initialized first with a call to Init() before registering handlers for events.

See also
Init()
UnregisterEventHandler()
DeviceEventHandler
ImageEventHandler
ImageListEventHandler
Parameters
evtHandlerToRegisterThe event handler to register for the camera

Implements ICameraBase.

◆ RegisterEventHandler() [3/3]

void RegisterEventHandler ( ImageEventHandler evtHandlerToRegister,
uint64_t  streamIndex 
)
virtual

RegisterEventHandler(ImageEventHandler &, uint64_t) Registers a specific stream handler for the camera given a stream index.

The camera has to be initialized first with a call to Init() before registering handlers for events.

See also
Init()
UnregisterEventHandler()
Parameters
evtHandlerToRegisterThe event handler to register for the camera
streamIndexThe index of the stream of where this handler will be registered to

Implements ICameraBase.

◆ SetBufferOwnership()

void SetBufferOwnership ( const BufferOwnership  mode)
virtual

SetBufferOwnership Sets data buffer ownership.

The data buffers can be owned by System or User. If the system owns the buffers, the memory required for the buffers are allocated and freed by the library. If user owns the buffers, the user is responsible for allocating and ultimately freeing the memory. By default, data buffers are owned by the library.

Note that an error SPINNAKER_ERR_NOT_IMPLEMENTED will be thrown during BeginAcquisition() if an unsupported combination of stream mode and buffer ownership is set.

See also
GetBufferOwnership()
SetUserBuffers()
Parameters
modeBuffer ownership to set

Implements ICameraBase.

◆ SetUserBuffers() [1/2]

void SetUserBuffers ( void **const  ppMemBuffers,
const uint64_t  bufferCount,
const uint64_t  bufferSize 
)
virtual

SetUserBuffers Specify non-contiguous user allocated memory to use as data buffers.

Each pointer to a buffer must have enough memory to hold one image. To prevent image tearing when working with USB3 cameras, the size of each buffer should be equal to: ((unsigned int) (bufferSize + 1024 - 1) / 1024) * 1024 where 1024 is the USB3 packet size.

See also
GetBufferOwnership()
SetBufferOwnership()
GetUserBufferCount()
GetUserBufferSize()
GetUserBufferTotalSize()
Parameters
ppMemBuffersPointer to pointers that each point to a single user memory buffer to be written to
bufferCountThe number of user memory buffers
bufferSizeThe size of the memory allocated for each user buffer (in bytes)

Implements ICameraBase.

◆ SetUserBuffers() [2/2]

void SetUserBuffers ( void *const  pMemBuffers,
uint64_t  totalSize 
)
virtual

SetUserBuffers Specify contiguous user allocated memory to use as data buffers.

To prevent image tearing when working with USB3 cameras, the size of each buffer should be equal to: ((unsigned int) (bufferSize + 1024 - 1) / 1024) * 1024 where 1024 is the USB3 packet size.

When working with GigE cameras, allocate memory and set at least 2 buffers for OldestFirst and NewestFirst stream modes, and 3 buffers for OldestFirstOverwrite and NewestOnly modes

Note that an error SPINNAKER_ERR_NOT_IMPLEMENTED will be thrown during BeginAcquisition() if an unsupported combination of stream mode and buffer ownership is set.

See also
GetBufferOwnership()
SetBufferOwnership()
GetUserBufferCount()
GetUserBufferSize()
GetUserBufferTotalSize()
Parameters
pMemBuffersPointer to memory buffers to be written to
totalSizeThe total size of the memory allocated for the user buffers (in bytes)

Implements ICameraBase.

◆ UnregisterEventHandler()

void UnregisterEventHandler ( EventHandler evtHandlerToUnregister)
virtual

UnregisterEventHandler Unregisters any type of event handler for the camera.

Event handlers should be unregistered first before calling camera DeInit(). Otherwise an exception will be thrown in the DeInit() call and require the user to unregister event handlers before the camera can be re-initialized again.

See also
DeInit()
RegisterEventHandler()
Parameters
evtHandlerToUnregisterThe event handler to unregister from the camera

Implements ICameraBase.

◆ WritePort()

void WritePort ( uint64_t  iAddress,
const void *  pBuffer,
size_t  iSize 
)
virtual

WritePort Writes a remote port on a physical Camera.

This function can be used to write registers on Cameras.

Caution: Only perform direct read/write to a register if the register isn't supported in the device nodemap. Otherwise the camera and nodemap may be left in an undefined state after the register read/write.

See also
ReadPort()
Parameters
iAddressA 64 bit address to a register on the camera
pBufferA pointer to a data buffer that will be written
iSizeNumber of bytes to write

Implements ICameraBase.

Friends And Related Symbol Documentation

◆ InterfaceImpl

friend class InterfaceImpl
friend

The documentation for this class was generated from the following file: