I am capturing a video frame as follows
CvCapture *capture = cvCreateFileCapture("PATH");
I can read the video and process it. Everything works fine. But when I try to release the capture
cvReleaseCapture( &capture );
I get
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
The function is inside a class.
public ref class Locator
and I am calling it from the main
Locator r;
Before I added it *public ref * to class locator it was not giving me any error.
Any ideas for fixing it? It was working fine before switching to c++-cli.
I think it is related to some heap problem, items on the heap can be moved as a result of garbage collection. In order to send a pointer to a native method/function, you need to “pin” the pointer for the duration of the call, but I don't know how.
Thanks.
Updated:
That fixed it.
pin_ptr<CvCapture*> p;
p = &capture;
cvReleaseCapture( p );
(Adding as answer, thanks to @AlexFarber for the correction)
Have you tried pin_ptr? Something like:
pin_ptr<CvCapture*> pCapture = &capture;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With