[EDIT] added evrything to namespace, also fixed includes

This commit is contained in:
Jasper
2021-05-21 12:12:42 +02:00
parent e39cb1a761
commit 27a09aeca4
12 changed files with 493 additions and 454 deletions

View File

@@ -1,10 +1,10 @@
#include "BackgroundRemover.h"
#include"opencv2\opencv.hpp"
/*
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
*/
namespace computervision
{
BackgroundRemover::BackgroundRemover(void) {
background;
calibrated = false;
@@ -56,3 +56,4 @@ void BackgroundRemover::removeBackground(Mat input, Mat background) {
}
}
}
}

View File

@@ -1,11 +1,11 @@
#pragma once
#include<opencv\cv.h>
#include"opencv2\opencv.hpp"
#include <opencv2/imgproc\types_c.h>
/*
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
*/
namespace computervision
{
using namespace cv;
using namespace std;
@@ -13,12 +13,13 @@ class BackgroundRemover {
public:
BackgroundRemover(void);
void calibrate(Mat input);
Mat BackgroundRemover::getForeground(Mat input);
Mat getForeground(Mat input);
private:
Mat background;
bool calibrated = false;
Mat getForegroundMask(Mat input);
void BackgroundRemover::removeBackground(Mat input, Mat background);
void removeBackground(Mat input, Mat background);
};
}

View File

@@ -1,10 +1,11 @@
#include "FaceDetector.h"
#include"opencv2\opencv.hpp"
/*
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
*/
namespace computervision
{
Rect getFaceRect(Mat input);
String faceClassifierFileName = "../res/haarcascade_frontalface_alt.xml";
@@ -49,3 +50,4 @@ Rect getFaceRect(Mat input) {
else
return Rect(0, 0, 1, 1);
}
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include<opencv\cv.h>
#include"opencv2\opencv.hpp"
#include <opencv2\imgproc\types_c.h>
#include <opencv2/objdetect/objdetect_c.h>
/*
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
*/
@@ -9,8 +9,11 @@
using namespace cv;
using namespace std;
namespace computervision
{
class FaceDetector {
public:
FaceDetector(void);
void removeFaces(Mat input, Mat output);
};
}

View File

@@ -12,6 +12,8 @@
#define BOUNDING_RECT_FINGER_SIZE_SCALING 0.3
#define BOUNDING_RECT_NEIGHBOR_DISTANCE_SCALING 0.05
namespace computervision
{
FingerCount::FingerCount(void) {
color_blue = Scalar(255, 0, 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);
}
}
}

View File

@@ -1,11 +1,14 @@
#pragma once
#include "opencv/cv.h"
#include "opencv2/core.hpp"
#include <opencv2/imgproc/types_c.h>
/*
Author: Nicol<6F> Castellazzi https://github.com/nicast
*/
namespace computervision
{
using namespace cv;
using namespace std;
@@ -30,3 +33,4 @@ private:
double findPointsDistanceOnX(Point a, Point b);
void drawVectorPoints(Mat image, vector<Point> points, Scalar color, bool with_numbers);
};
}

View File

@@ -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 "BackgroundRemover.h"
#include "BackgroundRemover.h"
#include "SkinDetector.h"
#include "FaceDetector.h"
#include "FingerCount.h"
@@ -8,10 +15,11 @@
namespace computervision
{
cv::VideoCapture cap(0);
cv::Mat img, imgGray, img2, img2Gray, img3, img4;
Mat frame, frameOut, handMask, foreground, fingerCountDebug;
//BackgroundRemover backgroundRemover;
BackgroundRemover backgroundRemover;
SkinDetector skinDetector;
FaceDetector faceDetector;
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);
frameOut = frame.clone();
skinDetector.drawSkinColorSampler(frameOut);
foreground = backgroundRemover.getForeground(frame);
faceDetector.removeFaces(frame, foreground);
handMask = skinDetector.getSkinMask(foreground);
return true;
}
void ObjectDetection::readWebcam()

View File

@@ -17,6 +17,7 @@ namespace computervision
public:
ObjectDetection();
bool Init();
void readWebcam();
void showWebcam();
void calculateDifference();

View File

@@ -1,10 +1,11 @@
#include "SkinDetector.h"
#include"opencv2\opencv.hpp"
/*
Author: Pierfrancesco Soffritti https://github.com/PierfrancescoSoffritti
*/
namespace computervision
{
SkinDetector::SkinDetector(void) {
hLowThreshold = 0;
hHighThreshold = 0;
@@ -101,3 +102,4 @@ void SkinDetector::performOpening(Mat binaryImage, int kernelShape, Point kernel
Mat structuringElement = getStructuringElement(kernelShape, kernelSize);
morphologyEx(binaryImage, binaryImage, MORPH_OPEN, structuringElement);
}
}

View File

@@ -1,11 +1,15 @@
#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
*/
namespace computervision
{
using namespace cv;
using namespace std;
@@ -30,5 +34,6 @@ private:
Rect skinColorSamplerRectangle1, skinColorSamplerRectangle2;
void calculateThresholds(Mat sample1, Mat sample2);
void SkinDetector::performOpening(Mat binaryImage, int structuralElementShapde, Point structuralElementSize);
void performOpening(Mat binaryImage, int structuralElementShapde, Point structuralElementSize);
};
}

View File

@@ -37,7 +37,7 @@
<ItemGroup>
<ClInclude Include="src\computervision\FaceDetector.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\ObjectDetection.h" />
<ClInclude Include="src\entities\camera.h" />

View File

@@ -101,7 +101,7 @@
<ClInclude Include="src\computervision\FaceDetector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\computervision\Header.h">
<ClInclude Include="src\computervision\BackgroundRemover.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>