[EDIT] added evrything to namespace, also fixed includes
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
#include "BackgroundRemover.h"
|
#include "BackgroundRemover.h"
|
||||||
#include"opencv2\opencv.hpp"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
BackgroundRemover::BackgroundRemover(void) {
|
BackgroundRemover::BackgroundRemover(void) {
|
||||||
background;
|
background;
|
||||||
calibrated = false;
|
calibrated = false;
|
||||||
@@ -56,3 +56,4 @@ void BackgroundRemover::removeBackground(Mat input, Mat background) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include"opencv2\opencv.hpp"
|
||||||
#include<opencv\cv.h>
|
#include <opencv2/imgproc\types_c.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -13,12 +13,13 @@ class BackgroundRemover {
|
|||||||
public:
|
public:
|
||||||
BackgroundRemover(void);
|
BackgroundRemover(void);
|
||||||
void calibrate(Mat input);
|
void calibrate(Mat input);
|
||||||
Mat BackgroundRemover::getForeground(Mat input);
|
Mat getForeground(Mat input);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mat background;
|
Mat background;
|
||||||
bool calibrated = false;
|
bool calibrated = false;
|
||||||
|
|
||||||
Mat getForegroundMask(Mat input);
|
Mat getForegroundMask(Mat input);
|
||||||
void BackgroundRemover::removeBackground(Mat input, Mat background);
|
void removeBackground(Mat input, Mat background);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "FaceDetector.h"
|
#include "FaceDetector.h"
|
||||||
#include"opencv2\opencv.hpp"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
Rect getFaceRect(Mat input);
|
Rect getFaceRect(Mat input);
|
||||||
|
|
||||||
String faceClassifierFileName = "../res/haarcascade_frontalface_alt.xml";
|
String faceClassifierFileName = "../res/haarcascade_frontalface_alt.xml";
|
||||||
@@ -49,3 +50,4 @@ Rect getFaceRect(Mat input) {
|
|||||||
else
|
else
|
||||||
return Rect(0, 0, 1, 1);
|
return Rect(0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include"opencv2\opencv.hpp"
|
||||||
#include<opencv\cv.h>
|
#include <opencv2\imgproc\types_c.h>
|
||||||
|
#include <opencv2/objdetect/objdetect_c.h>
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
@@ -9,8 +9,11 @@
|
|||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
class FaceDetector {
|
class FaceDetector {
|
||||||
public:
|
public:
|
||||||
FaceDetector(void);
|
FaceDetector(void);
|
||||||
void removeFaces(Mat input, Mat output);
|
void removeFaces(Mat input, Mat output);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
#define BOUNDING_RECT_FINGER_SIZE_SCALING 0.3
|
#define BOUNDING_RECT_FINGER_SIZE_SCALING 0.3
|
||||||
#define BOUNDING_RECT_NEIGHBOR_DISTANCE_SCALING 0.05
|
#define BOUNDING_RECT_NEIGHBOR_DISTANCE_SCALING 0.05
|
||||||
|
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
FingerCount::FingerCount(void) {
|
FingerCount::FingerCount(void) {
|
||||||
color_blue = Scalar(255, 0, 0);
|
color_blue = Scalar(255, 0, 0);
|
||||||
color_green = Scalar(0, 255, 0);
|
color_green = Scalar(0, 255, 0);
|
||||||
@@ -286,3 +288,4 @@ void FingerCount::drawVectorPoints(Mat image, vector<Point> points, Scalar color
|
|||||||
putText(image, to_string(i), points[i], FONT_HERSHEY_PLAIN, 3, color);
|
putText(image, to_string(i), points[i], FONT_HERSHEY_PLAIN, 3, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "opencv/cv.h"
|
#include "opencv2/core.hpp"
|
||||||
|
#include <opencv2/imgproc/types_c.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Author: Nicol<6F> Castellazzi https://github.com/nicast
|
Author: Nicol<6F> Castellazzi https://github.com/nicast
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -30,3 +33,4 @@ private:
|
|||||||
double findPointsDistanceOnX(Point a, Point b);
|
double findPointsDistanceOnX(Point a, Point b);
|
||||||
void drawVectorPoints(Mat image, vector<Point> points, Scalar color, bool with_numbers);
|
void drawVectorPoints(Mat image, vector<Point> points, Scalar color, bool with_numbers);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
@@ -1,6 +1,13 @@
|
|||||||
|
#include "opencv2/opencv.hpp"
|
||||||
|
#include "opencv2/imgcodecs.hpp"
|
||||||
|
#include "opencv2/imgproc.hpp"
|
||||||
|
#include "opencv2/videoio.hpp"
|
||||||
|
#include <opencv2/highgui.hpp>
|
||||||
|
#include <opencv2/video.hpp>
|
||||||
|
|
||||||
#include "ObjectDetection.h"
|
#include "ObjectDetection.h"
|
||||||
#include "ObjectDetection.h"
|
#include "ObjectDetection.h"
|
||||||
//#include "BackgroundRemover.h"
|
#include "BackgroundRemover.h"
|
||||||
#include "SkinDetector.h"
|
#include "SkinDetector.h"
|
||||||
#include "FaceDetector.h"
|
#include "FaceDetector.h"
|
||||||
#include "FingerCount.h"
|
#include "FingerCount.h"
|
||||||
@@ -8,10 +15,11 @@
|
|||||||
namespace computervision
|
namespace computervision
|
||||||
{
|
{
|
||||||
cv::VideoCapture cap(0);
|
cv::VideoCapture cap(0);
|
||||||
|
|
||||||
cv::Mat img, imgGray, img2, img2Gray, img3, img4;
|
cv::Mat img, imgGray, img2, img2Gray, img3, img4;
|
||||||
|
|
||||||
Mat frame, frameOut, handMask, foreground, fingerCountDebug;
|
Mat frame, frameOut, handMask, foreground, fingerCountDebug;
|
||||||
//BackgroundRemover backgroundRemover;
|
BackgroundRemover backgroundRemover;
|
||||||
SkinDetector skinDetector;
|
SkinDetector skinDetector;
|
||||||
FaceDetector faceDetector;
|
FaceDetector faceDetector;
|
||||||
FingerCount fingerCount;
|
FingerCount fingerCount;
|
||||||
@@ -21,15 +29,24 @@ namespace computervision
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDetection::Init()
|
bool ObjectDetection::Init()
|
||||||
{
|
{
|
||||||
|
if (!cap.isOpened()) {
|
||||||
|
cout << "Can't find camera!" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cap.read(frame);
|
cap.read(frame);
|
||||||
|
frameOut = frame.clone();
|
||||||
|
|
||||||
skinDetector.drawSkinColorSampler(frameOut);
|
skinDetector.drawSkinColorSampler(frameOut);
|
||||||
|
|
||||||
foreground = backgroundRemover.getForeground(frame);
|
foreground = backgroundRemover.getForeground(frame);
|
||||||
|
|
||||||
faceDetector.removeFaces(frame, foreground);
|
faceDetector.removeFaces(frame, foreground);
|
||||||
handMask = skinDetector.getSkinMask(foreground);
|
handMask = skinDetector.getSkinMask(foreground);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDetection::readWebcam()
|
void ObjectDetection::readWebcam()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace computervision
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectDetection();
|
ObjectDetection();
|
||||||
|
bool Init();
|
||||||
void readWebcam();
|
void readWebcam();
|
||||||
void showWebcam();
|
void showWebcam();
|
||||||
void calculateDifference();
|
void calculateDifference();
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "SkinDetector.h"
|
#include "SkinDetector.h"
|
||||||
#include"opencv2\opencv.hpp"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
SkinDetector::SkinDetector(void) {
|
SkinDetector::SkinDetector(void) {
|
||||||
hLowThreshold = 0;
|
hLowThreshold = 0;
|
||||||
hHighThreshold = 0;
|
hHighThreshold = 0;
|
||||||
@@ -101,3 +102,4 @@ void SkinDetector::performOpening(Mat binaryImage, int kernelShape, Point kernel
|
|||||||
Mat structuringElement = getStructuringElement(kernelShape, kernelSize);
|
Mat structuringElement = getStructuringElement(kernelShape, kernelSize);
|
||||||
morphologyEx(binaryImage, binaryImage, MORPH_OPEN, structuringElement);
|
morphologyEx(binaryImage, binaryImage, MORPH_OPEN, structuringElement);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<opencv\cv.h>
|
#include<opencv2\core.hpp>
|
||||||
|
#include <opencv2/imgcodecs.hpp>
|
||||||
|
#include <opencv2/imgproc.hpp>
|
||||||
|
#include <opencv2/imgproc/types_c.h>
|
||||||
/*
|
/*
|
||||||
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace computervision
|
||||||
|
{
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -30,5 +34,6 @@ private:
|
|||||||
Rect skinColorSamplerRectangle1, skinColorSamplerRectangle2;
|
Rect skinColorSamplerRectangle1, skinColorSamplerRectangle2;
|
||||||
|
|
||||||
void calculateThresholds(Mat sample1, Mat sample2);
|
void calculateThresholds(Mat sample1, Mat sample2);
|
||||||
void SkinDetector::performOpening(Mat binaryImage, int structuralElementShapde, Point structuralElementSize);
|
void performOpening(Mat binaryImage, int structuralElementShapde, Point structuralElementSize);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\computervision\FaceDetector.h" />
|
<ClInclude Include="src\computervision\FaceDetector.h" />
|
||||||
<ClInclude Include="src\computervision\FingerCount.h" />
|
<ClInclude Include="src\computervision\FingerCount.h" />
|
||||||
<ClInclude Include="src\computervision\Header.h" />
|
<ClInclude Include="src\computervision\BackgroundRemover.h" />
|
||||||
<ClInclude Include="src\computervision\SkinDetector.h" />
|
<ClInclude Include="src\computervision\SkinDetector.h" />
|
||||||
<ClInclude Include="src\computervision\ObjectDetection.h" />
|
<ClInclude Include="src\computervision\ObjectDetection.h" />
|
||||||
<ClInclude Include="src\entities\camera.h" />
|
<ClInclude Include="src\entities\camera.h" />
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
<ClInclude Include="src\computervision\FaceDetector.h">
|
<ClInclude Include="src\computervision\FaceDetector.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\computervision\Header.h">
|
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user