Question

I can't seem to find a way to create a standalone package for image recognition. I have a project I'm writing in python, and I found a way to do what I need using OpenCV, but I can't find a way to import the library into my project unless it is installed at the system level on Ubuntu. In other words, I can't seem to plop the build folder into my project after building the OpenCV library. And I can't find the equivalent of cv2.matchTemplate() in PIL or Pillow. So really there are two questions here.

1) How can I attach the build folder to my project, in order to avoid installing the OpenCV at the system level.

2) Is there an equivalent of cv2.matchTemplate() in PIL or Pillow that I can't seem to find?

Thanks.

Was it helpful?

Solution

You need to:

  • Download OpenCV
  • Use CMake to tell it to compile statically and to tell it to compile the Python module
  • Compile, and install into a directory you want.
  • Find in that directory the file under a directory called python, called cv2.so
  • Distribute that file with your Python code.

Now that I told you how to do it, let me tell you why your approach isn't a very good idea:

  • If the version of Python changes, you need to recompile (the so file) and redistribute your entire application
  • If the version of OpenCV changes you will need to recompile (the so file) and redistribute your entire application
  • You don't control what version of Python your users have
  • There can be important subtleties in version of libjpg, libtiff, zlib and others that could prevent your application from working, all outside your control.
  • You are converting a multi-platform application into a platform specific solution.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top