主頁 >  其他 > Pylon SDK的C語言使用流程詳解及代碼示例

Pylon SDK的C語言使用流程詳解及代碼示例

2021-09-15 11:30:33 其他

目錄

前言

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 功能允許您為選定的觸發型別啟用或禁用觸發影像采集,

設定觸發模式:

  1. TriggerSelector 引數設定為所需的 觸發型別,例如 FrameStart
  2. 設定 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 功能允許您配置如何觸發當前選定觸發器,

例如,您可以選擇輸入線路或軟體命令作為觸發源,

該功能的使用#

要配置觸發器的觸發方式:

  1. TriggerSelector 引數設定為所需的 觸發型別,例如 FrameStart
  2. 設定 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

標籤:其他

上一篇:python+opencv判斷開關或按鈕的狀態

下一篇:**動態時間規整演算法(DTW)與遙感影像地物分類(一)時序資料的下載及預處理**

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more