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

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"

Related

UE5 OpenCV: Can’t grab VideoCapture

I’m trying to read camera input using the built-in OpenCV library in UE5 but no matter what I do, I can’t seem to make cv::VideoCapture.read() return anything. cv::VideoCapture.grab() also returns false every time.
It works fine on the same machine with regular C++ with OpenCV 4.6.0 and the VideoCapture is definitely open and the camera turns on as expected.
Is there something about Unreal’s built-in implementation I need to know about? (Other than it used OpenCV 4.5.5). I can’t seem to find any info online about this.
This is what my header files look like:
#pragma once
#include "PreOpenCVHeaders.h"
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc.hpp>
#include "PostOpenCVHeaders.h"
#include "CameraReader.generated.h"
And my Plugin’s Build file:
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"OpenCVHelper",
"OpenCV",
// ... add other public dependencies that you statically link with here ...
}
);
Using Windows 11 with Kinect 2.0.
I thought maybe I was missing some OpenCV DLLs since I can only find a custom Unreal version of the OpenCV World DLL, so I tried overriding the default OpenCV plugin and adding the FFMPEG and MSMF DLLs myself but that didn’t change anything.
Edit: After many attempted building OpenCV from source, I only managed to get GStreamer and FFMPEG to work.
The OpenCV library that comes with UE5 is not built with FFmpeg or with the Media Foundation library, so it cannot read video from a file or from a camera.
You can try to build your own version of OpenCV with FFmpeg or Media Foundation support and use that instead of the one that comes with UE5.

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 "cvaux.h" equivalent

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>

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.