OpenCV "cvaux.h" equivalent - c++

I am new to opencv and am using OpenCV 3.0.0. I found an example using include "cvaux.h". But, I want to use the new features rather than old C functions.
So, what is the equivalent hpp file for "cvaux.h"? Thanks

If your example is actually using cvaux.h, then you probably need to get a newer example. cvaux is related to obsolete C api and is now deprecated.
However, it can be found in: #include <opencv/cvaux.h>.
Note that most of the time you can just use the "include all" header: #include <opencv2/opencv.hpp>

Related

Error while compiling eigen program: error: 'seq' is not a member of 'Eigen'

I am trying to index a matrix in indexes which follow an arithmetic sequence. According to the Eigen tutorial on the official website, I should use Eigen::seq(firstVal, lastVal, step) to generate this sequence. After calling this the error, as pasted in the title of this thread pops up.
I checked all the files of my local eigen folder, for the 'seq' method, but no luck. It wasn't anywhere. I guess this means that some file is missing, right?
Code goes smth like this.
Headers at the top
#include <iostream>
#include <string>
#include <chrono>
#include "Eigen/Dense"
#include "Eigen/Core"
#include <cmath>
#include <random>
m1(row, Eigen::seq(some_index*m1.cols(), some_index*m1.cols() + m1.cols()-1, step))= m2.block(row, 0, 1, m2.cols());
where of course, m1.cols() >> m2.cols()
Error output:
error: 'seq' is not a member of 'Eigen'
The expected result would be to get the row from matrix m2 (where m2.cols() < m1.cols()) and assign the row's values to certain indexes in the same row number of m1.
After inspecting the official repo
https://bitbucket.org/eigen/eigen/src/default/
The required function is in the file Eigen/src/core/ArithmeticSequence.h which is included in the general header Eigen/Core already used in the snippet.
The issue seems to be that OP downloaded Eigen from a third-party repo not in sync with the main repo and the aforementioned file was missing.
I add this note for posterity: The latest stable release at the moment of writing is 3.3.7, released in 2018, (see http://eigen.tuxfamily.org/index.php?title=Main_Page), and does not include the file. So, if anybody else finds the same issue, please try to clone the official repo.
The required function is in the file Eigen/src/core/ArithmeticSequence.h which is included in the general header Eigen/Core. So #include "Eigen/Core will suffice. (As #CuriouslyRecurringThoughts pointed out).
However, to address the confusion in his answer: ArithmeticSequences such as Seq are planned for Eigen version 3.4.0 So they are not present in versions prior to this. When I write this, the latest official release is 3.3.9 which thus doesn't support ArithmeticSequences.
If you look in the official repo, you will find that the file is also not present for release 3.3.9 and earlier. Right now, it is only included in the 3.4.0-rc1 and master branch.
So to answer your question: You are most likely using an older version of Eigen and you will need to use Eigen 3.4.0-rc1 or later.

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

Linking error while using Armadillo and Lapack

my name is Ulrich and I just started writing my bachelor thesis, which includes a part where i write a program, which needs a Singular Value Decompostion.
At first i need to say, English is my 2nd language and I'm totally new to programming. So please help me with easy words ;)
After some research, I found that Armadillo offers a good SVD()-function, which is based on the Lapack library, so I downloaded them both and tried to install them correctly, and I think i failed at that part:
So here is the relevant parts of my written code:
#include <iostream>
#include <vector>
#include <random>
#include <time.h>
#include <math.h>
#include <fstream>
#include <cmath>
#include <sstream>
#include <armadillo>
using namespace std;
using namespace arma;
mat A(N,2*N+1, fill::zeros); //the zeroess will be replaced later, don't worry i know a SVD of zeroes is stupid ;)
mat U;
mat V;
vec S=svd(A);
The compilation error is:
undefined reference to 'dgesdd_'
What I use:
Code Blocks with MinGW compiler (Probably latest version; I installed it 3 days ago).
Armadillo Library 4.650.4
Lapack Library 3.5.0
Windows 8.1
What I have done:
I linked in the settings of Codeblocks the compiler with the Folder containing a lot of .header files from Armadillo (.../include/armadillo_bits/)
and i linked in the same way the Lapack folder with 4 .header files(.../lapacke/include/)
Furthermore the readme from armadillo said I shall comment out certain lines from a file called config.hpp
i looked through the whole file, but i think i don't have to uncomment anything. but just in case you need to see it, I can upload the file for you.
PS: while searching for a solution I came across this question which looked quite similar to my problem and seems to be easy fixable, but unfortunately I don't understand anything of it:
Question from stackoverflow
i hope you can help me with this,
Ulli

opencv errors while using with windows form applications

I am using opencv with visual studio 2010 windows form application c++. but it wont allow calling inbuilt functions. It gives errors like
Error 1 error C3861: 'cvCvtColor': identifier not found c:\users\ayesha\documents\visual studio 2010\projects\abc\abc\Form1.h 140 1 abc
Error 2 error C3861: 'cvCvtPixToPlane': identifier not found c:\users\ayesha\documents\visual studio 2010\projects\abc\abc\Form1.h 146 1 abc
I have added the following headers
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
Can anyone please tell me what i am doing wrong.
Unfortunately, OP doesn't say what version of OpenCV he uses.
While working with OpenCV 3.0, use cvSplit() instead of cvCvtPixToPlane().
cvCvtColor() shall work with OpenCV 3.0, provided you added the required header files to your projects.
Finally, to make sure you don't miss any required files in your project, just start your code with #include <opencv2\opencv.hpp>.
cvCvtColor is a C API function of OpenCV, but you're intending to use the C++ one. You have 2 ways of fixing the problem:
1) (Recommended) Change your source code to use the C++ API. You should use cv::Mat instead of CvArr, cv::cvtColor instead of cvCvtColor, etc.
2) Since such changes in the source code can be pretty involved, you can still use the C API by including C-headers
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core_c.h"
#include "opencv2/highgui/highgui_c.h"
instead of the C++ (*.hpp) ones
The error you've mentioned it is a linker error I suppose.
As you're including two headers highgui.hpp and highgui.h targeting to an identical library which is opencv_highgui23#.
Just include only one header.

Background Subtraction – Stauffer & Grimson’s Algorithm in opencv's latest versions

There is an implementation of that algorithm in opencv version 1.0 the function is cvCreateFGDStatModel to create the background model. But I can't find it in latest versions. Does anybody knows if it was removed or renamed? And if you know other open source of that algorithm please tell me.
It's still there, just add the appropriate include:
#include "opencv2/video/background_segm.hpp" // on OpenCV 2.3, it's inside this header!
#include "cv.h"
#include "highgui.h"