Cannot convert parameter 1 from 'cli :: interior_ptr <Type>' to 'CvCapture **'

I am shooting a video as follows

CvCapture *capture = cvCreateFileCapture("PATH"); 

I can read the video and process it. Everything is working fine. But when I try to free the grip

 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 the class.

 public ref class Locator 

and I call it from the main

Latitude r;

Before I added it * public ref * to the class locator, it did not give me any errors.

Any ideas for fixing it? It worked fine before switching to C ++ - cli.

I think this is due to some heap problem, items in the heap can move as a result of garbage collection. To send a pointer to your own method / function, you need to "bind" the pointer to the duration of the call, but I do not know how to do it.

Thanks.

Updated:

This is fixed.

 pin_ptr<CvCapture*> p; p = &capture; cvReleaseCapture( p ); 
+4
source share
1 answer

(added as an answer, thanks to @AlexFarber for correction)

Have you tried pin_ptr? Sort of:

 pin_ptr<CvCapture*> pCapture = &capture; 
+10
source

All Articles