Dynamsoft Panorama - API Reference
Protected Attributes | List of all members
CPanoramaStitcher Class Reference

Public Member Functions

 CPanoramaStitcher ()
 
 ~CPanoramaStitcher ()
 
Initialization Functions
int InitLicense (const char *pLicense)
 
int InitLicenseFromServer (const char *pLicenseServer, const char *pLicenseKey)
 
int InitLicenseFromLicenseContent (const char *pLicenseKey, const char *pLicenseContent)
 
int OutputLicenseToStringPtr (char **content)
 
void FreeLicenseString (char **content)
 
Stitching Functions
int StartPanoramaStitchingByFile ()
 
int StartPanoramaStitchingByBuffer (int iWidth, int iHeight, int iStride, DPS_ImagePixelFormat format)
 
int AppendNewFrameByFile (const char *pFileName)
 
int AppendNewFrameByBuffer (const unsigned char *pBuffer)
 
void WaitForFinishStitching ()
 
void StopPanoramaStitching ()
 
Basic Setting Functions
int GetRuntimeSettings (DPS_RuntimeSettings *pSettings)
 
int UpdateRuntimeSettings (DPS_RuntimeSettings *pSettings, char error[], int errorMsgBufferLen)
 
Advanced Setting Functions
int InitRuntimeSettingsWithString (const char *pJsonSetting, char error[], int errorMsgBufferLen)
 
int OutputSettingsToStringPtr (char **content)
 
void FreeSettingsString (char **content)
 
Callback Functions
int SetResultCallback (CB_PanoramaResult cbFunction, void *pUser)
 
int SetErrorCodeCallback (CB_PanoramaErrorCode cbFunction, void *pUser)
 

Static Public Member Functions

General Functions
static const char * GetErrorString (const int iErrorCode)
 
static const char * GetVersion ()
 

Protected Attributes

DM_Panorama * m_pStitcher
 

Result Functions

int GetFinalResults (PanoramaResultArray **pResult)
 
int GetRunningState (RunningState *pRunningState)
 
static void FreePanoramaResults (PanoramaResultArray **pPresults)
 

Detailed Description

Defines a class that provides functions for working with image stitching and barcode data extracting.

Constructor & Destructor Documentation

◆ CPanoramaStitcher()

CPanoramaStitcher::CPanoramaStitcher ( )

Default constructor

◆ ~CPanoramaStitcher()

CPanoramaStitcher::~CPanoramaStitcher ( )

Destructor

Member Function Documentation

◆ AppendNewFrameByBuffer()

int CPanoramaStitcher::AppendNewFrameByBuffer ( const unsigned char *  pBuffer)

Appends a new frame image buffer from a file to the inner frame queue.

Parameters
[in]pBufferThe array of bytes which contain the image data.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.Possible returns are: DPS_OK; DPSERR_PANORAMA_NOT_STARTED; DPSERR_PANORAMA_STARTED_BY_FILE; DPSERR_NO_MEMORY; DPSERR_OVERLAP_MODE_STITCH_STOPED;
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
delete panorama;
Remarks:
StartPanoramaStitchingByBuffer() has to be successfully called before calling this method.
The size of the incoming image should be the same as the image size declared in StartPanoramaStitchingByBuffer().

◆ AppendNewFrameByFile()

int CPanoramaStitcher::AppendNewFrameByFile ( const char *  pFileName)

Appends a new frame from a file to the inner frame queue.

Parameters
[in]pFileNameA string defining the file name.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.Possible returns are: DPS_OK; DPSERR_PANORAMA_NOT_STARTED; DPSERR_PANORAMA_STARTED_BY_BUFFER; DPSERR_NO_MEMORY; DPSERR_OVERLAP_MODE_STITCH_STOPED;
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByFile();
panorama->AppendNewFrameByFile("C:\\Users\\*****\\1.jpg");
delete panorama;
Remarks:
StartPanoramaStitchingByFile() has to be successfully called before calling this method.
The size of the incoming image should be the same.

◆ FreeLicenseString()

void CPanoramaStitcher::FreeLicenseString ( char **  content)

Frees memory allocated for the license string.

Parameters
[in]contentThe output string which stores the content of license.
Remarks:
OutputLicenseToStringPtr() has to be successfully called before calling this method.

◆ FreePanoramaResults()

static void CPanoramaStitcher::FreePanoramaResults ( PanoramaResultArray **  pPresults)
static

Frees memory allocated for stitched image and panorama result.

Parameters
[in]pPresultsThe struct of Panorama result array.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
panorama->GetFinalResults(&pResult);
delete panorama;

◆ FreeSettingsString()

void CPanoramaStitcher::FreeSettingsString ( char **  content)

Frees memory allocated for runtime settings string.

Parameters
[in]contentThe runtime settings string.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
char error[256];
panorama->InitRuntimeSettingsWithString("{\"PreviewImgScaleRatio\": 0.25, \"ResultImgScaleRatio\":1}", error, 256);
char* pContent = NULL;
panorama->OutputSettingsToStringPtr(&pContent);
panorama->FreeSettingsString(&pContent);
delete panorama;

◆ GetErrorString()

static const char* CPanoramaStitcher::GetErrorString ( const int  iErrorCode)
static

Returns the error info string.

Parameters
[in]iErrorCodeThe error code.
Returns
The error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int errorCode = panorama->StartPanoramaStitchingByFile();
const char* errorString = CPanoramaStitcher::GetErrorString(errorCode);
delete panorama;

◆ GetFinalResults()

int CPanoramaStitcher::GetFinalResults ( PanoramaResultArray **  pResult)

Gets the image and barcodes results.

Parameters
[in,out]pResultThe output panorama result array.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
panorama->GetFinalResults(&pResult);
delete panorama;
Remarks:
StopPanoramaStitching() has to be successfully called before calling this method.

◆ GetRunningState()

int CPanoramaStitcher::GetRunningState ( RunningState pRunningState)

Gets running state of Panorama program.

Parameters
[in,out]pRunningStateThe struct of running state.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call DPS_GetErrorString() to get detailed error message.Possible returns are: DPS_OK; DPSERR_INPUT_NULL_POINTER;
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
RunningState* pRunningState = new RunningState();
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
panorama->GetRunningState(pRunningState);
delete pRunningState;
delete panorama;

◆ GetRuntimeSettings()

int CPanoramaStitcher::GetRuntimeSettings ( DPS_RuntimeSettings pSettings)

Gets current settings and saves them into a struct.

Parameters
[in,out]pSettingsThe struct of template settings.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
panorama->GetRuntimeSettings(pSettings);
delete pSettings;
delete panorama;

◆ GetVersion()

static const char* CPanoramaStitcher::GetVersion ( )
static

Returns the version info of the SDK.

Returns
The version info string.
Code Snippet:
const char* versionInfo = CPanoramaStitcher::GetVersion();

◆ InitLicense()

int CPanoramaStitcher::InitLicense ( const char *  pLicense)

Reads product key and activates the SDK.

Parameters
[in]pLicenseThe product keys.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
delete panorama;

◆ InitLicenseFromLicenseContent()

int CPanoramaStitcher::InitLicenseFromLicenseContent ( const char *  pLicenseKey,
const char *  pLicenseContent 
)

Initializes the license from the license content on the client-side for offline verification.

Parameters
[in]pLicenseKeyThe license key.
[in]pLicenseContentAn encrypted string representing the license content (quota, expiration date, barcode type, etc.) obtained from the method OutputLicenseToStringPtr().
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.

◆ InitLicenseFromServer()

int CPanoramaStitcher::InitLicenseFromServer ( const char *  pLicenseServer,
const char *  pLicenseKey 
)

Initializes the license and connections to the specified server for online verification.

Parameters
[in]pLicenseServerThe URL of the license server.
[in]pLicenseKeyThe license key.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.

◆ InitRuntimeSettingsWithString()

int CPanoramaStitcher::InitRuntimeSettingsWithString ( const char *  pJsonSetting,
char  error[],
int  errorMsgBufferLen 
)

Initializes Panorama settings with the parameters obtained from a JSON string.

Parameters
[in]pJsonSettingA JSON string that represents the content of the settings.
[in,out]errorThe buffer is allocated by caller and the recommending length is 256. The error message will be copied to the buffer.
[in]errorMsgBufferLenThe length of allocated buffer.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
char error[256];
panorama->InitRuntimeSettingsWithString("{\"PreviewImgScaleRatio\": 0.25, \"ResultImgScaleRatio\":1}", error, 256);
delete panorama;

◆ OutputLicenseToStringPtr()

int CPanoramaStitcher::OutputLicenseToStringPtr ( char **  content)

Outputs the license content as an encrypted string from the license server to be used for offline license verification.

Parameters
[in,out]contentThe output string which stores the content of license.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Remarks:
InitLicenseFromServer() has to be successfully called before calling this method.

◆ OutputSettingsToStringPtr()

int CPanoramaStitcher::OutputSettingsToStringPtr ( char **  content)

Outputs runtime settings to a string.

Parameters
[in,out]contentThe output string which stores the contents of current settings.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
char error[256];
panorama->InitRuntimeSettingsWithString("{\"PreviewImgScaleRatio\": 0.25, \"ResultImgScaleRatio\":1}", error, 256);
char* pContent = NULL;
panorama->OutputSettingsToStringPtr(&pContent);
panorama->FreeSettingsString(&pContent);
delete panorama;
Remarks:
Changing the parameter value in the output string and calling InitRuntimeSettingsWithString is also one of ways to init runtime settings.

◆ SetErrorCodeCallback()

int CPanoramaStitcher::SetErrorCodeCallback ( CB_PanoramaErrorCode  cbFunction,
void *  pUser 
)

Sets callback function to process errors generated during image stitching.

Parameters
[in]cbFunctionCallback function.
[in]pUserCustomized arguments passed to your function.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message. Possible returns are: DPS_OK; DPSERR_ERROR_CALLBACK_EXISTS;
Code Snippet:
void ErrorFunction(int errorCode, void * pUser)
{
//TODO add your code for using error code
}
panorama->SetErrorCodeCallback(ErrorFunction, NULL);
delete panorama;

◆ SetResultCallback()

int CPanoramaStitcher::SetResultCallback ( CB_PanoramaResult  cbFunction,
void *  pUser 
)

Sets callback function to process panorama result, including stitched image and barcodes.

Parameters
[in]cbFunctionCallback function.
[in]pUserCustomized arguments passed to your function.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message. Possible returns are: DPS_OK; DPSERR_RESULT_CALLBACK_EXISTS;
Code Snippet:
void ResultFunction(PanoramaResultArray** pResult, void * pUser)
{
//TODO add your code for using panorama result
}
panorama->SetResultCallback(ResultFunction, NULL);
delete panorama;

◆ StartPanoramaStitchingByBuffer()

int CPanoramaStitcher::StartPanoramaStitchingByBuffer ( int  iWidth,
int  iHeight,
int  iStride,
DPS_ImagePixelFormat  format 
)

Starts threads to manage images reading from buffer, this function should be used with AppendNewFrameByBuffer Function.

Parameters
[in]iWidthThe width of the frame image in pixels.
[in]iHeightThe height of the frame image in pixels.
[in]iStrideThe stride (or scan width) of the frame image.
[in]formatThe image pixel format used in the image byte array.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.Possible returns are: DPS_OK; DPSERR_PANORAMA_ALREADY_STARTED;
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
delete panorama;

◆ StartPanoramaStitchingByFile()

int CPanoramaStitcher::StartPanoramaStitchingByFile ( )

Starts threads to manage images reading from file, this function should be used with AppendNewFrameByFile Function.

Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.Possible returns are: DPS_OK; DPSERR_PANORAMA_ALREADY_STARTED;
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByFile();
panorama->AppendNewFrameByFile("C:\\Users\\*****\\1.jpg");
delete panorama;

◆ StopPanoramaStitching()

void CPanoramaStitcher::StopPanoramaStitching ( )

Stops stitching immediately, avoid stitching the remaining frames in the inner frame queue.

Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
delete panorama;

◆ UpdateRuntimeSettings()

int CPanoramaStitcher::UpdateRuntimeSettings ( DPS_RuntimeSettings pSettings,
char  error[],
int  errorMsgBufferLen 
)

Updates runtime settings with a given struct.

Parameters
[in]pSettingsThe struct of template settings.
[in,out]errorThe buffer is allocated by caller and the recommended length is 256.The error message will be copied to the buffer.
[in]errorMsgBufferLenThe length of the allocated buffer.
Returns
Returns error code. Returns 0 if the function operates successfully. You can call GetErrorString() to get detailed error message.
Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
panorama->GetRuntimeSettings(pSettings);
pSettings->stitchingAccuracyLevel = 0;
char error[256];
panorama->UpdateRuntimeSettings(pSettings, error, 256)
delete pSettings;
delete panorama;

◆ WaitForFinishStitching()

void CPanoramaStitcher::WaitForFinishStitching ( )

Waits for finishing stitching all frames in the inner frame queue.

Code Snippet:
panorama->InitLicense("t0260NwAAAHV***************");
int ret = panorama->StartPanoramaStitchingByBuffer(1080, 1920, 3240, DPS_IPF_RGB_888);
panorama->AppendNewFrameByBuffer(pBuffer);
delete panorama;

Member Data Documentation

◆ m_pStitcher

DM_Panorama* CPanoramaStitcher::m_pStitcher
protected

The internal panorama stitcher.