open cv binding for c++ <> c [closed]
Hello, i have a stupdid question as i really new to c++ / c development. I am doing it now since 2 days. I managed to pass the class cv::Mat around from one c++ dll to another - great.
Now i have a c dll which expects type CvMat. From my understanding this is the c representation of the cv::Mat class. Are these two object compatible to each other - can i convert the c++ cv::Mat to a c CvMat object? I have the memory adress of the CMat object.
Hmm i hope this makes any sense. Any help on this is highly welcome.
Thank you + Greetings, Holger
AVOID anything written in opencv's c-api. it's dead, no more maintained since 2010, and may be gone in a few weeks
Oh well the code base i am dealing with is using the c CvMat class, sadly. Any hope for me to get the c++ open cv lib with the c open cv lib working together?
If not i would need to port the code - ouch. If i get it right - i could write a c++ code expecting of type cv:Mat and then calling the c code?
there are conversion functions but you have to be VERY careful about data ownership, releasing / allocating c-structures. not at all suitable for a beginner !
if that was written in c, it's probably stone-age. (or written by a moron..).
again, rather avoid or replace it, or it will seep into your code.
find an alternative to that codebase, which is better maintained. anything else will be a waste of time
...if that was written in c, it's probably stone-age. (or written by a moron..)...
Well that guy is a chaotic guy imho - https://pjreddie.com/ But hes also good, from an algorithmic point of view. And i found nothing which could compare with the performance on cuda. Not tensorflow, not deeplearning4j or any other lib i tried out.
That the thing about darknet yolo - its poorly written and hard to embed in your app but has best performance for interference. Maybe i write my own mat class for passing data around. I am already at the point on which i dont care anymore - only worrying about code maintanance - feeling like 1970.
Anyway - Thank you for you help - this make things a bit more clear for me.
oh, you can be a genius and a moron at the same time, no problem ;)
and with darknet: you can build that without using opencv, and later write your own c++ wrappers around the io parts. that should be much easier (or at least cleaner), than using opencv's deprecated IplImage* things.
Yes you are right on both: 1) the moron <> genius thing (haha) and the 2) custom wrapper around the io classes darknet uses. And yes darknet yolo uses IplImage/CvMat for loading the image.
So instead of trying old style open cv classes and try to pass them around- i agree its easier to pass the new style classes (Mat or custom class ) to a c++ wrapper which will convert them into the c type and do the final call(hope this makes sense - my head say yes). The open cv layer on darknet is very very thing anyway. As you already mentioned you can get it even working without open cv.
Thx for you help / comments - helps me getting through this stuff and keeping my sanity XD.