Upgrade OpenCV project to latest version - c++

I have a C++ logo detection project which uses OpenCV 2.3.1. I need to upgrade this project to OpenCV 3.0. For example instead of using (I actually mean replacing) IplImage I would like to use cv::Mat. I know that everything will not be automatically upgraded without some manual coding.
Question: I would like to know if there is any way to at least do some of the work automatically, by using a software or third party library.

I recently had to upgrade an old OpenCV project to make use of some extra features offered in 2.4.* versions (coming from version 2.2). There is no tool or library that will help you detect what you need to change. I had to upgrade and then fix certain parts of my code that used functions that had changed slightly.
A really neat resource you can use is this: API changes/compatibility report for the OpenCV library
It allows you to check the backward compatibility % between versions and see the main changes introduced in each library version. So you can use this to fix every conflict you see once you update the library to the version you want.

Related

C++ runtime compatibility in an iOS library

I need to distribute a closed-source library (in the form of a dynamic .framework) which uses C++ internally and exposes an Objective-C API at the module boundary. The library will be used by numerous clients in their apps.
As I understand, by default the C++ runtime is linked dynamically via libc++.dylib. So the question is: is the runtime compatible between iOS releases / compiler versions? Can my clients run into binary compatibility issues when using my library (e.g. OS is shipped with a different runtime version, producing subtle bugs in my library)?
Sidenote (as to where this question is coming from): On Windows, you would usually want to link the C++ runtime statically if you want to ensure that the binary works on all systems without the need to ship the specific version runtime component. So I wonder if the same problem existent on iOS.
Only Apple knows if or when some C++ library is no longer supported. My guess would be that apps depending on a no longer supported runtime would stop working completely or would not build with your library in the first place. I have found this info here (Xcode 10 (iOS 12) does not contain libstdc++6.0.9) indicating that, over the years, support for older runtimes may be dropped and then you'd need to build another library.
Speaking from past experience, we had an app - I know, not quite the same as a library - in the App store with a C++ core and Objective-C shim and did not care about C++ runtime compatibility. That never became an issue. Instead, from time to time (over several years and iOS iterations) there were slight user interface quirks that needed to be ironed out (I think with iOS7 - ok, you may not have an UI) then the forced move to 64-bit, then some API change where Apple wanted things that way or another... When there as an issue then we did a build with the latest XCode and that would have helped keeping things running, but the old version kept on working.
The upshot is, you'll need to be prepared to maintain your library and maybe something else 'gives' before the C++ runtime becomes a problem and then you'll just have to do another build for your customers.
If you are using libc++.dylib which is system wide library, then any application can also use it.
So by definition whoever delivers this library (Apple), is responsible for maintaining backward binary compatibility of this library.
If compatibility would have been broken, thousands of application would be corrupted.
On other hand if you are using some custom version of this library then it should be shipped with *.framework. In this case there is no risk of breaking compatibility since it is shipped with framework.
So basically there is no reason for you to worry about that.
If something is gets broken then lots of applications will be broken.
In the past new iOS versions have provided excellent compatibility with existing apps. If an app was built for an old iOS version, it would also run on new iOS versions. It seems that Apple simulates old iOS versions - including their visual style and quirks. If you run an app built for iOS 6 or earlier, it will still have the grayish look and not the new style introduced with iOS 7.
Once an app is updated, the story is different: you will need to use the latest Xcode, new rules apply and many old features will have been decommissioned. As part of this, Apple might remove APIs, switch to a new C++ compiler, change the standard C and C++ library etc.
So:
A released app in the App Store should continue to work for many years with your C++ library.
However, for the development of new apps or new version of an existing app, you will need to check the compatibility of your library regularly and possibly provide updated versions.

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.

Why compile OpenCV with QT?

I am using Qt & OpenCV on a new project am about to compile OpenCV to work with MinGW.
A thought has arose that I can compile the OpenCV libs with Qt support but I don't really understand why I would want to do that. If I don't compile the libs with Qt support I can still route cv::mat to a QImage using a method like this.
So what am I missing? What value is provided in compiling Qt with OpenCV?
I have searched online and pages like this, this & this (from searching "why compile OpenCV with Qt") only show me how to compile with Qt and not why.
LE: misunderstood the question
WITH_QT option is used by highgui module to create windows using qt, so the QImage to cv::Mat conversion and vice-versa will work no matter how WITH_QT option is set.
First some clarifications: you are not compiling OpenCV with Qt, Qt is not a compiler so you can't compile anything with it.
Qt is a C++ library (it's called a framework because it imposes some design some rules to your application source code, but basically it's a C++ library, just like OpenCV).
Now, in C++ world* to use some libraries together you need to build those libraries with the same compiler (and in some cases even the same compiler settings), so must decide which C++ compiler you want to use and get both Qt and OpenCV built with the same compiler not necessarily build by you, binaries can be obtained from their websites.
If you want to use MinGW you will need to build OpenCV with MinGW compiler, because OpenCV (at least, version 2410) comes build only with Visual C++ version 10, 11, 12 - that means Visual Studio 2010, 2012 and 2013.
So if you decide to use some Visual Studio version, depending on version you choose, you might be able to use Qt with OpenCV without having to build neither yourself, but if you want MinGW compiler you need to build OpenCV with MinGW.
*you can get away with it if your libraries only export a C interface, but that is not the case with neither Qt nor latest OpenCV versions.
//if you want more details about this use your favorite internet search engine to search for: c++ binary compatibility and or c++ abi
You'd like to compile OpenCV with Qt for at least two reasons:
it gives you the zoom (mouse wheel) in imshow
it gives you the pixel RGB value when hovering over this pixel
Without WITH_QT, you just have a bare window, with none of these features (and you'll miss extra buttons too, like Save the picture), which make the image processing debugging more tedious.

GIS extension of Boost.Geometry

I am using Boost 1.50.0 and I need to use the GIS extension of Boost.Geometry. Where can I find this extension for Boost 1.50.0 or lower? (I haven't upgraded my application to newer version of Boost due to some compatibility issues.)
The extensions are a part of the development version of a library, they're not released. So in order to use them you should probably checkout/clone (and use) the development version of Boost.Geometry. You could also try to mix the released version and the extensions from the development version but I'm guessing this way it'd be easier to make some mistake which would e.g. result in unwanted incompatibilities.
Anyway, the most simple way of doing it would be to see which commit was the most recent one in the Boost.Geometry released in Boost 1.50 (boost-1.50.0 tag in Boost.Geometry repository on GitHub):
https://github.com/boostorg/geometry/commits/boost-1.50.0
and then try to find a corresponding one in the develop branch:
https://github.com/boostorg/geometry/commits/develop
Note that you can find some commits in both branches that can't be found in the other. I don't know if that's because SVN was used back then or the reason is different. In your case I'd try with this commit from boost-1.50.0:
https://github.com/boostorg/geometry/commit/443b01bc07b0fb329aee803ea1bef6a8f14e449b
which seems to correspond to this commit in develop:
https://github.com/boostorg/geometry/commit/d35eb8f2dff20e61655fcef5ee4a23ca4d9d9847
so this is the develop tree:
https://github.com/boostorg/geometry/tree/d35eb8f2dff20e61655fcef5ee4a23ca4d9d9847
which you should be able to download by clicking the "Download ZIP" button on the right side of the page. Then you could use it instead of the released version or just extract the extensions from it, etc. Just have in mind it's not officially released version and that no guarantees can be made.
Here you can see the extensions in that tree:
https://github.com/boostorg/geometry/tree/d35eb8f2dff20e61655fcef5ee4a23ca4d9d9847/include/boost/geometry/extensions

Wii MotionPlus support

I am developing a PC application that interacts with the Wiimote. So far I have been using the wiiuse library, which has worked great.
However, wiiuse does not support the MotionPlus extension.
I have heard of extensions to implement this by Dolphin and libogc but have not managed to locate this code.
Do you know of code that implements support for MotionPlus with wiiuse, or another C based libary?
I found that fWIIne has a modded version with MotionPlus support, though only in the release zip file and not the repository.