in reply to Shameless plug and QR japh

First, congrats on cracking XS (not easy) and getting OpenCV working!

This is amazingly good timing, as a PDL user is just looking to get OpenCV working in the context of PDL (see https://github.com/PDLPorters/pdl/issues/362 and latest state of play on https://sourceforge.net/p/pdl/mailman/message/37627428/).

We've identified that a vital next step would be to make an Alien::OpenCV that captures whether OpenCV is installed on the user's machine, and would need a ->cflags and ->libs method for use in other modules' Makefile.PL etc. Do you feel like making such a module, and/or helping the user get further with their OpenCV adventure?

Replies are listed 'Best First'.
Re^2: Shameless plug and QR japh
by bliako (Abbot) on Mar 24, 2022 at 10:26 UTC

    An Alien module would be great, but I am totally alien to Alien. Also, OpenCV discourage you from using pkg-config (which is more or less standard with any *nix dev tools package), instead they suggest cmake (which is a hit+miss for both M$ and *nix). See this forum post. In fact the only failed test I have for Image::DecodeQR::WeChat is on a M$ machine with no cmake. Installing OpenCV binaries on M$ does not include cmake.

    So, an Alien module would be a breaze on *nix but it will be a real headache for M$ windows. But I am prepared to give it a try in about a month's time.

    In the meantime, I include some code, at the bottom, I use to detect OpenCV flags in above module's Makefile.PL.

    Regarding compiling OpenCV code as part of XS. There's a trick suggested by Botje @ #perl: do not include any OpenCV code or headers in the XS file. Place them in separate C++ files, and add an entry function which does not depend on OpenCV data structures and headers at all. So that excludes at the moment passing or returning said data structures lest they are casted to anonymous pointers which is a fair solution. Then link that C++ code to XS careful with function name mangling. Including OpenCV headers in XS clashes with Perl's internals (seed and ... cv come to mind and also the linked posts mention it, plus Inline::CPP + OpenCV = problems. I have used that trick successfully, so at least there is a way. I explain the process and various subleties at the pod of Image::DecodeQR::WeChat. Having C++ code linking to XS is another tough to crack. But solvable.

    bw, bliako

      Fair enough. There's an Alien::cmake3 you could use to get cmake available in more places.
      A note from the future: the mighty zmughal made an Alien::OpenCV, which you might want to change your module over to using.

        noted thanks