How do i use an alternative version of opencv with OF?

i posted this question already in a thread that is 4 years old.
i thought it might be better to start a new one. hope that’s not cross posting :frowning:

I am trying to use opencv code that uses the gpu with of 0.9.3 on OS X 10.10.5. do we know if the static opencv.a lib for OS X has gpu enabled?

trying to run opencv gpu based code
gpu::GpuMat gpu_img;
which causes this compile errors like:
Variable has incomplete type 'gpu::GpuMat'

gpu::HOGDescriptor gpu_hog(cv::Size(64, 128), cv::Size(16, 16), cv::Size(8, 8), cv::Size(8, 8),9);
No member named 'gpu::HOGDescriptor' in namespace 'cv::gpu'; did you mean simply 'HOGDescriptor'?

does this simply mean ofxCv does not have these options build in to it’s wrapper? i also started to build opencv3 via brew brew install opencv3 --with-contrib --with-cuda --with-ffmpeg --with-tbb but was not sure how to link it properly in to OF. simply pointing to the include and lib folder seems not enough.
as suggested here:

here is the openCv example i am hoping to get running:

I think by now all of the libraries are complied using OF’s internal package manager Apothecary

This is the OpenCv formula

thanks for the info.

why do i then get these errors:

here the code:

might be because of -DWITH_CUDA=OFF?!

i see, the apothecary script seems not to build CUDA.

what would be the best approach be?
somehow work my way in to seeing apothecary via the quick start guide:

or use a separate opencv version, like the one i made via brew?

figured out how to start working with apothecary to update the opencv addon

$ /Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary update ofxOpencv

before running the script i set -DWITH_CUDA=ON in the above mentioned OpenCv formula.

got make errors like this"
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

maybe @danomatika knows why?

here the full error:

I didn’t write the opencv formula, so I don’t know the details.

A quick google search using the clang error string turns up that the formula should probably compile each architecture separately & link them into a fat lib on OS X:

thanks for responding.

i guess i know too little about apothecary.

tried this:

kinder:~ stephan$  /Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary update ofxOpenCv
/Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary: line 68: /Users/stephan/ No such file or directory
/Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary: line 978: XS: unbound variable
^ Received error ^

and this

kinder:~ stephan$ /Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary ofxOpenCv/scripts/formulas/
/Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary: line 68: /Users/stephan/ No such file or directory
 Missing lib build target (maybe you wanted "core"). See help: 'apothecary -h'.

and this

kinder:~ stephan$ /Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary ofxOpenCv/scripts/formulas/ -t osx -a 64
/Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary: line 68: /Users/stephan/ No such file or directory
/Applications/openFrameworks-0.9.3-master/scripts/apothecary/apothecary: line 978: XS: unbound variable

 ^ Received error ^

in case it’s useful the most uptodate formulas and apothecary are now in:

those formulas are also run on a ci server whenever there’s a change and the libraries compiled for all the platforms can be found here:

@stephanschulz did you ever manage to update the OpenCV version inside of openFrameworks? I also couldn’t get apothecary to work (also related to this issue ), so I’m now doing a manual build of OpenCV from source and then (hopefully) replacing the library and include files inside addons/ofxOpenCv . But no luck so far.

Would love to use OpenCV-DNN that’s included in 3.3.0 !

EDIT: applied this patch and at least Apothecary works again on my system. I changed VER to 3.3.0 and am about to see what happens!

1 Like

@noio let me check with my co-worker. we recently compiled openCv with DNN ability. He was putting together a readme and was going to publish the code and examples.

1 Like

That would be amazing!

I managed to successfully execute apothecary update opencv but am running into linker errors (for protobuf & TraceManager) when building my project.

To the rescue, here I am!
I forked apothecary last week to include a modified version of the formulae to compile version 3.3.0 of OpenCV on OSX, along with all the modules from the opencv_contrib repository.
Please consult:


Great, that worked! (after re-applying the realpath patch I mentioned before).

I can now compile openFrameworks with OpenCV 3.3.0! :tada:

(Now imread doesn’t work (returns empty matrices). I think because WITH_JPG and WITH_PNG are turned off as reported by cv::getBuildInformation()… Gonna try to fix that )

1 Like

It has been over 1 year since this post was discussed, but I also need to use alternative version of openCv with OF under Windows developing on VS2017. Do you have a version for Windows platform? or if you know how to do it by chance, could you please share your knowledge of how to use alternative version of openCV on Windows platform?

if you already have the opencv version you want to use compiled just put the compiled dll in addons/ofxOpenCv/libs/opencv/lib/win(not sure if this last folder is win but it is the one you have there). Then put the includes in addons/ofxOpenCv/libs/opencv/include folder.
The other option is to use the apothecary and recompile the version you want to use. search the forum for more info on the apothecary.

1 Like