Edit C++ project in VSCode and OpenCV without installing the whole library - c++

I am working in a C++ project with OpenCV in Windows and VSCode. The project is meant to be built and run in a Docker Container, thus I do not need OpenCV in Windows. If needed, I use OpenCV as installed in WSL.
VSCode complains all the time in #include <opencv2/opencv.hpp> about not being able to find the library, and consequently it refuses to look for errors along the rest of the file.
I do not need OpenCV and I know that the compiling process can become tedious over Windows, so I would like VSCode to ignore this error and go on checking the rest of the files. Having IntelliSense working with OpenCV classes would be ideal.
Is there some way to have this without installing OpenCV in Windows?

This sounds like a good use case for VS Code Dev Containers. Dev containers let you use a docker file to define an isolated linux based development environment—including which tools and libraries are installed—in a reproducible way that does not effect your local machine.
Check out the Dev Container docs and the example c++ dev container for help getting started. If you already have an OpenCV docker image, you can use this as the base for your dev cotntainer

If you are using VSCode on Windows and would like it to OpenCV that is in WSL, you will need to install an extension on VSCode called Remote - WSL, developed by Microsoft.
You'll be able to use Linux specific toolchains, utilities and even run Linux-based applications directly from VSCode on Windows..

Related

How to deploy a Tensorflow trained model for inference for a Windows standalone application

I would like to use a model trained with Tensorflow in a Windows standalone desktop application. I only need to perform predictions, I can train the model with Tensorflow Python API. What is the recommended approach?
I know there is a C++ API, but it is really hard to compile it, especially on Windows. Can I find any prebuilt C++ Tensorflow binaries for Windows?
Is there an easy way to distribute Python with Tensorflow as a Windows installer prerequisite?
Can I import the Tensorflow model in another technology and use it for inference? OpenCv DNN module has a function which imports data from Tensorflow, but I understood it has many limitations, and I was not able to import and use a model with OpenCv.
Thanks for help!
I was challenging the same issues as you.
You should at least try to compile it (try CMake, it might be easier)
If you still having trouble:
Compiler is out of Heap Space
Standalone Windows Lib
Basic Tensorflow Handling with C++
I asked a similar question and eventually found my own way to the answer. In the end, I found the Tensorflow instructions were actually pretty good (it was my reading them that was bad!). I have not tried using Bazel for Windows, but building Tensorflow using CMake ended up working fine.
The main issue was the compiler heap space issue. This always seems to occur in some random place if you are using the MS Visual Studio 32-bit compiler (default). The key is to make sure you run vcvarsall.bat or vcvars64.bat or whatever it takes to invoke the 64-bit compiler (in Task Manager, it should show up as cl.exe, not cl.exe *32) I found it hard (read: impossible) to get Visual Studio to use the 64-bit compiler, but using the MSBuild tool to compile on the command line worked fine.
Once you can build the example program, you have an example of an application that links to a static tensorflow library to do its stuff. You can just make your own application link to this library for what you want.

Cross-compiling C++ OpenCV from Visual Studio 2013 on Windows to Ubuntu

I've got a C++ VS2013 solution with 3 projects, using OpenCV 2.4.10, easylogging++ and Dlib libraries. The problem is that our client is now migrating to Linux (Ubuntu Server). I've looked into Cygwin and MinGW and a few questions here on stackoverflow, but I'm still lost as to where I should start. I need this done as soon as possible, so the simpler solution would be best. I really appreciate any help you can provide.
I recommend using cmake build system on ubuntu. Using Opencv and easylogging on ubuntu out of the box could be a matter of minutes. dlib's website also mentions a simple cmake building steps that works on ubuntu.
After you get your libraries up and running, build your code and see if there are any system-dependent functions then google how to standardize them across systems. If your code is already standardized it should run right then and there.
You can then ask about any specific issues you meet on the way.

What's the simplest way to run an OSX openFrameworks project on a Raspberry pi?

I've built a relatively simple oF app which uses several 3rd-party addons. I've created the project with the project generator, and coded the whole thing in Xcode on OSX.
Now, I need to use this app on a Raspberry Pi running Raspbian. I've successfully compiled the armv6 version of oF, but I now need to compile the actual project.
So far I thought of the following options:
Try to get code::blocks running on the Pi, install oF for codeblocks, recreate the project and build.
Try to set up Ubuntu as a virtual desktop on my mac, set up a cross-compiler like this, recreate the project and build.
Pretend to be a magician – set up the OSX project on the Pi so that I could maybe compile it with make, except I have no idea whether this is possible at all.
???
So my question is: Given a severe deficiency of time and general skill when it comes to linux/compiling C++, what is the easiest way for me to get my oF app running on the Pi?
Many thanks!
The absolute easiest (and perhaps even fastest when accounting for the extra cross-compiler setup time) way is to use a Raspberry Pi 2 and compile everything directly on the board using all 4 cores. It is actually quite quick and easy to set up. To set it up, follow these instructions:
http://forum.openframeworks.cc/t/raspberry-pi-2-setup-guide/
If you would like to use a more friendly IDE like Xcode, I would recommend developing your code on OSX and then copy the project folder over to the Pi2 and execute the makefiles as noted in the setup guide above.

Tesseract + OpenCV + linux

I have developed an OCR application on Windows using OpenCV and Tesseract. Now all I want to do is to write same application over Linux (Ubuntu 12.10) in C++. And I don't have any experience in Linux development. I don't know where to start. All I want is developing environment in which I would able to link these two libraries OpenCV and Tesseract.
Please suggest me. I have tried searching Google but failed. Maybe I am not searching with good keywords. As I am totally new in Linux
First make sure that you compiled OpenCV on your system, as OpenCV's linux bundle hasn't got pre-compiled libs (unlike Windows bundle). Follow this tutorial.
For a starting point, build up Eclipse as IDE and follow this tutorial. It shouldn't be so hard to adopt if you already used Visual Studio (MSVC Windows compiler).
Later on, it would be wise to learn about gcc (official linux compiler for your c++ code) and its syntax, and maybe together with CMake. Because learning the terminal and g++ syntax suddenly accelerates the development process. Linux has got many opportunities for a developer, such as pkg-config, which links all the libs and headers automatically (well, almost). You can also go for learning CMake for cross platform development and let it use "gcc" by default; example here.
Also note that, using cygwin, you can actually compile & build linux binaries on a Windows platform. For the opposite; check MinGW.
Good luck.
EDIT: other cross platform solutions
VisualGDB
Qt

How to install MinGW correctly on Windows

I have recently started learning C++, but I require a compiler. I have tried the one packaged with Code::Blocks, but I have been told it is out of date.
I have tried reading the instructions on the website, but I simply don't know which files to download and un-zip. Is there a list of files to download? (latest version) and a folder structure I need?
I was the person that pointed you at the more up-to-date version at Twilight Dragon. The file you want there is http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-4.4.1-2.exe/download which is a Windows binary installer - you just run it. Note that you don't actually need to do this - the version that comes with Code::Blocks will work OK for someone starting to learn C++.
I recommend using a pre-packaged MinGW that includes some common APIs like Boost, SDL etc: http://nuwen.net/mingw.html
If I remember correctly, the only thing you must do to get it working is to modify Windows's PATH environment variable.
edit: OpenAL is not included in this package.
Here are some instructions to have a MinGW setup that I used to build Octave modules.
I have switched to using the build environment for msysgit. Just download the netinstall file and it will setup GCC, Make, etc. along with Git.