refcount attribute

asked 2016-02-24 10:17:35 -0600

fijoy gravatar image

Can anyone explain how exactly the refcount attribute is used in OpenCV structs? I am specifically looking at refcount in CvMat. I expected refcount to be used memory management, but looking at the source code (array.cpp and matrix.cpp), I see that the value of refcount is 0 or 1. I expected to see refcount incremented in shallow copy operations like cvMatToMat(const CvMat* m, bool copyData) with copyData=false. Am I missing something or not looking at the right source files?

Thanks.

edit retag flag offensive close merge delete

Comments

1

please don't try to use any of the deprecated c-api structures, like IplImage* CvMat *, CvArr* . they moved away from that in 2010 already, you're fighting problems, that were simply solved using the c++ api, cv::Mat.

berak gravatar imageberak ( 2016-02-24 10:52:44 -0600 )edit

I'm trying to integrate OpenCV with existing C code, so looking into the C interface. I'm considering wrapping the C++ interface of OpenCV into C code, but don't know yet if that will be feasible.

fijoy gravatar imagefijoy ( 2016-02-24 10:56:42 -0600 )edit
1

re-write the c-code. seriously. use c++,. (or do not use opencv)

berak gravatar imageberak ( 2016-02-24 11:00:00 -0600 )edit

no, not an option to rewrite c code. it's in the order of 100K lines.

fijoy gravatar imagefijoy ( 2016-02-24 11:07:16 -0600 )edit

ok. still - don't use the discontinued c-api bindings.

try to build opencv with java support, then look at the generated jni code, to get a feeling, how it should be done.

berak gravatar imageberak ( 2016-02-24 11:11:37 -0600 )edit

In my opinion, if your project must use C and if there are not yet OpenCV lines of code in your project, you should consider using a pure C computer vision library instead of using the deprecated c-api of OpenCV:

Eduardo gravatar imageEduardo ( 2016-02-24 12:19:35 -0600 )edit