Skip to content

Commit

Permalink
Merge branch 'main' into nvtransformchange
Browse files Browse the repository at this point in the history
  • Loading branch information
mraduldubey authored Jul 18, 2023
2 parents bc27982 + b19d76f commit a7f53e5
Show file tree
Hide file tree
Showing 45 changed files with 91,103 additions and 469 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-lin-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
submodules: 'recursive'
lfs: true
fetch-depth: 0

- name: List Submodules
run: |
git config --global --add safe.directory "*"
Expand Down
5 changes: 4 additions & 1 deletion 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 @@ -478,6 +480,7 @@ IF (ENABLE_CUDA)
test/cudamemcopy_tests.cpp
test/resizenppi_tests.cpp
test/rotatenppi_tests.cpp
test/ccnppi_tests.cpp
)
IF(NOT ENABLE_ARM64) # following tests need CUDA but can not run on ARM ?

Expand All @@ -486,7 +489,6 @@ IF (ENABLE_CUDA)
test/jpegdecodernvjpeg_tests.cpp
test/resizenppi_jpegencodernvjpeg_tests.cpp
test/nvjpeg_combo_tests.cpp
test/ccnppi_tests.cpp
test/overlaynppi_tests.cpp
test/effectsnppi_tests.cpp
test/h264Encodernvcodec_tests.cpp
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
4 changes: 3 additions & 1 deletion base/include/CCNPPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class CCNPPIProps : public ModuleProps
{
public:

CCNPPIProps(ImageMetadata::ImageType _imageType, cudastream_sp& _stream)
{
stream_sp = _stream;
Expand Down Expand Up @@ -49,6 +50,7 @@ class CCNPPI : public Module
int mOutputFrameType;
size_t mFrameLength;
framemetadata_sp mOutputMetadata;
framemetadata_sp mIntermediateMetadata;
std::string mOutputPinId;
CCNPPIProps props;
CCNPPIProps mProps;
};
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
11 changes: 9 additions & 2 deletions base/include/Mp4WriterSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ class DetailH264;
class Mp4WriterSinkProps : public ModuleProps
{
public:
Mp4WriterSinkProps(uint32_t _chunkTime, uint32_t _syncTimeInSecs, uint16_t _fps, std::string _baseFolder, bool _recordedTSBasedDTS = true) : ModuleProps()
Mp4WriterSinkProps(uint32_t _chunkTime, uint32_t _syncTimeInSecs, uint16_t _fps, std::string _baseFolder, bool _recordedTSBasedDTS = true, bool _enableMetadata = true) : ModuleProps()
{
baseFolder = _baseFolder;
fps = _fps;
recordedTSBasedDTS = _recordedTSBasedDTS;
enableMetadata = _enableMetadata;
if ((_chunkTime >= 1 && _chunkTime <= 60) || (_chunkTime == UINT32_MAX))
{
chunkTime = _chunkTime;
Expand All @@ -39,6 +40,7 @@ class Mp4WriterSinkProps : public ModuleProps
syncTimeInSecs = 1;
fps = 30;
recordedTSBasedDTS = true;
enableMetadata = true;
}

size_t getSerializeSize()
Expand All @@ -48,14 +50,16 @@ class Mp4WriterSinkProps : public ModuleProps
sizeof(baseFolder) +
sizeof(chunkTime) +
sizeof(syncTimeInSecs) +
sizeof(fps);
sizeof(fps) +
sizeof(enableMetadata);;
}

std::string baseFolder;
uint32_t chunkTime = 1;
uint32_t syncTimeInSecs = 1;
uint16_t fps = 30;
bool recordedTSBasedDTS = true;
bool enableMetadata = true;
private:
friend class boost::serialization::access;

Expand All @@ -68,6 +72,7 @@ class Mp4WriterSinkProps : public ModuleProps
ar &chunkTime;
ar &syncTimeInSecs;
ar &fps;
ar &enableMetadata;
}
};

Expand All @@ -89,6 +94,8 @@ class Mp4WriterSink : public Module
bool setMetadata(framemetadata_sp &inputMetadata);
bool handlePropsChange(frame_sp &frame);
bool shouldTriggerSOS();
void addInputPin(framemetadata_sp& metadata, string& pinId);
bool enableMp4Metadata(framemetadata_sp &inputMetadata);
boost::shared_ptr<DetailAbs> mDetail;
Mp4WriterSinkProps mProp;

Expand Down
2 changes: 1 addition & 1 deletion base/include/Mp4WriterSinkUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Mp4WriterSinkUtils
bool customNamedFileDirCheck(std::string baseFolder, uint32_t chunkTimeInMinutes, boost::filesystem::path relPath, std::string& nextFrameFileName);
std::string format_hrs(int &hr);
std::string format_2(int &min);
std::string filePath(boost::filesystem::path relPath, std::string mp4FileName, std::string baseFolder);
std::string filePath(boost::filesystem::path relPath, std::string mp4FileName, std::string baseFolder, uint64_t chunkTimeInMins);
~Mp4WriterSinkUtils();
private:
int lastVideoMinute=0;
Expand Down
Loading

0 comments on commit a7f53e5

Please sign in to comment.