SFML community forums

General => General discussions => Topic started by: DenisBrno on December 25, 2022, 05:10:12 pm

Title: Including OpenCV
Post by: DenisBrno on December 25, 2022, 05:10:12 pm
Hello, I want to include OpenCV to my project, but I don't know how. I was able to run OpenCV and SFML in 2 separate folders. But when I was trying to run it both at once I wasn't able to even include SFML...
Thanks for future help
Title: Re: Including OpenCV
Post by: eXpl0it3r on December 26, 2022, 11:05:16 pm
It's rather vague what you're asking here.
Do you have compiler or linker errors? Or what exactly are you struggling with.

I haven't used OpenCV so I'm not really sure how it works. Does it use the GPU for some of its work?
Title: Re: Including OpenCV
Post by: kojack on December 30, 2022, 12:06:15 pm
I recently added OpenCV to an SFML project to do video processing (working on a motion detection thing for security camera footage).

From a code point of view the setup was basically (this is for visual studio):
#include "opencv2/opencv.hpp"

#ifdef _DEBUG
        #pragma comment(lib, "opencv_world460d.lib")
#else
        #pragma comment(lib, "opencv_world460.lib")
#endif
 

The usual stuff needs to be set up as with any library: includes path, library path and dlls next to the project exe.

Of course OpenCV's images aren't directly compatible with SFML, you'll need to convert them if you need images. So far the only easy way I've found is manually looping over each pixel and converting them.