Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Including OpenCV  (Read 1587 times)

0 Members and 1 Guest are viewing this topic.

DenisBrno

  • Newbie
  • *
  • Posts: 1
    • View Profile
Including OpenCV
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Including OpenCV
« Reply #1 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Including OpenCV
« Reply #2 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.