[問題] 影像擷取功能

作者: LennyW (Lenny)   2015-08-03 12:31:25
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
程式碼(Code):(請善用置底文網頁, 記得排版)
ll_Grabbing int CCreateDevice()
{
// Create an instant camera object with the camera device found first.
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
// The parameter MaxNumBuffer can be used to control the count of buffers
// allocated for grabbing. The default value of this parameter is 10.
camera.MaxNumBuffer = 5;
//Print the model name of the camera.
//camera.GetDeviceInfo().GetModelName();
camera.StartGrabbing(c_countOfImagesToGrab);
return 0;
}
Dll_Grabbing int Grabbing()
{
// This smart pointer will receive the grab result data.
CGrabResultPtr ptrGrabResult;
// Camera.StopGrabbing() is called automatically by the RetrieveResult()
method
// when c_countOfImagesToGrab images have been retrieved.
while (camera.IsGrabbing())
{
// Wait for an image and then retrieve it. A timeout of 5000 ms is used.
camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);
// Image grabbed successfully?
if (ptrGrabResult->GrabSucceeded())
{
// Access the image data.
uint32_t aGetWidth = ptrGrabResult -> GetWidth();
uint32_t aGetHeight = ptrGrabResult -> GetHeight();
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult -> GetBuffer();
return pImageBuffer[0];
}
else
{
return 0
}
}
return 0;
補充說明(Supplement):
小弟目前有一組 Camera,
程式碼是根據網站上提供的 Sample code 來做修改,
之後要包成 DLL 讓 Labview 去呼叫。
但目前有個點不知道該怎麼解決,
想請問如何把 CCreateDevice() 函式裡創建的 Device 拿給 Grabbing() 函式用,
原本是寫成重新取一次值就要建一次device,
但實在太慢了。
不曉得要如何讓 Grabbing() 可以抓到上個函式建好的 Device ?
小弟只是初學者,
基本上都是直接硬寫...
還在學習,也還有很多不懂的原理...
作者: CumCumCum (2 hard 2 hard)   2015-08-04 08:50:00
basler在這兩個函式外 定義一個Cinstantcamera變數

Links booklink

Contact Us: admin [ a t ] ucptt.com