Guest User

Untitled

a guest
Jan 5th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. bool loadCameraCalibration(string name, Mat& cameraMatrix, Mat& distanceCoefficients) {
  2. ifstream inStream(name);
  3. if (inStream) {
  4. uint16_t rows;
  5. uint16_t columns;
  6.  
  7. inStream >> rows;
  8. inStream >> columns;
  9.  
  10. cameraMatrix = Mat(Size(columns, rows), CV_64F);
  11.  
  12. for (int r = 0; r < rows; r++) {
  13. for (int c = 0; c < columns; c++) {
  14. double read = 0.0f;
  15. inStream >> read;
  16. cameraMatrix.at<double>(r, c) = read;
  17. cout << cameraMatrix.at<double>(r, c) << "\n";
  18.  
  19. }
  20. }
  21.  
  22. //Distance(distortion) coefficients
  23. inStream >> rows;
  24. inStream >> columns;
  25.  
  26.  
  27. distanceCoefficients = Mat::zeros(rows, columns, CV_64F);
  28.  
  29. for (int r = 0; r < rows; r++) {
  30. for (int c = 0; c < columns; c++) {
  31. double read = 0.0f;
  32. inStream >> read;
  33. distanceCoefficients.at<double>(r, c) = read;
  34. cout << distanceCoefficients.at<double>(r, c) << "\n";
  35. }
  36. }
  37. inStream.close();
  38. return true;
  39. }
  40. return false;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment