Guest User

Untitled

a guest
Feb 17th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #pragma once
  2. #define MY_EXPORT 1
  3. #ifdef MY_EXPORT
  4. #define MY_API __declspec(dllexport)
  5. #else
  6. #define MY_API __declspec(dllimport)
  7. #endif
  8.  
  9.  
  10. #include <iostream>
  11. #include <stdio.h>
  12. #include <cstdio>
  13.  
  14. #include "opencv2/objdetect.hpp"
  15. #include "opencv2/highgui.hpp"
  16. #include "opencv2/imgproc.hpp"
  17. #include "opencv2/dnn.hpp"
  18. #include "opencv2/dnn/shape_utils.hpp"
  19. #include "opencv2/opencv.hpp"
  20. #include "opencv2/imgproc.hpp"
  21. #include "dlib/image_processing.h"
  22. #include "dlib/opencv.h"
  23. #include "dlib/image_processing/frontal_face_detector.h"
  24.  
  25.  
  26. using namespace std;
  27.  
  28.  
  29. // Struct to pass data from DLL
  30. struct MY_API TransformData
  31. {
  32.     TransformData(float tx, float ty, float tz, float rfx, float rfy, float rfz, float rux, float ruy, float ruz) :
  33.         tX(tx), tY(ty), tZ(tz), rfX(rfx), rfY(rfy), rfZ(rfz), ruX(rux), ruY(ruy), ruZ(ruz) {}
  34.     float tX, tY, tZ;
  35.     float rfX, rfY, rfZ;
  36.     float ruX, ruY, ruZ;
  37. };
  38.  
  39.  
  40.  
  41. class MY_API Estimator {
  42. public:
  43.  
  44.     cv::VideoCapture _capture;
  45.     const string caffe_config_file = "./deploy.prototxt";
  46.     const string caffe_weight_file = "./res10_300x300_ssd_iter_140000_fp16.caffemodel";
  47.     const string landmarks_model = "./shape_predictor_68_face_landmarks.dat";
  48.  
  49.     // Face box data
  50.     int face_width;
  51.     int center_x;
  52.     int center_y;
  53.  
  54.     // Tick counter
  55.     int run_count;
  56.  
  57.     // Capture Dimensions
  58.     int frame_width;
  59.     int frame_height;
  60.  
  61.     int scale_ratio;
  62.  
  63.     // Networks
  64.     cv::dnn::Net box_detector;
  65.     dlib::shape_predictor landmark_detector;
  66.  
  67.     // Storage for reusable variables
  68.     cv::Point2f prev_nose;
  69.     vector< vector<cv::Point2f> > landmarks;
  70.     dlib::rectangle face_rect;
  71.     cv::Mat frame;
  72.     std::vector<cv::Point3d> model_points;
  73.  
  74. public:
  75.  
  76.     Estimator();
  77.  
  78.     int init(int& outCameraWidth, int& outCameraHeight, int detectRatio, int camId);
  79.  
  80.     void close();
  81.  
  82.     void detect(TransformData& outFaces);
  83.  
  84.     void getRawImageBytes(unsigned char* data, int width, int height);
  85.  
  86. };
  87.  
  88.  
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment