WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
Public Types | Public Member Functions | List of all members
USB3Camera Class Reference

This class is the implementation of IWPOCTCamera. More...

#include <USB3Camera.h>

Inheritance diagram for USB3Camera:
Inheritance graph
[legend]
Collaboration diagram for USB3Camera:
Collaboration graph
[legend]

Public Types

enum  RegisterAddress {
  ScanWidth = 0x12004 , ScanHeight = 0x4F00000C , LinePeriod = 0x12100 , ExposureTime = 0x12108 ,
  TriggerMode = 0x1210C , TriggerFrameLineNumber = 0x12128
}
 Camera register.
 
- Public Types inherited from IWPOCTCamera
enum  ErrorCode {
  NoError = 0 , InitializeLibraryError = 1 , ShutdownLibraryError = 2 , UpdateCameraListError = 3 ,
  GetCameraInfoError = 4 , OpenCameraError = 5 , CloseCameraError = 6 , MemoryAllocationError = 7 ,
  ProcessingError = 8 , ReadParameterError = 9 , SetParameterError = 10 , StartAcquiringError = 11 ,
  StopAcquiringError = 12 , GetBufferError = 13 , BufferCompletedWithZeros = 14 , AbortGetBufferError = 15 ,
  RequeueBufferError = 16 , FlushBufferError = 17 , TimeoutError = 18 , CameraFileError = 19 ,
  DongleNotFound = 20 , NumErrors = 21 , DLLExpired = 22 , NoError = 0 ,
  InitializeLibraryError = 1 , ShutdownLibraryError = 2 , UpdateCameraListError = 3 , GetCameraInfoError = 4 ,
  OpenCameraError = 5 , CloseCameraError = 6 , MemoryAllocationError = 7 , ProcessingError = 8 ,
  ReadParameterError = 9 , SetParameterError = 10 , StartAcquiringError = 11 , StopAcquiringError = 12 ,
  GetBufferError = 13 , BufferCompletedWithZeros = 14 , AbortGetBufferError = 15 , RequeueBufferError = 16 ,
  FlushBufferError = 17 , TimeoutError = 18 , CameraFileError = 19 , DongleNotFound = 20 ,
  NumErrors = 21 , DLLExpired = 22
}
 The following are error codes that are used within the camera. More...
 
enum  CameraType {
  NoCamera = 0 , USB3 = 1 , CameraLink = 2 , NI1433 = 3 ,
  NumCameras = 4 , NoCamera = 0 , USB3 = 1 , CameraLink = 2 ,
  NI1433 = 3 , NumCameras = 4
}
 The following are the camera types that are used in GetOCTCamera and GetCameraType. More...
 
enum  CurrentStates {
  Idle = 0 , LibraryInitialized = 1 , CameraOpened = 2 , ParametersSet = 4 ,
  CameraAcquiring = 8 , Idle = 0 , LibraryInitialized = 1 , CameraOpened = 2 ,
  ParametersSet = 4 , CameraAcquiring = 8
}
 Current states of the camera (more than one can be active) The following are status codes that are used within the camera. More...
 
enum class  ErrorCode {
  NoError = 0 , InitializeLibraryError = 1 , ShutdownLibraryError = 2 , UpdateCameraListError = 3 ,
  GetCameraInfoError = 4 , OpenCameraError = 5 , CloseCameraError = 6 , MemoryAllocationError = 7 ,
  ProcessingError = 8 , ReadParameterError = 9 , SetParameterError = 10 , StartAcquiringError = 11 ,
  StopAcquiringError = 12 , GetBufferError = 13 , BufferCompletedWithZeros = 14 , AbortGetBufferError = 15 ,
  RequeueBufferError = 16 , FlushBufferError = 17 , TimeoutError = 18 , CameraFileError = 19 ,
  DongleNotFound = 20 , NumErrors = 21 , DLLExpired = 22 , NoError = 0 ,
  InitializeLibraryError = 1 , ShutdownLibraryError = 2 , UpdateCameraListError = 3 , GetCameraInfoError = 4 ,
  OpenCameraError = 5 , CloseCameraError = 6 , MemoryAllocationError = 7 , ProcessingError = 8 ,
  ReadParameterError = 9 , SetParameterError = 10 , StartAcquiringError = 11 , StopAcquiringError = 12 ,
  GetBufferError = 13 , BufferCompletedWithZeros = 14 , AbortGetBufferError = 15 , RequeueBufferError = 16 ,
  FlushBufferError = 17 , TimeoutError = 18 , CameraFileError = 19 , DongleNotFound = 20 ,
  NumErrors = 21 , DLLExpired = 22
}
 
enum class  CameraType {
  NoCamera = 0 , USB3 = 1 , CameraLink = 2 , NI1433 = 3 ,
  NumCameras = 4 , NoCamera = 0 , USB3 = 1 , CameraLink = 2 ,
  NI1433 = 3 , NumCameras = 4
}
 
enum class  CurrentStates {
  Idle = 0 , LibraryInitialized = 1 , CameraOpened = 2 , ParametersSet = 4 ,
  CameraAcquiring = 8 , Idle = 0 , LibraryInitialized = 1 , CameraOpened = 2 ,
  ParametersSet = 4 , CameraAcquiring = 8
}
 

Public Member Functions

 USB3Camera ()
 Constructor.
 
virtual ~USB3Camera ()
 Destructor.
 
float GetLinePeriod () const override
 Get the period between lines.
 
float GetExposureTime () const override
 Get the exposure time.
 
int GetTriggerMode () const override
 Get the trigger mode.
 
int GetTriggerFrameLineNum () const
 Get the trigger frame line trigger count.
 
int GetCameraWidth () const override
 Get the width of the camera in pixels.
 
int GetNumCameras () const override
 Get the number of cameras in system.
 
const char * GetCameraID (int index=0) override
 Get the camera ID string (260 chars max).
 
int GetNumBitsInPixel () const override
 Get the size of a pixel in bits.
 
int GetNumBytesInPixel () const override
 Get the size of a padded pixel in bytes.
 
bool SetLinePeriod (float value) override
 Set the period between lines.
 
bool SetExposureTime (float value) override
 Set the exposure time.
 
bool SetTriggerMode (int value) override
 Set the trigger mode.
 
bool SetTriggerFrameLineNum (int value)
 Set the trigger frame line count, which determines how many triggers are sent when in trigger mode 6 or 7.
 
bool SetScanHeight (int value) override
 Set scan height.
 
bool InitializeLibrary () override
 Initializes the library.
 
bool ShutDownLibrary () override
 Shuts down the camera library. More...
 
bool Open (const char *id) override
 This uses the camera's S/N.
 
bool Open (int id=0) override
 This uses a 0 or 1 and only works for USB cameras.
 
bool Close () override
 Closes the camera opened with the Open command. More...
 
bool ReadParameter (unsigned int address, unsigned int *value) const override
 Reads a parameter or register from the camera and returns the value in the value argument. More...
 
bool WriteParameter (unsigned int address, unsigned int value) override
 Writes a parameter or register to the camera with the value supplied. More...
 
bool SetParameters () override
 Sets the height of the camera buffers and the number of buffers based on values entered with SetScanHeight and SetNumBuffers. More...
 
bool SetParameters (int height, int numBuffers) override
 Sets the height of the camera buffers and the number of buffers that the camera can use. More...
 
bool StartAcquiring () override
 Starts the camera acquiring frames of data. More...
 
bool StopAcquiring (bool flushBuffers) override
 Stops the camera data acquisition. More...
 
bool GetBuffer (void **buffer) override
 Gets a buffer from the camera. More...
 
bool GetBuffer2 (unsigned short **buffer) override
 Gets a camera buffer and returns the pointer to the buffer. More...
 
bool GetBufferCopy (unsigned short *buffer) override
 Gets a camera buffer and copies it into the buffer supplied. More...
 
bool GetBufferAndIndex (void **buffer, int **index, unsigned long *frameNumber) override
 Gets a buffer from the camera. More...
 
bool GetBufferAndIndex2 (unsigned short **buffer, int **index, unsigned long *frameNumber) override
 Gets a camera buffer and returns a void pointer to the buffer. More...
 
bool AbortGetBuffer () override
 Cancel the GetBuffer call. More...
 
bool RequeueBuffer () override
 Requeues the most recent camera buffer obtained so it can be used again. More...
 
bool RequeueBuffer (int *bufferHandle) override
 Requeues the camera buffer pointed to by the bufferHandle so it can be used again. More...
 
bool FlushBuffers () override
 Flushes all camera buffers so they can be used by the camera for acquisition. More...
 
bool ResetDevice () override
 Reset camera.
 
- Public Member Functions inherited from WPCamera
 WPCamera ()
 Constructor.
 
virtual ~WPCamera ()
 Destructor.
 
bool IsInitialized () const override
 Is the camera library initialized?
 
bool IsOpened () const override
 Is the camera opened?
 
bool IsAcquiring () const override
 Is the camera currently acquiring?
 
bool AreParametersSet () const override
 Are camera parameters set?
 
IWPOCTCamera::ErrorCode GetLastError () const override
 Gets the result of the most current operation.
 
IWPOCTCamera::CurrentStates GetCurrentState () const override
 Gets the current status of the camera. More...
 
int GetScanWidth () const override
 Get the width of an image.
 
int GetScanHeight () const override
 Get the height of an image.
 
bool GetScanWidthAndHeight (int *width, int *height) const override
 Get the width and height of a scan.
 
int GetNumBuffers () const override
 Get the number of image buffers.
 
int GetLinesLost () const override
 Get the number of lines lost in the last frame.
 
int GetTriggersMissed () const override
 Get the number of triggers missed in the last frame.
 
long long GetImageSize () const
 Get the size of an image.
 
int GetCameraType () const override
 Get the camera type.
 
int GetAcquisitionTimeout () const override
 Get the acquisition timeout in milliseconds.
 
int GetResourceIndex () const override
 Get the resource index of the frame grabber.
 
const char * GetCameraFileName () const override
 Get the name of the camera configuration file.
 
bool SetScanHeight (int value) override
 Set the height of an image.
 
bool SetNumBuffers (int value) override
 Set the number of image buffers.
 
bool SetCameraFileName (const char *name) override
 Set the name of the camera configuration file.
 
bool SetAcquisitionTimeout (int value) override
 Set the acquisition timeout in milliseconds.
 
bool SetResourceIndex (int value) override
 Set the resource index of the frame grabber.
 
bool AcquireFramesWriteToDisk (const char *baseFilePath, int numFrames, bool keepMemoryAllocated) override
 Write consecutive image acquisitions to memory. When finished write all to disk. More...
 
bool AcquireWriteFramesToMemory (unsigned short **data, int numFrames) override
 Write consecutive image acquisitions to memory pointed to by data supplied by this dll.
 
bool AcquireWriteFramesToMemory (unsigned short *data, int numFrames) override
 Write consecutive image acquisitions to memory pointed to by data supplied by the application.
 
- Public Member Functions inherited from IWPOCTCamera
virtual void Dispose ()
 
virtual bool IsInitialized ()
 
virtual bool IsOpened ()
 
virtual bool AreParametersSet ()
 
virtual bool IsAcquiring ()
 
virtual int GetScanWidth ()
 
virtual int GetScanHeight ()
 
virtual bool GetScanWidthAndHeight (ref int width, ref int height)
 
virtual int GetCameraWidth ()
 
virtual int GetNumCameras ()
 
virtual int GetNumBuffers ()
 
virtual int GetLinesLost ()
 
virtual int GetTriggersMissed ()
 
virtual float GetLinePeriod ()
 
virtual float GetExposureTime ()
 
virtual int GetTriggerMode ()
 
virtual int GetCameraType ()
 
virtual int GetNumBitsInPixel ()
 
virtual int GetNumBytesInPixel ()
 
virtual int GetAcquisitionTimeout ()
 
virtual int GetResourceIndex ()
 
virtual string GetCameraFileName ()
 
virtual bool SetCameraFileName (string name)
 
virtual bool Open (string id)
 
virtual bool ReadParameter (uint address, ref uint value)
 
virtual bool WriteParameter (uint address, uint value)
 
virtual bool GetBuffer (ref global::System.IntPtr buffer)
 
virtual bool GetBuffer2 (ref global::System.IntPtr buffer)
 
unsafe bool GetBufferCopy (ushort[] buffer)
 
virtual bool GetBufferAndIndex (ref global::System.IntPtr buffer, ref global::System.IntPtr index, ref ulong frameNumber)
 
virtual bool GetBufferAndIndex2 (ref global::System.IntPtr buffer, ref global::System.IntPtr index, ref ulong frameNumber)
 
virtual bool RequeueBuffer (ref int bufferHandle)
 
virtual bool AcquireFramesWriteToDisk (string baseFilePath, int numFrames, bool keepMemoryAllocated)
 
unsafe bool AcquireWriteFramesToMemory (ref global::System.IntPtr data, int numFrames)
 
unsafe bool AcquireWriteFramesToMemory (ushort[] data, int numFrames)
 
virtual IWPOCTCamera.ErrorCode GetLastError ()
 
virtual IWPOCTCamera.CurrentStates GetCurrentState ()
 

Additional Inherited Members

- Static Public Member Functions inherited from IWPOCTCamera
static IWPOCTCamera GetOCTCamera (IWPOCTCamera.CameraType cameraType)
 
static IWPOCTCamera.ErrorCode GetLastAttemptError ()
 
static bool DestroyOCTCamera (IWPOCTCamera camera)
 
static bool DestroyOCTCamera ()
 
- Protected Member Functions inherited from WPCamera
virtual bool DeleteResources ()
 
void OutputDebugMsg (const wchar_t *str) const
 
void OutputDebugMsg (const char *str) const
 
string FormSeriesBaseFileName (const char *baseFilePath)
 
string FormSeriesFinalFileName (size_t index, const char *extension)
 
string GetFilledDigits (int number, int totalDigits)
 Gets the string prefixed with zeros so the string is a certain length. More...
 
- Static Protected Member Functions inherited from WPCamera
template<typename T >
static bool SaveMemoryToBinFile (const char *fname, long long size, const T *data)
 
- Protected Attributes inherited from WPCamera
int _id
 
unsigned int _scanWidth
 The width of an scan.
 
unsigned int _scanHeight
 The height of an scan.
 
std::atomic< ErrorCode_lastError
 The most recent error code.
 
std::atomic< CurrentStates_currentState
 
int _numBuffers
 
std::atomic< int > _linesLost
 
std::atomic< int > _triggersMissed
 
std::atomic< int > _acquisitionTimeout
 
std::atomic< bool > _acquiringSeries
 
std::atomic< bool > _abortAcquisition
 
std::atomic< long > _dongleVal
 Dongle check return value.
 
int _resourceIndex
 
CameraType _cameraType
 
vector< unsigned short > _acquisitionData
 
std::string _cameraFileName
 
std::string _seriesBaseFileName
 
- Protected Attributes inherited from IWPOCTCamera
bool swigCMemOwn
 

Detailed Description

This class is the implementation of IWPOCTCamera.

Member Function Documentation

◆ AbortGetBuffer()

bool USB3Camera::AbortGetBuffer ( )
overridevirtual

Cancel the GetBuffer call.

Returns
true on success

Implements IWPOCTCamera.

◆ Close()

bool USB3Camera::Close ( )
overridevirtual

Closes the camera opened with the Open command.

This call should be made after the StopAcquiring API is called.

Returns
true if successful

Implements IWPOCTCamera.

◆ FlushBuffers()

bool USB3Camera::FlushBuffers ( )
overridevirtual

Flushes all camera buffers so they can be used by the camera for acquisition.

This call is only needed by USB cameras when acquiring is stopped. Alternatively, the flushBuffer flag can be set to true in StopAcquiring to get the same effect.

Often called after StopAcquiring is called.

Returns
true on success

Implements IWPOCTCamera.

◆ GetBuffer()

bool USB3Camera::GetBuffer ( void **  buffer)
overridevirtual

Gets a buffer from the camera.

Parameters
bufferThe pointer to the data.
Returns
bool - true if successful

Implements IWPOCTCamera.

◆ GetBuffer2()

bool USB3Camera::GetBuffer2 ( unsigned short **  buffer)
overridevirtual

Gets a camera buffer and returns the pointer to the buffer.

This call will wait until a buffer is filled before returning. If the timeout period is reached before the buffer is filled, the call returns with a false return value.

Parameters
buffer[out]pointer to an unsigned short pointer that holds the location of the start of the camera buffer.
Note
Use this if the app is single-threaded.
Returns
true on success

Implements IWPOCTCamera.

◆ GetBufferAndIndex()

bool USB3Camera::GetBufferAndIndex ( void **  buffer,
int **  index,
unsigned long *  frameNumber 
)
overridevirtual

Gets a buffer from the camera.

Also returns the index of the buffer.

Parameters
bufferThe pointer to the data.
indexThe buffer index.
frameNumberThe frame number captured since the camera started acquiring.
Returns
bool - true if successful

Implements IWPOCTCamera.

◆ GetBufferAndIndex2()

bool USB3Camera::GetBufferAndIndex2 ( unsigned short **  buffer,
int **  index,
unsigned long *  frameNumber 
)
overridevirtual

Gets a camera buffer and returns a void pointer to the buffer.

The index associated with the buffer is also returned. This index is used with USB cameras to requeue the buffer specified. The frameNumber is a number that counts up as successive frames are returned. It can be used to assure the frames are put in the correct order. GetBufferAndIndex will wait until a buffer is filled before returning. If the timeout period is reached before the buffer is filled, the call returns with a false return value.

Parameters
buffer[out]pointer to an unsigned short pointer that holds the location of the start of the camera buffer.
index[out]pointer to an int pointer that holds the index of the camera buffer.
frameNumber[out]pointer to the frame number returned. This value counts up from zero when acquisition is started.
Returns
true on success

Implements IWPOCTCamera.

◆ GetBufferCopy()

bool USB3Camera::GetBufferCopy ( unsigned short *  buffer)
overridevirtual

Gets a camera buffer and copies it into the buffer supplied.

This call will wait until a buffer is filled before returning. If the timeout period is reached before the buffer is filled, the call returns with a false return value. Note that the RequeueBuffer API does not need to be called after calling this API.

Parameters
buffer[out]void pointer to a buffer that will have the camera buffer data copied to it.
Returns
true on success

Implements IWPOCTCamera.

◆ ReadParameter()

bool USB3Camera::ReadParameter ( unsigned int  address,
unsigned int *  value 
) const
overridevirtual

Reads a parameter or register from the camera and returns the value in the value argument.


Note
This call is only valid for USB cameras.
Parameters
address[in]the location where the parameter is stored.
value[out]pointer to int that contains the value of the register once the call returns.
See also
manual "UMA_OCTOPLUS-USB3_Mono_RevB5.pdf" for more information.
Returns
true if successful

Implements IWPOCTCamera.

◆ RequeueBuffer() [1/2]

bool USB3Camera::RequeueBuffer ( )
overridevirtual

Requeues the most recent camera buffer obtained so it can be used again.

This call is used for USB cameras where only a single thread is used to acquire camera data. CameraLink frame grabbers do not need to call this API. Used with GetBuffer().

Returns
true on success

Implements IWPOCTCamera.

◆ RequeueBuffer() [2/2]

bool USB3Camera::RequeueBuffer ( int *  bufferHandle)
overridevirtual

Requeues the camera buffer pointed to by the bufferHandle so it can be used again.

This call is used for USB cameras where multi-threading is used to acquire camera data. CameraLink frame grabbers do not need to call this API. Used with GetBufferAndIndex().

Parameters
bufferHandle[in]the buffer handle obtained in the GetBufferAndIndex call.
Returns
true on success

Implements IWPOCTCamera.

◆ SetParameters() [1/2]

bool USB3Camera::SetParameters ( )
overridevirtual

Sets the height of the camera buffers and the number of buffers based on values entered with SetScanHeight and SetNumBuffers.

Returns
true if successful

Implements IWPOCTCamera.

◆ SetParameters() [2/2]

bool USB3Camera::SetParameters ( int  height,
int  numBuffers 
)
overridevirtual

Sets the height of the camera buffers and the number of buffers that the camera can use.


Parameters
height[in]the height (number of line scans) of a camera buffer.
numBuffers[in]the number of buffers available to the camera.
Minimum value could be 2 but in reality should be between 10 and
  1. While buffers are being processed by the application they are unavailable to the camera, so the number of buffers must be large enough to ensure the camera does not run out of buffers.
Returns
true if successful

Implements IWPOCTCamera.

◆ ShutDownLibrary()

bool USB3Camera::ShutDownLibrary ( )
overridevirtual

Shuts down the camera library.

This should be the last step before deleting the camera object.

Returns
true if successful

Implements IWPOCTCamera.

◆ StartAcquiring()

bool USB3Camera::StartAcquiring ( )
overridevirtual

Starts the camera acquiring frames of data.

Returns
true if successful

Implements IWPOCTCamera.

◆ StopAcquiring()

bool USB3Camera::StopAcquiring ( bool  flushBuffers)
overridevirtual

Stops the camera data acquisition.

Parameters
flushBuffers[in]flag on whether to flush buffers after acquiring has stopped. This flag is only used by OctoPlus USB3 cameras.

Implements IWPOCTCamera.

◆ WriteParameter()

bool USB3Camera::WriteParameter ( unsigned int  address,
unsigned int  value 
)
overridevirtual

Writes a parameter or register to the camera with the value supplied.


Note
This call is only valid for USB cameras.
Parameters
address[in]the location where the parameter is stored.
value[in]int that contains the value of the register to be written.
See also
manual "UMA_OCTOPLUS-USB3_Mono_RevB5.pdf" for more information.
Returns
true if successful

Implements IWPOCTCamera.


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