Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. for (int i = 0; i < NUM_OF_PICS; i++) {
  2. printf("FileName : %sn", filefinder.name);
  3. string img_path = path + "CameraCalibration/" + filefinder.name;
  4.  
  5. images_color[i] = imread(img_path);
  6.  
  7.  
  8. images[i] = imread(img_path, 0);
  9. images_copy[i] = images_color[i].clone();
  10. cp_img = images[i].clone();
  11. bool patternfound = findChessboardCorners(images[i], patternsize, edges,
  12. CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
  13. + CALIB_CB_FAST_CHECK);
  14. if (patternfound) {
  15. cornerSubPix(images[i], edges, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 50, 0.0001));
  16. edge_points.push_back(edges);
  17. drawChessboardCorners(images_copy[i], patternsize, Mat(edges), patternfound);
  18. points_vector_pile.push_back(points_vector);
  19. }
  20.  
  21.  
  22.  
  23. cout << "Pic_" + to_string(i) << ": "<< patternfound << endl;
  24.  
  25. nExistNext = _findnext(handle, &filefinder);
  26. }
  27.  
  28. calibrateCamera(points_vector_pile, edge_points, patternsize, camera_matrix, dist_coeffs, rvecs, tvecs);
  29.  
  30. for (int i = 0; i < 10; i++) {
  31. Mat ouputImage;
  32. undistort(images[i], ouputImage, camera_matrix, dist_coeffs);
  33. namedWindow("Undistorted_" + to_string(i), WINDOW_NORMAL);
  34. resizeWindow("Undistorted_" + to_string(i), ouputImage.cols / 2, ouputImage.rows / 2);
  35. imshow("Undistorted_" + to_string(i), ouputImage);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement