This OpenCV tutorial is a very simple code example of GPU Cuda optical flow in OpenCV written in c++. The configuration of the project, code, and explanation are included for farneback Optical Flow method. Farneback algorithm is a dense method that is used to process all the pixels in the given image. The dense methods are slower but more accurate as all the pixels of the image are processed. In the following example, I am displaying just a few pixes based on a grid. I am not displaying all the pixes. In the opposite to dense method the sparse method like Lucas Kanade using just a selected subset of pixels. They are faster. Both methods have specific applications. Lucas-Kanade is widely used in tracking. The farneback can be used for the analysis of more complex movement in image scene and furder segmentation based on these changes. As dense methods are slightly slower, the GPU and Cuda implementation can lead to great performance improvements to calculate optical flow for all pixels o
Basic Opencv Face Detection Tutorial
Basic Opencv C++ tutorial how to detect the face from video image and any source you can achieve.
If you have little bit skills with programing you can just achieve the result under 10 minutes. I would like to reccomend also the installation by NUGET package. It is the fastest approach in Visual Studio how to start coding with opencv..
If you have little bit skills with programing you can just achieve the result under 10 minutes. I would like to reccomend also the installation by NUGET package. It is the fastest approach in Visual Studio how to start coding with opencv..
Problem with CascadeClassifier detectMultiScale Opencv 3.0.0. Windows prebuild libs
Problem is that in many cases with 32 bit Opencv 3.0.0 Windows version in debug and in release mode. I thing any of haarcascade_xxx return vector<Rect> Faces (testing number of cascades is 7). The length of the vector is incomprehensibly bigger than I can expect with my parameters and experiences with previous Opencv version..
vector<Rect> of detection is to big
This is some kind of bug that I try to find in opencv source. What is surprising is fact that 64 bit version of Opencv works fine in my case.
I am using Visual Studio 2015 with 64 bit Opencv 3.0.0
Here is my tutorial how to install Opencv 3.0.0 libs for Visual Studio 2015.
Install Opencv for Visual Studio 2015
You can simple prepare the project inside the Visual Studio 2015 by Nuget Packages. This approach is easy for beginers and better than standard installation with all the environmental variables problems. Just follow the installation steps inside here
You can simple prepare the project inside the Visual Studio 2015 by Nuget Packages. This approach is easy for beginers and better than standard installation with all the environmental variables problems. Just follow the installation steps inside here
Face detection basic Opencv C++ code example
There is nothing special, but you can also find the example how to replace the face with transparent mask or any pictures. This is at least fun.
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/objdetect.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
// capture from web camera init
VideoCapture cap(0);
cap.open(0);
Mat img;
// Load cascate classifier placed in sulution folder
CascadeClassifier detector;
string cascadeName = "haarcascade_frontalface_alt.xml";
bool loaded = detector.load(cascadeName);
// Parameters of detectMultiscale Cascade Classifier
int groundThreshold = 2;
double scaleStep = 1.1;
Size minimalObjectSize(80, 80);
Size maximalObjectSize(200, 200);
// Vector of returned faces
vector found;
for (;;)
{
// Image from camera to Mat
cap >> img;
// Convert input to greyscale
Mat image_grey;
cvtColor(img, image_grey, CV_BGR2GRAY);
// why not
found.clear();
// Detect faces
detector.detectMultiScale(image_greyHead, found, scaleStep, groundThreshold, 0 | 2, minimalObjectSize,maximalObjectSize);
// Draw the results into mat retrieved from webcam
if (found.size() > 0) {
for (int i = 0; i <= found.size() - 1; i++) {
rectangle(img, found[i].br(), found[i].tl(), Scalar(0, 0, 0), 1, 8, 0);
}
}
//Show the results
imshow("wooohooo", img);
int key2 = waitKey(20);
}
return 0;
}
I have got this error:xxx.cpp(56): error C2065: 'image_greyHead': undeclared identifier
ReplyDeleteCan you share the value of this identifier?
'image_greyHead': undeclared identifier what should i do?
ReplyDeleteReplace image_greyHead to image_grey lol
Deletealso point to the correct folder for the haar classifer
ReplyDeleteVBasic Code Examples
ReplyDeleteThe throw : Read access to offense.
ReplyDeletethis이(가) 0x445FF8였습니다.
If you have a program for this exception handler can continue safely.
template inline
Point_<_Tp> Rect_<_Tp>::br() const
{
return Point_<_Tp>(x + width, y + height); <<error part
}
I got exception like "Unhandled exception at 0x000007FEFD619E5D in OpenCVTest.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001BF1F0."
ReplyDeletewhat should I do
mine gives error on vector. I fixed it vector found. but why it cant detect my face?
ReplyDeletehow did you fixed it ?
DeleteThis comment has been removed by the author.
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
DeleteThanks for the info.
ReplyDeleteผลมวย
มวยไทย 7 สี
โปรแกรมแข่งมวย
คลิปมวยไทย
ReplyDelete'std::vector': use of class template requires template argument list this is error
can you provide me some idea
write vector found; instead of vector found;
DeleteWorked for me. Probably not gonna be useful for you since you might have already solved it but I hope it can help someone one day
welp sorry, meant that you have to enter Rect into brackets next to vector. Idk why I can't right it in comment section
Delete<Rect
The information in this blog is handy for the people. Face Recognition App
ReplyDeleteThis comment has been removed by the author.
ReplyDeletefixed file,you can download it from:
ReplyDeletehttps://goo.gl/cQmgw2