Message Boards Message Boards

Do some camera calibration using OpenCVLink?


I would like to do some camera calibration using functionality that is available in opencv. (I have my own code for this and want to compare the opencv solution.) I see that there is an OpenCVLink in the Mathematica application's Links directory. Alas, it looks like it is merely 'glue' for some of the built-in Mathematica image processing routines (defining filters, enhancing routines, etc).

I was wondering if anyone else has bothered to 'embrace and expand/enhance' the supplied OpenCVLink to provide other opencv capabilities. Most importantly, it looks like there's some support/glue/voodoo for passing the Mathematica Image data structure into the opencv calls. For example -

         $LineSegmentDetector = ... "opencv_LineSegmentDetector", { {"Image", "Constant"}}, {_Real, 1}];

seems to suggest it calls into the DLL w an image and a real parameter. If this is the case it would seem like one might be able to add a few things, depending on the complexities of the interface, etc. I can imagine, however, that this might be particularly tricky based on assumptions about what the objects/classes want with respect to messages, etc. (for example. I can't find a member function for LineSegmentDetector that looks like the above call template.)

Has anyone tried this? Are there any 'unofficial' mechanisms for this? Any suggestions?

POSTED BY: Flip Phillips
2 months ago


I have never called opencv routines from Mathematica but I think it would not be hard to use Mathematica's WSTP interface to call opencv routines. I would suggest not trying to reverse engineer and use the ones built in to Mathematica because they may not be complete and every time Mathematica upgrades, it will likely break your code. I suggest you install a fresh copy of OpenCv and use WSTP as a robust way to call functions in libraries (or compiled standalone code). Are you familiar with it? If not, here are some documentation links:

This is a good overview of WSTP

This is the full documentation. This is a more detailed overview which includes two sections -- one for MacOS and one for Windows

The included example code is particularly useful.

You can take an image, call an opencv routine and get the results back and continue in Mathematica. I have some more Mac-specific advice on calling library routines (I have done this), Are you using a Mac?

I hope this helps.



POSTED BY: Neil Singer
2 months ago

Group Abstract Group Abstract