Advertisement
Guest User

main

a guest
Nov 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 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.     int nBallPixels = 0;
  27.     for (int i = 0; i < ball.rows; i++) {
  28.         for (int j = 0; j < ball.cols; j++) {
  29.             if (ball.at<Vec3b>(i, j) == Vec3b(255, 255, 255))
  30.                 nBallPixels++;
  31.         }
  32.     }
  33.  
  34.     double avgDist;
  35.     std::ifstream in("MiI-SredniaOdleglosc.txt");
  36.     in >> avgDist;
  37.     in.close();
  38.  
  39.     double diameterPx = 2 * sqrt((double)nBallPixels / 3.141592);
  40.     double diameterCm = 0.001 * avgDist * diameterPx;
  41.  
  42.     std::cout << diameterCm << std::endl;
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement