简体   繁体   中英

OpenCV Program does not work on another computer

I downloaded opencv-2.4.9.exe and I opened it D:\\opencv directory.

After that I wrote an OpenCV library with Visual Studio 2013 and also a wrapper DLL. I used this wrapper DLL in a C# Windows application. It worked perfectly on my computer. But when I copy and run it on another computer, it gives me an error. The error says that it cannot find the OpenCV DLLs.

Here are the sources that I used:

https://marcomuraresearch.wordpress.com/2015/04/16/install-opencv-visual-studio/comment-page-1/#comment-181

https://drthitirat.wordpress.com/2013/06/06/use-opencv-c-codes-in-a-vc-project-solution-of-creating-a-managed-clr-wrapper/

How can I make my program run on any computer even if OpenCV doesn't exist?

When you make your DLL wrapper you can do it two ways: You can choose to link against the OpenCV DLLs or to compile OpenCV as a static library into your DLL. Presumably you are currently linking against the OpenCV DLLs, which means that your DLL wrapper is looking for the OpenCV DLLs when it gets loaded so that it can execute code from those DLLs. If you have OpenCV installed on your system it is possible that you have the OpenCV DLLs in your OS' Path and therefore it can find the OpenCV DLLs on your computer. When you go to another computer this may fail. You have two options.

  1. Distribute your DLL alongside the OpenCV DLLs. (You don't need to install anything extra on that computer, just make sure all of the DLLs are in the executable's directory).
  2. Compile OpenCV as a static library into your DLL wrapper project so that all pertinent executable OpenCV code is contained in your DLL. This is less-commonly done so it might require a bit more effort, but you can probably find some good resources on how to do this via your favorite search engine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM