[問題] 影像擷取功能

看板C_and_CPP (C/C++)作者 (Lenny)時間10年前 (2015/08/03 12:31), 10年前編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
開發平台(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 ? 小弟只是初學者, 基本上都是直接硬寫... 還在學習,也還有很多不懂的原理... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.221.83.204 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1438576287.A.003.html ※ 編輯: LennyW (61.221.83.204), 08/03/2015 12:36:24

08/04 08:50, , 1F
basler
08/04 08:50, 1F

08/04 08:53, , 2F
在這兩個函式外 定義一個Cinstantcamera變數
08/04 08:53, 2F
文章代碼(AID): #1LlkwV03 (C_and_CPP)
文章代碼(AID): #1LlkwV03 (C_and_CPP)