Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. //Calibration
  2. Mat K, xi, D, idx;
  3. int flags=0|omnidir::CALIB_FIX_SKEW | omnidir::CALIB_FIX_K1 |
  4. omnidir::CALIB_FIX_K2;
  5.  
  6. TermCriteria critia(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 200,
  7. 0.0001);
  8.  
  9. vector<cv::Mat> rvecs, tvecs;
  10.  
  11. double rms = cv::omnidir::calibrate(obj_points, image_points, image_size, K,
  12. xi, D, rvecs, tvecs, flags, critia, idx);
  13.  
  14.  
  15. //Testing
  16. Mat R = Mat::eye(3, 3, CV_32F);
  17. Mat Mapx, Mapy;
  18. Mat New_camera_mat(3,3,CV_32F);
  19.  
  20. //New_camera_mat tries to get entire FOV,but it is losing some information
  21. at edges
  22.  
  23. New_camera_mat.at<float>(0, 0) = 100; New_camera_mat.at<float>(0, 1) = 0;
  24. New_camera_mat.at<float>(0, 2) = 1280/2;
  25.  
  26. New_camera_mat.at<float>(1, 0) = 0; New_camera_mat.at<float>(1, 1) = 100;
  27. New_camera_mat.at<float>(1, 2) = 720/2 ;
  28.  
  29. New_camera_mat.at<float>(2, 0) = 0; New_camera_mat.at<float>(2, 1) = 0;
  30. New_camera_mat.at<float>(2, 2) = 1;
  31.  
  32. cv::omnidir::initUndistortRectifyMap(K, D, xi_Right, R, New_camera_mat,
  33. image_size, CV_32F, Mapx, Mapy, cv::omnidir::RECTIFY_PERSPECTIVE);
  34.  
  35. remap(distorted_frame, undistorted_out_frame, Mapx, Mapy, INTER_CUBIC);
Add Comment
Please, Sign In to add comment