I'am working with opencv that I integrated into MATLAB. I'm using the Features2D and Nonfree libraries of opencv to run different keypoints detection and description algorithms.
After many tests I noticed that BRISK is performing pretty good with my data. The problem is that the constructor of the class BRISK is very slow compared to other algorithms. this line:
BRISK detector(10,3,1.0f);
is an order of magnitudes slower than the detection,description an matching all together. Now I make it in such a way that every time a new couple of images arrives, I run my mex file and all the declarations and class constructions are done again, which makes it slower.
Is there a way to start the mex file at the beginning of my MATLAB script (before the loop sending new images to the mex file), so that it makes all the needed declarations and keeps waiting in background for input from MATLAB. This would make my code much faster. In the provided matlab API from the creators of BRISK, it seems like it is done this way but I could't figure out how to do the same for my own mex code.
I tried searching for this in stackoverflow but I don't really know what to search for or what this kind of thing is called.
Thanks
What you are looking for a way to make objects persistent between mex calls. See here (edited):
Yes, you can make a C++ object persistent between calls, and you don't have to return the pointer to the Matlab workspace. Simply define your object above the mexFunction entry point. It will remain persistent as long as your mex file stays in memory (i.e. you don't clear the mex file).