Guest User

Untitled

a guest
Feb 17th, 2021
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.40 KB | None | 0 0
  1. // TestNEURALVFX.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include "pose_estimate.h"
  6. #include <opencv2/opencv.hpp>
  7.  
  8. using namespace std;
  9. using namespace cv;
  10.  
  11. struct TransformData {
  12. public:
  13.   float tX, tY, tZ, rfX, rfY, rfZ, ruX, ruY, ruZ;
  14. };
  15.  
  16. int main()
  17. {
  18.   std::vector<cv::Point3d> transs;
  19.   std::vector<cv::Point3d> rot_uu;
  20.   std::vector<cv::Point3d> rot_ff;
  21.  
  22.     int detectRatio = 1;
  23.      int camId;
  24.  
  25.     bool _ready = false;
  26.     TransformData faces;
  27.     Estimator result;
  28.     cv::Mat im = cv::imread("headPose.jpg");    
  29.     int cam_width = im.cols, cam_height = im.rows;
  30.     result.init(cam_width, cam_height, detectRatio, camId);
  31.     double focal_length = im.cols; // Approximate focal length.
  32.     Point2d center = cv::Point2d(im.cols / 2, im.rows / 2);
  33.     // Setup camera
  34.     cv::Mat camera_matrix = (cv::Mat_<double>(3, 3) << focal_length, 0,
  35.                              center.x, 0, focal_length, center.y, 0, 0, 1);
  36.     cv::Mat dist_coeffs = cv::Mat::zeros(
  37.         4, 1, cv::DataType<double>::type); // Assuming no lens distortion
  38.  
  39.     cout << "Camera Matrix " << endl << camera_matrix << endl;
  40.     // Output rotation and transslation
  41.     cv::Mat rotation_vector; // Rotation in axis-angle form
  42.     cv::Mat transslation_vector;
  43.    
  44.  
  45.  
  46.     std::vector<cv::Point3d>  transs;
  47.     std::vector<cv::Point3d> rot_uu;
  48.     std::vector<cv::Point3d> rot_ff;
  49.     _ready = true;
  50.  
  51.  
  52.     result.close();
  53.  
  54.     TransformData outFaces = faces;
  55.     result.detect(outFaces);
  56.  
  57.     transs.push_back(cv::Point3d((faces.tX, faces.tY, faces.tZ)));
  58.     rot_uu.push_back(cv::Point3d((faces.ruX, faces.ruY, faces.ruZ)));
  59.     rot_ff.push_back(cv::Point3d((faces.rfX, faces.rfY, faces.rfZ)));
  60.  
  61.  
  62.  
  63.  
  64. }
  65.  
  66. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  67. // Debug program: F5 or Debug > Start Debugging menu
  68.  
  69. // Tips for Getting Started:
  70. //   1. Use the Solution Explorer window to add/manage files
  71. //   2. Use the Team Explorer window to connect to source control
  72. //   3. Use the Output window to see build output and other messages
  73. //   4. Use the Error List window to view errors
  74. //   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  75. //   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
  76.  
Advertisement
Add Comment
Please, Sign In to add comment