How do we modify OpenCV and generate new DLLs - c++

The OpenCV library is great. Most functions have the required functionality, however, I would like to modify some of the functions and recompile so that it fits my specific needs. how would we recompile the dlls and other files? is there a built-in script or do we need to write all the scripts ourselves?

According to the install guide, you'll need CMake to compile it on Windows.
I found this tutorial that shows step-by-step how to compile OpenCV 2.0 on Windows, but I believe the instructions also apply for compiling OpenCV 2.1.
This thread is directly related to what you aim.

Related

Possible to create a DYLIB from a C++ DLL project?

I have a C++ project that was used to create a DLL. Is it possible to take that C++ code and create a DYLIB file? I have only done a tiny bit of work with C++, so I am not sure if this can easily be done. Basically, I have an app that I rewrote in Python so I could run it on Windows or macOS. The Windows version of the app is able to use the DLL without a problem. Now, I would like to use the library with the macOS version of the app.
In general, of course, it is possible. However, whether it will be an easy job or not depends on whether how the library was written.
In the best case: you only need to recompile the library in macOS following its build instructions (e.g. typically explained in the documentation or in a README-style file in the root of the project).
In the worst case: the library is not portable at all (e.g. depends on the Windows API) and you won't be able to use it without rewriting it.
A side question is whether you really need the library: it is possible that you can find a Python library to fulfill the same job.

How to include OpenCV source code in C++ project to make it portable?

In my C++ project I use (3.1) OpenCV Mat for (only) storing and operating matrices (thus only the core module is used).
Now I would like to make the code portable: if a user (running Linux or Windows or OS X) takes my code then he can compile and run it, without installing the whole OpenCV pack.
Moreover, I would like the user to run the fastest version of the code (i.e. compiled in Release mode, Optimizations, etc...).
Could you please suggest a way to do that?
I copied the source code from modules/cores to the project directory but not sure how to proceed.
Thank you in advance for any suggestions!
You could do this by including the static library (a .a file) along with your package and linking to it during compile-time. Building OpenCV with -D BUILD_SHARED_LIBS=OFF as an argument to cmake should create the static files.

How can I get the boost numeric bindings?

I have a file that needs to use boost numeric bindings's library. How can I get that binding library?
The following link seems not able to work anymore. The zipped file is corrupted.
http://mathema.tician.de/dl/software/boost-numeric-bindings/
And I hope I could use it in Window and Visual Studio tool.
I have a file that needs to use boost numeric bindings's library. How can I get that binding library?
You can grab the sources of the current version via
svn co http://svn.boost.org/svn/boost/sandbox/numeric_bindings
The version from http://mathema.tician.de/dl/software/boost-numeric-bindings/ is an older version with a different interface. You can grab the sources of that older version via
svn co http://svn.boost.org/svn/boost/sandbox/numeric_bindings-v1
And I hope I could use it in Window and Visual Studio tool.
You need a blas/lapack library in addition to the bindings. For windows, Intel MKL, AMD's ACML, clapack and atlas used to work, last time I checked. (You only need one of these, but note that atlas only implements blas and a small subset of lapack). These libraries have widely different performance and license conditions, but they all implement the same interface (more or less).
In general, the people at http://lists.boost.org/mailman/listinfo.cgi/ublas seem to be helpful, if you try to use the bindings (or ublas) and run into problems. But I'm not sure if any of them checks here at stackoverflow for potential users that ran into problems.

Octave - .m-File Compiler?

I know that with Matlab it is possible to compile the scripts / functions as an executable which can then be a standalone version together with Matlab Compiler Runtime.
Is there any possible way to compile .m-files associated with octave as an executable program in a way that the .m-files aren't needed anymore for it to run?
I would like to a have a standalone version of the script (possibility together with octave libraries / dlls) without the necessity of the .m-Files.
I believe it is, see for example How do I create a simple Octave distributable without installing Octave, which references the relevant part of the documentation. However, I have never tried it, and it doesn't appear to be that straightforward (at first impression at least).

How to create a Standalone Executable program in C++?

I want to create a program that could work on any computer without the source code, How is that possible? and does it make any difference if I used OpenGL in the Program?
You cannot code a program in C++ that would work on any computer without giving your source code to be compiled.
For example, you could perhaps code in C++ a program, and compile it and build an executable which works on Windows x86-64, but that executable won't work on Linux (or MacOSX), and it won't work on ARM (e.g. Android phones) unless you consider using emulators
If you are developing your code with Visual C++ you may need to consider two options:
Make sure you link all libraries statically.
Install on the target computers along with your program Microsoft Visual C++ Redistributable Package corresponding to the Visual C++ version you use like the one at http://www.microsoft.com/download/en/details.aspx?id=5555. Some installer generating software will make it for you automatically.
Normally you would link your object file with some sort of a platform dependent loader. This loader loads your object and does all the stuff to start it from memory. Normally you can tell your compiler to link your object file and compile a blob. OpenGL is a powerful API and is usually distributed as a.dynamic linked library and is linked at runtime to your program. If I remember you just have to make sure the dll is where you want it and load the dll in your program from start.
Your C++ program is compiled and linked into an executable before it is run. You should be able to find that executable in a Debug or Release subfolder of the folder containing your project.
OpenGL, if you're not using GLUT or similar libraries, should just come with Windows and pose no additional problems. If you do use GLUT, it's enough to bundle the .dll file with your application.
In any case, the source code won't be necessary.
I want to create a program that could work on any computer without the source code, How is that possible? and does it make any difference if I used OpenGL in the Program?
By compiling and linking it into an executable. As long as you're not using some interpreted language (like Python, Ruby or such) you're presented with an executable inevitably. The biggest problem you may/will run into is dependencies on libraries. However those are linked into a binary as well. So what you're going to ship will be just a .exe; and some .dll maybe. Usually you'd wrap this in a installer package for deployment to the end user. Installers are created with something like the "NullSoft Installer System" (NSIS).
OpenGL itself is just a API, provided by a system library. So you don't ship OpenGL with your program, but expect the user to have it installed on the system (which will be the case if he installed the graphics drivers).