Python C++ binding in OpenCV - c++

What technique/library is used for Python binding in OpenCV2.0?
I am aware there there are a number of libraries for C++/Python binding and that previous versions of OpenCV were using SWING library.
I am testing Python in Python Tools for Visual Studio which has code completition (intellisense) built in. However, for current OpenCV Python bindings it displays only function names in interactive window. In editor, it does not even display the function names.
Is it possible to have intellisense working on parameter level for C++ Python bindings?

What technique/library is used for Python binding in OpenCV2.0?
Vadim Pisarevsky, one of the core developers of OpenCV, has given a brief answer for this question here: How Python API is generated?. He says:
We do not use SWIG or any other standard wrapper generation tool. We
did not find such tools that would produce satisfying results.
Instead, we use our own purely Python-based solution for parsing
OpenCV headers
The parser is at opencv/modules/python/src2/hdr_parser.py
After all the API is extracted, we use some more python code
(opencv/modules/python/src2/gen2.py) to produce Python wrappers.

Related

How to build and use the C++ API for Tensorflow on windows

Has anyone been successful in building/using the c++ API for TensorFlow on windows (withing Visual Studio)? The tutorials I found online or on TensorFlow's website have only shown building from source for python, or are outdated (3+ years old or for TensorFlow 1.x)
I see that there are docs for the functions of the built C++ API on TensorFlow's website, but there's no mention of where to get it or how to build it, the build from source section builds the python package that can be installed using pip, not anything that can be used with C++.
I've looked at the C api, but that seems to be different from what is mentioned in the C++ API section of the docs, and I was unable to get the C API working within VS due an error in mixing C++ and C.
If it helps, the end goal is to run inferences for pre-trained models (built using the python API) using C++.
Any help is appreciated.

How to program with C++ API library on Windows using Bazel?

What I want to do
First of all, my goal is using Tensorflow C++ API as a library on Windows, which is part of my project, instead of building my project inside Tensorflow.
Background
I had achieved this by building Tensorflow with CMake. However, from Tensorflow 1.10, building with CMake was deprecated and Bazel is recommended instead. But the official way to use C++ API is building project inside Tensorflow with Bazel. Thus, this way is not good for me.
What I have done
To use a newer version of Tensorflow, I have been trying to build Tensorflow with Bazel as a standalone library.
Some maintainer denoted that it is possible by substituting //tensorflow/tools/pip_package:build_pip_package to //tensorflow:libtensorflow_cc.so in the official tutorial. But in fact I encountered some problems and solved them by reading this tutorial. Now I have successfully built libtensorflow_cc.so.
What the problem is
However, I have no idea what should be done next to use the built result. And it is exactly what my problem is. There is no documentation of course. Only some incomplete ideas on it I have found, and I will show all of them, trying to give you more information:
There is somebody already successfully linking built *.so and having solved the problems he has encountered.
There is a repo doing the what I want to do on Ubuntu and Arch Linux. I have contacted with the maintainer and he told me that they have no plan for supporting Windows now.
A related issue: Building a .dll on Windows.
A related issue: Packaged TensorFlow C++ library for bazel-independent use.
A related issue: Feature request: provide a means to configure, build, and install that includes cc.
A related question: How to build and use Google TensorFlow C++ api. The scope of this question is a little larger without 'using bazel' and 'on Windows' restrictions.
A related pull request: C++ API
There must be someone struggling with similar problems like me. I hope this question can build a reservoir of ways to solve the problem.
It's over 2 years since this question was asked, and the news is not good: it seems there are insufficient people with Windows skills in a position to provide the support to integrate Tensorflow into Windows applications using the familiar headers + library model. And Tensorflow advances week by week, meaning that the Windows support falls further behind.
In my assessment, the path to building on Windows is currently blocked due to inadequate documentation. It's not so much that "There is no documentation of course" as the OP asserts, it's that the sparse documentation is distributed throughout dozens of separate posts, each of which dates rapidly with the continuing development of the Tensorflow along paths other than Windows C++.
I originally gave this answer to a similar question, but updated it with advice along the following lines yesterday:
Windows is a Microsoft product, so watch what Microsoft is doing
Hint: Microsoft is investing in the ONNX format
you can convert Tensorflow to ONNX, or Keras to ONNX
You can implement your (ONNX) model on Windows in C++ in at least 3 ways:
Windows ML (uses Onnx runtime)
Onnx runtime (supports DirectML as an execution provider)
DirectML (how Microsoft uses graphics cards to boost performance)
We don't have the latest or best hardware (e.g. we have Intel graphics cards), but have been able to get a solution based on Onnx runtime that classifies 224 x 224 RGB images in about 20 milliseconds for us. We found the Windows ML path much more difficult to work with legacy code, and also slower to run.

How to Integrate C/C++ python modules with PVTS projects/VS 2013 Solutions

I have installed VS2013 Express Edition and wanted to use the PVTS plugin to manage Python based web application solutions. Apparently the PVTS plugin cannot be installed for an existing VS Express Edition (vs Professional/Ultimate Editions)
Also I'd like to have some support to edit python pyramid compatible view templates (i.e. simple (X-)HTML editing?!?), but that's a nice to have.
So since the plugin doesn't work for the Express Edition: Is there a way to tell the standalone PVTS VS installation about C/C++ projects & integration?
PTVS Integrated does not come with VS Express - rather, it comes with VS Integrated Shell. The net effect is kinda similar to "Python Express", but one subtle difference is that Shell permits installation of other extensions into it. Also, unlike Express, it is not separate from VS proper - i.e. if you install VS Professional or Ultimate on a machine with PTVS Integrated, it will replace and subsume the Shell.
Unfortunately, Shell does not come with editing and project system support for C++ - it has the full-featured native debugger, but nothing else. Since said C++ support is not distributed as extension, there's no way to add it to PTVS Integrated without upgrading to VS Professional or higher.
What you can do is use VS Express and PTVS Integrated open side by side with the same solution, which includes both your Python project and your C++ project. Express will not be able to show Python projects, and so they will show up as "unavailable" there, but it will give you a good C++ editing story and the ability to build the module. PTVS will show C++ projects as "unavailable", but it will give you a good Python and HTML editing story, and the ability to debug Python & C++ side by side. Unfortunately, this means no build/run integration, so you'll need to remember to build the C++ project in Express every time you want to run the Python project in PTVS.
With respect to HTML editing, the template language used in Pyramid does not have any special syntax above that of HTML, so the stock VS HTML editor should provide reasonably good experience. PTVS does not have any special support for Pyramid beyond that, neither for template editing nor for the project system, but there is a feature request for it in the tracker, and we're planning on adding project system support for it in 2.1 - have a look at the functional specification for more information on what's coming up.

How do I run mercurial queries from C++ (cross-platform)?

I would like to run some mercurial queries from C++ and get some results (similar to what we get on the command line) and would like it to be cross-platform. Any way to accomplish this without using Mercurial python API (I am hoping to see a wrapper that someone has already built in C++ or in C)?
Better than using the python API would be interfacing with the Mercurial Command Server though it does not yet have a C / C++ wrapper.
https://www.mercurial-scm.org/wiki/CommandServer#Libraries

Converting Matlab to C++

I need to convert some MATLAB code to C++. I am using Visual Studio 2010 and have MATLAB compiler installed. I am wondering how do I go about doing this.
Also when I publish my project will the end user have to install anything by MATLAB? (this cannot be the case)
You can compile Matlab scripts into standalone executables, but I'm not familiar with a Matlab tool to convert Matlab code to Visual C++ code. You can convert Matlab code to C or C++ using Simulink Coder (formerly Real-Time Workshop), which is available from Mathworks as a separate product.
To run the standalone executable, the user will have to install the Matlab Compiler Runtime. From the Matlab Compiler web page:
Executables and libraries created with the MATLAB Compiler product use a runtime engine called the MATLAB Compiler Runtime (MCR). The MCR is provided with MATLAB Compiler for distribution with your application and can be deployed royalty-free.
You will not get rid of the Matlab runtimes. I often had problems using Matlab Compiler. It basically is like a wrapper around the Matlab runtime, generates clumsy code and did introduce many problems for deployment. C alternatives ... ? I could not find any. So I recently switched to ilnumerics, which is like Matlab in C# - only much faster and no translation necessary. it works out great so far because we use ASP.NET anyway and hence save jumping between languages and can directly use the 3d plots of ilnumerics.
Another option you have is to use the MATLAB Engine. It probably isn't an option for real-time applications, but otherwise it's really nice. You basically call MATLAB functions right from C++. Figures (plots) will be display just as if you were running local MATLAB. When the program starts, a MATLAB console is created.