Skip to content

Commit

Permalink
Merge branch 'main' into EnhanceEglRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mraduldubey authored Jul 18, 2023
2 parents c127253 + b19d76f commit abe26e4
Show file tree
Hide file tree
Showing 9 changed files with 28,474 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ SET(IP_FILES
src/ImageViewerModule.cpp
src/BMPConverter.cpp
src/ImageResizeCV.cpp
src/FacialLandmarksCV.cpp
src/ImageEncoderCV.cpp
src/RotateCV.cpp
src/BrightnessContrastControlXform.cpp
Expand Down Expand Up @@ -288,6 +289,7 @@ SET(IP_FILES_H
include/ImageDecoderCV.h
include/BMPConverter.h
include/ImageResizeCV.h
include/FacialLandmarksCV.h
include/ImageEncoderCV.h
include/RotateCV.h
include/BrightnessContrastControlXform.h
Expand Down Expand Up @@ -520,6 +522,7 @@ SET(UT_FILES
test/findexstrategy_tests.cpp
test/jpegdecodercv_tests.cpp
test/Imageresizecv_tests.cpp
test/faciallandmarkscv_tests.cpp
test/ImageEncodeCV_tests.cpp
test/rotatecv_tests.cpp
test/brightness_contrast_tests.cpp
Expand Down
5 changes: 5 additions & 0 deletions base/include/ApraPoint2f.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class ApraPoint2f : public cv::Point2f

}

ApraPoint2f(cv::Point2f &point) : cv::Point2f(point)
{

}

private:
friend class boost::serialization::access;

Expand Down
84 changes: 84 additions & 0 deletions base/include/FacialLandmarksCV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#pragma once

#include <opencv2/face.hpp>
#include "Module.h"

class Detail;
class DetailSSD;
class DetailHCASCADE;

class FacialLandmarkCVProps : public ModuleProps
{
public:
enum FaceDetectionModelType
{
SSD,
HAAR_CASCADE
};

FacialLandmarkCVProps(FaceDetectionModelType _type) : type(_type) {}

FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _Face_Detection_Configuration, const std::string _Face_Detection_Weights, const std::string _landmarksDetectionModel, cv::Ptr<cv::face::Facemark> _facemark)
: type(_type), Face_Detection_Configuration(_Face_Detection_Configuration), Face_Detection_Weights(_Face_Detection_Weights), landmarksDetectionModel(_landmarksDetectionModel),facemark(_facemark)
{
if (_type != FaceDetectionModelType::SSD)
{
throw AIPException(AIP_FATAL, "This constructor only supports SSD");
}
}

FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _faceDetectionModel,const std::string _landmarksDetectionModel, cv::Ptr<cv::face::Facemark> _facemark)
: type(_type), landmarksDetectionModel(_landmarksDetectionModel), faceDetectionModel(_faceDetectionModel), facemark(_facemark)
{
if (_type != FaceDetectionModelType::HAAR_CASCADE)
{
throw AIPException(AIP_FATAL, "This constructor only supports HAAR_CASCADE ");
}
}

FaceDetectionModelType type;
const std::string Face_Detection_Configuration = "./data/assets/deploy.prototxt";
const std::string Face_Detection_Weights = "./data/assets/res10_300x300_ssd_iter_140000_fp16.caffemodel";
const std::string landmarksDetectionModel = "./data/assets/face_landmark_model.dat";
const std::string faceDetectionModel = "./data/assets/haarcascade.xml";
cv::Ptr<cv::face::Facemark> facemark = cv::face::FacemarkKazemi::create();

size_t getSerializeSize()
{
return ModuleProps::getSerializeSize() + sizeof(type);
}

private:
friend class boost::serialization::access;

template <class Archive>
void serialize(Archive& ar, const unsigned int version)
{
ar& boost::serialization::base_object<ModuleProps>(*this);
ar& type;
}
};

class FacialLandmarkCV : public Module
{
public:
FacialLandmarkCV(FacialLandmarkCVProps props);
virtual ~FacialLandmarkCV();
bool init();
bool term();
void setProps(FacialLandmarkCVProps& props);
FacialLandmarkCVProps getProps();

protected:
bool process(frame_container &frames);
bool processSOS(frame_sp &frame);
bool validateInputPins();
bool validateOutputPins();
void addInputPin(framemetadata_sp &metadata, string &pinId); // throws exception if validation fails
bool shouldTriggerSOS();
bool processEOS(string &pinId);
boost::shared_ptr<Detail> mDetail;
FacialLandmarkCVProps mProp;
bool handlePropsChange(frame_sp& frame);
std::string mOutputPinId1;
};
3 changes: 2 additions & 1 deletion base/include/FrameMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class FrameMetadata {
MP4_VIDEO_METADATA,
HEVC_DATA, //H265
MOTION_VECTOR_DATA,
OVERLAY_INFO_IMAGE
OVERLAY_INFO_IMAGE,
FACE_LANDMARKS_INFO
};

enum MemType
Expand Down
Loading

0 comments on commit abe26e4

Please sign in to comment.