OpenCV C++ Tracking API - c++

I've built OpenCV from source along with the contrib modules. But when I include the tracking module with:
#include <opencv2/tracking.hpp>
or
#include <opencv2/tracking/tracking.hpp>
or
#include <opencv2/video/tracking.hpp>
and then try to use a tracker like this:
cv::Ptr<cv::Tracker> tracker;
I get an error saying that "Tracker is not a member of 'cv'".
What is the proper way to include the tracking API and how can I troubleshoot possible installation errors?

Related

Files/directories to include in Visual Studio C++ to use CUDA?

I want to use CUDA/GPU in OpenCV in Visual Studio. For example, cuda::GpuMat. I successfully build OpenCV with the extra modules with CUDA enabled
I tried the following code
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/photo/cuda.hpp>
#include <opencv2/photo.hpp>
using namespace std;
using namespace cv;
int main(){
string imageName("input.bmp");
//CPU version
Mat image = imread(imageName.c_str(), IMREAD_GRAYSCALE);
//CUDA version
cuda::GpuMat imageGPU;
cuda::GpuMat downloadGPU;
Mat buff;
imageGPU.upload(image);
downloadGPU.download(buff);
imwrite("gpu.bmp", buff);
return 0;
}
But I get an unhandled exception error.
I originally downloaded OpenCV in C:\Users\me\Downloads\opencv
I then downloaded and installed the latest OpenCV extra modules with CUDA on in
In Property Pages->C/C++->General->Additional Include Directories, I have:
C:\Users\me\Downloads\opencv\build\include\opencv
C:\Users\me\Downloads\opencv\build\include\opencv2
C:\Users\me\Downloads\opencv\build\include\
In Property Pages->Linker->General->Additional Library Directories, I have:
C:\Users\me\Downloads\opencv\build\x64\vc15\lib
and in Property Pages->Linker->Input->Additional Dependencies, I have:
opencv_world343d.lib
opencv_world343.lib
what else am I supposed to include so I can get GpuMat to work properly?
Most of the cases, yes, but you need to know which library you need to add, it may be cufft.lib, cublas.lib, cudnn.lib, etc. It depends of the function you use inside your code.
Opencv includes a cmake include file that would set all of this up for you if you use cmake to build you VS test project. This file will be in the root of the opencv install directory, i.e. after building opencv running cmake --install or the equivalent in VS. The file is OpenCVConfig.cmake, and it would be included in the CMakeLists.txt file for your project. Then you would call FindPackage(OpenCV), which would locate the OpenCV install, setup a few variables, which you would then use to link against your app.
I can post a sample CMakeList.txt file if you feel that would help.

How to get Image using opencv as input for C++ program

i made a code for solving soduko and now i want to convert sudoku of real life to digital grid using opencv. But i can't import libraries in vscode 2019. Plz help. i get include error
i can't find anywhere how to get it to work. I dont want to work in visual basic but just c++ file
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
so i get import errors on these and i can't find where to import it. I added to Path the opencv bin folder

CGAL file not found after installation

I recently installed CGAL from their website. I used the native installer that is up to download on the website, and after selecting a directory, the installation completed. I am looking through the User Manual and trying to run some basic code, but I keep getting a compiler error. The code that I run is this (it is straight from the user manual):
// example: construct a quadratic program from data
// the QP below is the first quadratic program example in the user manual
#include <iostream>
#include <cassert>
#include <CGAL/basic.h>
#include <CGAL/QP_models.h>
#include <CGAL/QP_functions.h>
// choose exact integral type
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpz.h>
typedef CGAL::Gmpz ET;
#else
#include <CGAL/MP_Float.h>
typedef CGAL::MP_Float ET;
#endif
int main()
{
}
It is just a simple QP problem, using the syntax straight from the website. However, when I try to run it, I receive this compiler error:
C:\...\include\CGAL\config.h|161|fatal error: CGAL/compiler_config.h: No such file or directory|
I used the installer straight from the website, but CGAL is still giving me these issues. Does anyone know how to solve it? Thank you.
According to the documentation (https://doc.cgal.org/latest/Manual/installation.html#title5), after installing CGAL on Windows, you still need to build the library itself.
This process will (I suspect) create the missing configuration files according to the compiler you have (gcc 7.3).

OpenCV on C++/Namespace issue?

I am new to C++ so I get some trouble to use openCV on my C++ project. I'm using Xcode as an IDE.
So I used brew to install opencv using the two command lines:
brew install opencv3 --with-ffmpeg --with-tbb --with-contrib
brew reinstall opencv3 --HEAD --with-python3 --with-ffmpeg --with-tbb --with-contrib
I checked the path to add to my project to load the library using recursivity, so I added on Xcode the path for header path and library:
/usr/local/Cellar/**
I also tried to install it another way, but still got the same issue:
brew install opencv
And adding the path to:
/usr/local/include/**
Everything seems to work since the library is detected, but import is not working because I got namespace errors in the openCV files, for instance:
No type named 'unique_ptr' in namespace 'std'
No member named 'allocator_traits' in namespace 'std'; did you mean 'allocator_arg_t'?
I checked on the internet and maybe it should be due to the the C++ language dialect or standard library, but I use GNU ++ 14 and libc++ . From what I found it should be working in that config, but I still got the issues. Do you have any ideas ?
EDIT: I don't even try to use it yet, I just used the include and print an hello:
#include <iostream>
#include "cv.h"
int main(int argc, char *argv[]){
std::cout<<"hello";
}
I also tried cv.hpp instead of cv.h, still not working
Thanks a lot !
I don't think you are using the correct #include paths, if you look at the OpenCV Example, you need the following for OpenCV 3.0 to open an image:
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
None of these are like the headers that you have, which are likely for older versions.
This tutorial looks like a very sensible one to get up and running with xcode, and the example at the bottom looks like a better start

OpenCV: ‘AlgorithmInfo’ does not name a type while building opencv_contrib

I am getting the following error while trying to build opencv with the contrib module
/opencv/opencv_contrib/modules/tracking/include/opencv2/tracking/tracker.hpp:577:11: error: ‘AlgorithmInfo’ does not name a type
The code is latest and pulled just now.
After adding a forward declaration class AlgorithmInfo; to the file tracker.hpp that particular error is gone but I am getting other '‘AlgorithmInfo’ does not name a type' errors in other files. Probably AlgorithmInfo is not getting included somehow. Any ideas?
Investigation:
After grepping AlgorithmInfo I found that there is no defination of AlgorithmInfo in the code base.
Comparing to the previous version of code I found AlgorithmInfo is defined at opencv2/core.hpp line 3006. But in the latest code, it is not present there at all!
This is not a permanent solution but I had the same issue and here is how i was able to continue work on the project until someone finds a better way.
I looked at the link that Utkarsh posted How do I use SIFT in OpenCV 3.0 with c++?
To summarize I had to get the opencv_contrib repo and remake opencv.
After doing so I still got the same error and eventually realized that
you must include
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/features2d/features2d.hpp"
but you still get the same unless you also remove/comment out
//#include "opencv2/nonfree/features2d.hpp"
//#include "opencv2/nonfree/nonfree.hpp"
anyway this is how i got around the error for the time being.