dariahinz

srednia

Jan 12th, 2018
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. /*
  2. * stereo_match.cpp
  3. * calibration
  4. *
  5. * Created by Victor Eruhimov on 1/18/10.
  6. * Copyright 2010 Argus Corp. All rights reserved.
  7. *
  8. */
  9.  
  10. #include "opencv2/calib3d/calib3d.hpp"
  11. #include "opencv2/imgproc/imgproc.hpp"
  12. #include "opencv2/highgui/highgui.hpp"
  13. #include "opencv2/contrib/contrib.hpp"
  14.  
  15. #include <stdio.h>
  16. #include <iostream>
  17. #include <fstream>
  18.  
  19. using namespace cv;
  20.  
  21. int main(int argc, char** argv)
  22. {
  23. Mat dist = imread("MiI-MapaGłębokości.png");
  24. Mat ball = imread("MiI-Obszar.png");
  25.  
  26. double avgDist = 0;
  27. int nDist = 0;
  28.  
  29. for (int i = 0; i < ball.rows; i++) {
  30. for (int j = 0; j < ball.cols; j++) {
  31. Vec3b ballPx = ball.at<Vec3b>(i, j);
  32. uchar distPx = dist.at<uchar>(i, j);
  33.  
  34. // Skip pixels not in ball.
  35. if (ballPx != Vec3b(255, 255, 255))
  36. continue;
  37.  
  38. avgDist += distPx;
  39. nDist++;
  40. }
  41. }
  42.  
  43. avgDist /= nDist;
  44.  
  45. std::ofstream out("MiI-SredniaOdleglosc.txt");
  46. out << avgDist;
  47. out.close();
  48.  
  49. return 0;
  50. }
Add Comment
Please, Sign In to add comment