Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated flags to OpenCV 4.0 #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions calib_intrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ void setup_calibration(int board_width, int board_height, int num_imgs,
sprintf(img_file, "%s%s%d.%s", imgs_directory, imgs_filename, k, extension);
if(!doesExist(img_file))
continue;
img = imread(img_file, CV_LOAD_IMAGE_COLOR);
cv::cvtColor(img, gray, CV_BGR2GRAY);
img = imread(img_file, IMREAD_COLOR);
cv::cvtColor(img, gray, COLOR_BGR2GRAY);

bool found = false;
found = cv::findChessboardCorners(img, board_size, corners,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FILTER_QUADS);
if (found)
{
cornerSubPix(gray, corners, cv::Size(5, 5), cv::Size(-1, -1),
TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1));
TermCriteria(TermCriteria::EPS | TermCriteria::MAX_ITER, 30, 0.1));
drawChessboardCorners(gray, board_size, corners, found);
}

Expand Down Expand Up @@ -73,7 +73,7 @@ double computeReprojectionErrors(const vector< vector< Point3f > >& objectPoints
for (i = 0; i < (int)objectPoints.size(); ++i) {
projectPoints(Mat(objectPoints[i]), rvecs[i], tvecs[i], cameraMatrix,
distCoeffs, imagePoints2);
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), CV_L2);
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), NORM_L2);
int n = (int)objectPoints[i].size();
perViewErrors[i] = (float) std::sqrt(err*err/n);
totalErr += err*err;
Expand Down Expand Up @@ -116,8 +116,8 @@ int main(int argc, char const **argv)
Mat D;
vector< Mat > rvecs, tvecs;
int flag = 0;
flag |= CV_CALIB_FIX_K4;
flag |= CV_CALIB_FIX_K5;
flag |= CALIB_FIX_K4;
flag |= CALIB_FIX_K5;
calibrateCamera(object_points, image_points, img.size(), K, D, rvecs, tvecs, flag);

cout << "Calibration error: " << computeReprojectionErrors(object_points, image_points, rvecs, tvecs, K, D) << endl;
Expand Down
18 changes: 9 additions & 9 deletions calib_stereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ void load_image_points(int board_width, int board_height, int num_imgs, float sq
char left_img[100], right_img[100];
sprintf(left_img, "%s%s%d.%s", leftimg_dir, leftimg_filename, i, extension);
sprintf(right_img, "%s%s%d.%s", rightimg_dir, rightimg_filename, i, extension);
img1 = imread(left_img, CV_LOAD_IMAGE_COLOR);
img2 = imread(right_img, CV_LOAD_IMAGE_COLOR);
cvtColor(img1, gray1, CV_BGR2GRAY);
cvtColor(img2, gray2, CV_BGR2GRAY);
img1 = imread(left_img, IMREAD_COLOR);
img2 = imread(right_img, IMREAD_COLOR);
cvtColor(img1, gray1, COLOR_BGR2GRAY);
cvtColor(img2, gray2, COLOR_BGR2GRAY);

bool found1 = false, found2 = false;

found1 = cv::findChessboardCorners(img1, board_size, corners1,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FILTER_QUADS);
found2 = cv::findChessboardCorners(img2, board_size, corners2,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FILTER_QUADS);


if(!found1 || !found2){
Expand All @@ -48,13 +48,13 @@ void load_image_points(int board_width, int board_height, int num_imgs, float sq
if (found1)
{
cv::cornerSubPix(gray1, corners1, cv::Size(5, 5), cv::Size(-1, -1),
cv::TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1));
cv::TermCriteria(TermCriteria::EPS | TermCriteria::MAX_ITER, 30, 0.1));
cv::drawChessboardCorners(gray1, board_size, corners1, found1);
}
if (found2)
{
cv::cornerSubPix(gray2, corners2, cv::Size(5, 5), cv::Size(-1, -1),
cv::TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1));
cv::TermCriteria(TermCriteria::EPS | TermCriteria::MAX_ITER, 30, 0.1));
cv::drawChessboardCorners(gray2, board_size, corners2, found2);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ int main(int argc, char const *argv[])
fsl["D"] >> D1;
fsr["D"] >> D2;
int flag = 0;
flag |= CV_CALIB_FIX_INTRINSIC;
flag |= CALIB_FIX_INTRINSIC;

cout << "Read intrinsics" << endl;

Expand Down
4 changes: 2 additions & 2 deletions undistort_rectify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ int main(int argc, char const *argv[])
Mat K1, K2, R;
Vec3d T;
Mat D1, D2;
Mat img1 = imread(leftimg_filename, CV_LOAD_IMAGE_COLOR);
Mat img2 = imread(rightimg_filename, CV_LOAD_IMAGE_COLOR);
Mat img1 = imread(leftimg_filename, IMREAD_COLOR);
Mat img2 = imread(rightimg_filename, IMREAD_COLOR);

cv::FileStorage fs1(calib_file, cv::FileStorage::READ);
fs1["K1"] >> K1;
Expand Down