目錄
前言
1.Pylon SDK簡介與基本運行流程
2.載入相機
3.流抓取器抓取物件
4.單幀或連續抓圖程序
5.收尾作業
5.1卸載流抓取器
5.2卸載相機物件
前言
筆者采用的Pylon版本為Basler_pylon_5.2.0.13457的開發者版本,本文默認軟體已安裝完畢,VS專案中相關庫專案配置完成,在首次介紹一個函式時,筆者會首先列出其在頭檔案的定義,然后列出其使用實體,實體大多來源Pylon C指導手冊,
1.Pylon SDK簡介與基本運行流程
首先,我們使用的是Pylon 5 Runtime開發組件包,官網關于該組件包的描述如下:
Basler pylon 5 Runtime(5.0.12版)- 包含適用于所有相機介面及適用于C++、.NET、GenTL、DirectShow/Twain編程語言的驅動程式,此組件包已包含全部在終端用戶的PC上運行基于pylon的應用時所需的全部組件,
關于Pylon SDK的整體運行推薦對照以下鏈接的圖解,
3.Pylon 以實時影像采集講解PylonC SDK使用流程_文洲的專欄-CSDN博客
2.載入相機
在Pylon中,攝像機設備是通過“攝像機物件”來管理的,并由PYLON_DEVICE_HANDLE型別的句柄表示,相機設備由傳輸層提供動態檢測,
在使用Pylon功能前,需要呼叫函式PylonInitialize()初始化Pylon Runtime環境,下列代碼來自頭檔案定義,可以看出該函式為無參函式,
IDL_ENTRY(PYLONC_MODULE, "_PylonInitialize@0", "Initialize the pylon runtime system.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE_DOC
PylonInitialize(void);
然后,呼叫PylonEnumerateDevices()列舉所有連接的相機設備,PylonEnumerateDevices()函式回傳值為所有介面檢測到的攝像機設備的總數,需要注意的是,如果相機設備為兩個,可以使用[0 ,1]索引訪問每個相機,然后依次為每個索引值呼叫PylonGetDeviceInfo(),通過查看PylonDeviceInfo_t結構體的欄位,可以識別每個單獨的攝像機,然后呼叫PylonGetDeviceInfoHandle()將設備索引轉換為可用于查詢設備屬性的PYLON_DEVICE_INFO_HANDLE,
/* Device enumeration / creation */
IDL_ENTRY(PYLONC_MODULE, "_PylonEnumerateDevices@4", "Enumerate all devices.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonEnumerateDevices(RETVAL_PAR size_t *numDevices);
PylonEnumerateDevices()使用示例如下:
/* Enumerate all camera devices. You must call
PylonEnumerateDevices() before creating a device. */
res = PylonEnumerateDevices( &numDevices );//1.列舉
CHECK(res);
if ( 0 == numDevices )
{
fprintf( stderr, "No devices found.\n" );
PylonTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
在檢測完相機設備后,可以通過呼叫PylonCreateDeviceByIndex()來創建相機物件(由PYLON_DEVICE_HANDLE表示),
IDL_ENTRY(PYLONC_MODULE, "_PylonCreateDeviceByIndex@8", "Create a device object.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonCreateDeviceByIndex( size_t index, RETVAL_PAR PYLON_DEVICE_HANDLE *phDev);
實體如下,0代表第一個被檢測的相機:
/* Get a handle for the first device found. */
res = PylonCreateDeviceByIndex( 0, &hDev );//2.CreateDeviceByIndex
CHECK(res);
/* ...The device is no longer used, destroy it. */
res = PylonDestroyDevice ( hDev );//3.與PylonCreateDeviceByIndex對應
CHECK(res);
相機物件創建完畢后,使用之前需要呼叫PylonDeviceOpen()初始化傳輸層,并且建立到物理相機設備的連接,
/* Device operations */
IDL_ENTRY(PYLONC_MODULE, "_PylonDeviceOpen@8", "Open a device.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceOpen(PYLON_DEVICE_HANDLE hDev, int accessMode);
使用示例如下:
/* Before using the device, it must be opened. Open it for configuring
parameters and for grabbing images. */
res = PylonDeviceOpen( hDev, PYLONC_ACCESS_MODE_CONTROL | PYLONC_ACCESS_MODE_STREAM );
CHECK(res);
完成后,我們就可以設定引數和抓取影像了,
在設定引數時,使用PylonDeviceFeatureFromString()函式,關于該函式的其他特征引數設定這里不做詳解,
IDL_ENTRY(PYLONC_MODULE, "_PylonDeviceFeatureFromString@12", "Set a feature's value from a string.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceFeatureFromString(PYLON_DEVICE_HANDLE hDev, STRING_PAR const char* pName, STRING_PAR const char* pValue);
Pylon中,相機可由軟體觸發器觸發,因此相應地配置TriggerMode和TriggerSource攝像機引數,事實上,TriggerMode和TriggerSource都是Trigger Selector配置觸發型別時的功能,這里官網介紹得很詳細,有興趣的讀者可以去官網查看,本文僅列出TriggerMode和TriggerSource的配置方法及代碼示例,
Trigger Mode
相機的 Trigger Mode 功能允許您為選定的觸發型別啟用或禁用觸發影像采集,
設定觸發模式:
- 將
TriggerSelector引數設定為所需的 觸發型別,例如FrameStart,- 設定
TriggerMode引數設定為以下值:
On:為選定的觸發型別啟用觸發影像采集,Off:為所選觸發型別禁用觸發影像采集,觸發信號由相機自動生成,默認情況下,所有觸發型別的觸發模式均設定為
Off,這意味著啟用了自由運行影像采集,
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
/* Select the Frame Start trigger */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSelector", "FrameStart");
CHECK(errRes);
/* Enable triggered image acquisition for the Frame Start trigger */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerMode", "On");
CHECK(errRes);
Trigger Source#
相機的 Trigger Source 功能允許您配置如何觸發當前選定觸發器,
例如,您可以選擇輸入線路或軟體命令作為觸發源,
該功能的使用#
要配置觸發器的觸發方式:
- 將
TriggerSelector引數設定為所需的 觸發型別,例如FrameStart,- 設定
TriggerSource引數(如果可用),
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
/* Select the Frame Start trigger */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSelector", "FrameStart");
CHECK(errRes);
/* Set the trigger source to Line 1 */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSource", "Line1");
CHECK(errRes);
使用軟體觸發時,應使用連續幀模式,即將設備句柄和相機引數“AcquisitionMode”和“Continuous”作為引數傳遞給PylonDeviceFeatureFromString(),
使用示例如下:
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
/* Configure single frame acquisition on the camera */
errRes = PylonDeviceFeatureFromString(hdev, "AcquisitionMode", "SingleFrame");
CHECK(errRes);
/* Switch on image acquisition */
errRes = PylonDeviceExecuteCommandFeature(hdev, "AcquisitionStart");
CHECK(errRes);
/* The camera waits for a trigger signal. */
/* When a Frame Start trigger signal has been received, */
/* the camera executes an Acquisition Stop command internally. */
/* Configure continuous image acquisition on the camera */
errRes = PylonDeviceFeatureFromString(hdev, "AcquisitionMode", "Continuous");
CHECK(errRes);
/* Switch on image acquisition */
errRes = PylonDeviceExecuteCommandFeature(hdev, "AcquisitionStart");
CHECK(errRes);
/* The camera waits for trigger signals. */
/* (...) */
/* Switch off image acquisition */
errRes = PylonDeviceExecuteCommandFeature(hdev, "AcquisitionStop");
CHECK(errRes);
至此,相機正式開始影像采集的作業,接下來就是獲取影像資訊,
3.流抓取器抓取物件
Pylon中,相機物件獲得影像可以采用事件抓取器和流抓取器,這里僅介紹流抓取器的使用,
相機提供的流捕捉器的數量可以使用PylonDeviceGetNumStreamGrabberChannels()函式來確定,函式的作用是:回傳一個PYLON_STREAMGRABBER_HANDLE,在檢索流捕捉器句柄之前,必須已打開攝像機設備,注意,若相機無此功能,則回傳值為0,
DL_ENTRY(PYLONC_MODULE, "_PylonDeviceGetNumStreamGrabberChannels@8", "Return the access mode flags for a device.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceGetNumStreamGrabberChannels(PYLON_DEVICE_HANDLE hDev, RETVAL_PAR size_t *pNumChannels);
使用流抓取器抓取影像時,對于每個相機設備,通過呼叫PylonDeviceGetStreamGrabber()并將設備句柄和流抓取器句柄作為引數傳遞來創建流抓取器,
IDL_ENTRY(PYLONC_MODULE, "_PylonDeviceGetStreamGrabber@12", "Obtain a stream grabber handle from a device.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceGetStreamGrabber(PYLON_DEVICE_HANDLE hDev, size_t index, RETVAL_PAR PYLON_STREAMGRABBER_HANDLE *phStg);
在使用之前,流捕獲器必須通過呼叫PylonStreamGrabberOpen()來打開,當獲取影像完成時,流捕捉器必須通過呼叫PylonStreamGrabberClose()關閉,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberOpen@4", "Open a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberOpen(PYLON_STREAMGRABBER_HANDLE hStg);
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberClose@4", "Close a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberClose(PYLON_STREAMGRABBER_HANDLE hStg);
然后使用PylonStreamGrabberGetWaitObject()檢索流抓取器的等待物件的句柄,等待物件等待緩沖區被抓取的影像資料填滿,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberGetWaitObject@8", "Return a stream grabber's wait object.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberGetWaitObject(PYLON_STREAMGRABBER_HANDLE hStg, RETVAL_PAR PYLON_WAITOBJECT_HANDLE *phWobj);
使用示例如下:
/* Image grabbing is done using a stream grabber.
A device may be able to provide different streams. A separate stream grabber must
be used for each stream. In this sample, we create a stream grabber for the default
stream, i.e., the first stream ( index == 0 ).
*/
/* Get the number of streams supported by the device and the transport layer. */
res = PylonDeviceGetNumStreamGrabberChannels( hDev, &nStreams );
if ( nStreams < 1 )
{
PylonTerminate();
}
/* Create and open a stream grabber for the first channel. */ 流是在相機句柄之上的新句柄
res = PylonDeviceGetStreamGrabber( hDev, 0, &hGrabber );
res = PylonStreamGrabberOpen( hGrabber );
/* Get a handle for the stream grabber's wait object. The wait object allows waiting for buffers to be filled with grabbed data. */
res = PylonStreamGrabberGetWaitObject( hGrabber, &hWait );
CHECK(res);
我們還必須告訴流抓取器我們正在使用的緩沖區的數量和大小,這是通過PylonStreamGraberSetMaxNumbuffer()和PylonStreamGraberSetMaxBufferSize()完成的,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberSetMaxNumBuffer@8", "Set the maximum number of data buffers for a stream grabber to use.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberSetMaxNumBuffer(PYLON_STREAMGRABBER_HANDLE hStg, size_t numBuffers );
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberSetMaxBufferSize@8", "Set the maximum data buffer size for a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberSetMaxBufferSize(PYLON_STREAMGRABBER_HANDLE hStg, size_t maxSize );
通過呼叫PylonStreamGrabberPrepareGrab(),我們可以分配抓取所需的資源,在此之后,在呼叫PylonStreamGrabberFinishGrab()之前,不得更改影響有效負載大小的關鍵引數(只讀),
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberPrepareGrab@4", "Prepare a stream grabber for grabbing.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberPrepareGrab(PYLON_STREAMGRABBER_HANDLE hStg);
使用示例如下:
/* Allocate memory for grabbing. */
for ( i = 0; i < NUM_BUFFERS; ++i )//分配NUM_BUFFERS個緩沖區
{
buffers[i] = (unsignedchar*) malloc ( payloadSize );
if ( NULL == buffers[i] )
{
PylonTerminate();
}
}
/* We must tell the stream grabber the number and size of the buffers we are using. */
/* .. We will not use more than NUM_BUFFERS for grabbing. */
res = PylonStreamGrabberSetMaxNumBuffer( hGrabber, NUM_BUFFERS );//buffer的個數
CHECK(res);
/* .. We will not use buffers bigger than payloadSize bytes. */
res = PylonStreamGrabberSetMaxBufferSize( hGrabber, payloadSize );//buffer的大小
CHECK(res);
/* Allocate the resources required for grabbing. After this, critical parameters
that impact the payload size must not be changed until FinishGrab() is called. */
res = PylonStreamGrabberPrepareGrab( hGrabber );//分配 grabbing所需要的資源
CHECK(res);
每個stream grabber有兩個不同的緩沖區佇列,輸入佇列和輸出佇列,用于grab的緩沖區必須放到輸入佇列中,
在使用緩沖區進行抓取之前,必須將它們注冊并排入流抓取器的輸入佇列,這是通過PylonStreamGrabberRegisterBuffer()和PylonStreamGrabberQueueBuffer()完成的,
PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberRegisterBuffer(PYLON_STREAMGRABBER_HANDLE hStg, void* pBuffer, size_t BufLen, PYLON_STREAMBUFFER_HANDLE *phBuf);
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE_DOC
PylonStreamGrabberQueueBuffer(PYLON_STREAMGRABBER_HANDLE hStg, PYLON_STREAMBUFFER_HANDLE hBuf, const void * pContext);
使用實體如下:
/* Before using the buffers for grabbing, they must be registered at
the stream grabber. For each registered buffer, a buffer handle
is returned. After registering, these handles are used instead of the
raw pointers. */
for ( i = 0; i < NUM_BUFFERS; ++i )
{
res = PylonStreamGrabberRegisterBuffer( hGrabber, buffers[i], payloadSize, &bufHandles[i] ); //注冊每個緩沖區,回傳句柄
CHECK(res);
}
/* Feed the buffers into the stream grabber's input queue. For each buffer, the API
allows passing in a pointer to additional context information. This pointer
will be returned unchanged when the grab is finished. In our example, we use the index of the
buffer as context information. */
for ( i = 0; i < NUM_BUFFERS; ++i )
{
res = PylonStreamGrabberQueueBuffer( hGrabber, bufHandles[i], (void*) i );
CHECK(res);
4.單幀或連續抓圖程序
首先呼叫PylonDeviceExecuteCommandFeature()啟動影像采集,注意該函式也可用于結束影像采集,
DL_ENTRY(PYLONC_MODULE, "_PylonDeviceExecuteCommandFeature@8", "Execute a command.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceExecuteCommandFeature(PYLON_DEVICE_HANDLE hDev, STRING_PAR const char *pName);
呼叫該函式將并將設備句柄和AcquisitionStart引數作為每個攝像頭上的引數,以啟動影像采集,
使用示例如下:
/* Let the camera acquire images. */
res = PylonDeviceExecuteCommandFeature( hDev, "AcquisitionStart");
CHECK(res);
呼叫PylonStreamGrabberGetWaitObject()等待緩沖區被影像填充,然后呼叫PylonStreamGrabberRetrieveResult()檢索被流抓取器抓取的影像,可以使用PylonImageWindowDisplayImageGrabResult()顯示影像,
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE_DOC
PylonStreamGrabberRetrieveResult(PYLON_STREAMGRABBER_HANDLE hStg, PylonGrabResult_t * pGrabResult, PINVOKE_RETVAL_PAR _Bool * pReady);
處理完成后,我們通過呼叫PylonStreamGrabberQueueBuffer()將當前抓取的緩沖區重新排隊以再次填充,該程序反復即可實作連續抓圖,
使用示例如下:
/* Grab NUM_GRABS images */
nGrabs = 0; /* Counts the number of images grabbed */
while ( nGrabs < NUM_GRABS ) //已經采集的影像個數少于規定的個數
{
size_t bufferIndex; /* Index of the buffer */
unsignedchar min, max;
/* Wait for the next buffer to be filled. Wait up to 1000 ms. */
res = PylonWaitObjectWait( hWait, 1000, &isReady ); //1.使用等待句柄判斷有無影像來,
CHECK(res);
if ( ! isReady )
{
/* Timeout occurred. */
fprintf(stderr, "Grab timeout occurred\n");
break; /* Stop grabbing. */
}
/* Since the wait operation was successful, the result of at least one grab operation is available. Retrieve it. */
res = PylonStreamGrabberRetrieveResult( hGrabber, &grabResult, &isReady ); //2.等待成功,從輸出佇列中獲取影像
CHECK(res);
if ( ! isReady )
{
/* Oops. No grab result available? We should never have reached this point.
Since the wait operation above returned without a timeout, a grab result
should be available. */
fprintf(stderr, "Failed to retrieve a grab result\n");
break;
}
nGrabs++; //3.成功采集的影像個數加1
/* Get the buffer index from the context information. */
bufferIndex = (size_t) grabResult.Context; //4. 剛采集到的影像的索引
/* Check to see if the image was grabbed successfully. */
if ( grabResult.Status == Grabbed ) //5.檢查剛采集到的影像是否是成功的?
{
/* Success. Perform image processing. Since we passed more than one buffer
to the stream grabber, the remaining buffers are filled while
we do the image processing. The processed buffer won't be touched by
the stream grabber until we pass it back to the stream grabber. */
unsignedchar* buffer; /* Pointer to the buffer attached to the grab result. */指向我們要處理的緩沖區
/* Get the buffer pointer from the result structure. Since we also got the buffer index,
we could alternatively use buffers[bufferIndex]. */
buffer = (unsignedchar*) grabResult.pBuffer; //6.將當前影像賦給用戶自定義的指標
/* Perform processing. */
getMinMax( buffer, grabResult.SizeX, grabResult.SizeY, &min, &max );
printf("Grabbed frame %2d into buffer %2d. Min. gray value = %3u, Max. gray value = %3u\n",nGrabs, (int) bufferIndex, min, max);
#ifdef GENAPIC_WIN_BUILD
/* Display image */
res = PylonImageWindowDisplayImageGrabResult(0, &grabResult);
CHECK(res);
#endif
}
elseif ( grabResult.Status == Failed )
{
fprintf( stderr, "Frame %d wasn't grabbed successfully. Error code = 0x%08X\n",
nGrabs, grabResult.ErrorCode );
}
/* Once finished with the processing, requeue the buffer to be filled again. */ //7.影像結束后再次將該緩沖區入隊
res = PylonStreamGrabberQueueBuffer( hGrabber, grabResult.hBuffer, (void*) bufferIndex );
CHECK(res);
}
采集完成后,停止影像采集
/* ... Stop the camera. */
res = PylonDeviceExecuteCommandFeature( hDev, "AcquisitionStop");
CHECK(res);
5.收尾作業
當影像采集停止時,我們必須對所有相機進行清理,即必須移除所有等待物件,釋放所有分配的緩沖記憶體,關閉并銷毀流抓取器以及相機設備句柄,
5.1卸載流抓取器
停止相機采集后,需要將所有還在輸入佇列等待的緩沖區移動到輸出佇列,實作該功能需要呼叫PylonStreamGrabberCancelGrab(),
DL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberCancelGrab@4", "Cancel grab operation.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberCancelGrab(PYLON_STREAMGRABBER_HANDLE hStg);
依舊呼叫PylonStreamGrabberRetrieveResult(),將輸出佇列的資料全部取出,再呼叫PylonStreamGrabberDeregisterBuffer()注銷分配的緩沖區,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberDeregisterBuffer@8", "Detach an image data buffer from a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberDeregisterBuffer(PYLON_STREAMGRABBER_HANDLE hStg, PYLON_STREAMBUFFER_HANDLE hBuf);
緩沖區注銷后,呼叫PylonStreamGrabberFinishGrab()釋放為緩沖區分配的資源,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberFinishGrab@4", "Shut down a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberFinishGrab(PYLON_STREAMGRABBER_HANDLE hStg);
最后,呼叫PylonStreamGrabberClose()關閉流抓取器,
IDL_ENTRY(PYLONC_MODULE, "_PylonStreamGrabberClose@4", "Close a stream grabber.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonStreamGrabberClose(PYLON_STREAMGRABBER_HANDLE hStg);
使用示例如下:
/* ... We must issue a cancel call to ensure that all pending buffers are put into the
stream grabber's output queue. */
res = PylonStreamGrabberCancelGrab( hGrabber );
CHECK(res);
/* ... The buffers can now be retrieved from the stream grabber. */
do
{
res = PylonStreamGrabberRetrieveResult( hGrabber, &grabResult, &isReady );
CHECK(res);
} while ( isReady );
/* ... When all buffers have been retrieved from the stream grabber, they can be deregistered.
After that, it is safe to free the memory. */
for ( i = 0; i < NUM_BUFFERS; ++i )
{
res = PylonStreamGrabberDeregisterBuffer( hGrabber, bufHandles[i] );
CHECK(res);
free( buffers[i] );
}
/* ... Release grabbing related resources. */
res = PylonStreamGrabberFinishGrab( hGrabber );
CHECK(res);
/* After calling PylonStreamGrabberFinishGrab(), parameters that impact the payload size (e.g.,
the AOI width and height parameters) are unlocked and can be modified again. */
/* ... Close the stream grabber. */
res = PylonStreamGrabberClose( hGrabber );
CHECK(res);
5.2卸載相機物件
呼叫PylonDeviceClose()和PylonDestroyDevice()關閉并銷毀相機物件,
IDL_ENTRY(PYLONC_MODULE, "_PylonDeviceClose@4", "Close a device.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE
PylonDeviceClose(PYLON_DEVICE_HANDLE hDev);
IDL_ENTRY(PYLONC_MODULE, "_PylonDestroyDevice@4", "Delete a device object.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE_DOC
PylonDestroyDevice(PYLON_DEVICE_HANDLE hDev);
最后,我們通過呼叫PylonTerminate()關閉pylon runtime系統,
IDL_ENTRY(PYLONC_MODULE, "_PylonTerminate@0", "Shut down the pylon runtime system.")
PYLONC_API GENAPIC_RESULT PYLONC_CC PINVOKE_DOC
PylonTerminate(void);
使用示例如下:
/* ... Close and release the pylon device. The stream grabber becomes invalid
after closing the pylon device. Don't call stream grabber related methods after
closing or releasing the device. */
res = PylonDeviceClose( hDev );
CHECK(res);
/* ...The device is no longer used, destroy it. */
res = PylonDestroyDevice ( hDev );//與PylonCreateDeviceByIndex對應
CHECK(res);
/* ... Shut down the pylon runtime system. Don't call any pylon method after
calling PylonTerminate(). */
PylonTerminate();
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/300316.html
標籤:其他
