I've asked about OpenCV before. Specifically the latest C++ versions. Since then I've spent about 18 months programming with OpenCV in C++. However, Lazarus is head and shoulders above any other non-commercial IDE for Linux. So I'm always pulled back to Lazarus (and Pascal!) by something like a gravitational force.
So yesterday, I was thinking ...
- A .dll or .so is basically a blob of machine code - it really does not matter in what language the source files were written.
- An executable is also basically a blob of machine code - it also doesn't matter in what language the source files were written.
- So at runtime it's all machine code, and the secret is getting the executable's machine code to interact with the .dll or .so machine code.
- There are no OpenCV "bindings" for Free Pascal (as there are for Python and Java), so it's difficult / impossible to pass sophisticated C++ objects back and forth between the base executable section and the loaded .dll or .so section.
- However, simple objects can be passed back and forth as pointers, and the basic element of the "cv::Mat" class is its data buffer.
- So if I can pass this buffer back and forth ("flattened") along with some other simple parameters, then inside the .dll or .so section (which I write in C++) I can construct full blown cv::Mats and we're off to the races.
- And when the OpenCV processing is done, the results are passed back through that same data pointer.
If I'm understanding this correctly, I don't have to wait for somebody to develop OpenCV bindings for Free Pascal. I just write my own .dll's and / or .so's in C++ and manage the interfaces. And I still get to write the main app in Lazarus / FPC !!! It seems almost too good to be true! What am I missing? I've never done anything like this with Lazarus, but I've done something similar with Python "ctypes" and a .dll written in C.
I don't want you to spend a lot of time coaching the specifics, I should learn those on my own time. But I do want to know if it's as feasible as I seem to believe it is. Thanks in advance !! (I was gonna post this in "Graphics" but it's generic enough conceptually for general programming)