4
我捕捉視頻幀如下無法從「CLI :: interior_ptr <Type>」轉換參數1「CvCapture **」
CvCapture *capture = cvCreateFileCapture("PATH");
我可以讀取視頻,並對其進行處理。一切正常。但是,當我嘗試釋放捕獲
cvReleaseCapture(&capture);
我得到
error C2664: 'cvReleaseCapture' : cannot convert parameter 1 from
'cli::interior_ptr<Type>' to 'CvCapture **'
with
[
Type=CvCapture *
]
Cannot convert a managed type to an unmanaged type
功能是一個類的內部。
public ref class Locator
,我從主
定位R電話它;
在我添加之前* public ref *到class locator它沒有給我任何錯誤。
修復它的任何想法?在切換到C++ - cli之前它工作正常。
我認爲它與一些堆問題有關,堆中的項可以作爲垃圾收集的結果而移動。爲了發送一個指向本地方法/函數的指針,你需要在調用期間「固定」指針,但我不知道如何。
謝謝。
更新:
修復它。
pin_ptr<CvCapture*> p;
p = &capture;
cvReleaseCapture(p);
您需要調用'Marshal :: FreeHGlobal'來清理StringToHGlobalAnsi創建的字符串。請參閱此答案的示例代碼:http://stackoverflow.com/a/5667246/480937 – 2012-07-20 17:06:05
這是如何影響捕獲? – fmvpsenior 2012-07-20 17:23:23
我編輯的問題,因爲即使我直接給它的路徑它仍然給我同樣的錯誤 – fmvpsenior 2012-07-20 17:30:08