Skip to content

Instantly share code, notes, and snippets.

@goldbattle
Created July 8, 2020 05:23
Show Gist options
  • Save goldbattle/b2cf968003abea2132453f0774f13e4a to your computer and use it in GitHub Desktop.
Save goldbattle/b2cf968003abea2132453f0774f13e4a to your computer and use it in GitHub Desktop.
Script to update Kalibr calibration toolbox to use opencv 4 (allows compiling on ubuntu 18.04).
#!/bin/sh
# update from old OPENCV to the newest OPENCV 3/4
# https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/912#issue-377202823
# place this file in your /kalibr/ directory and run it
# -> you will still need to comment out cvStartWindowThread(); function calls
# -> aslamcv_helper.hpp needs to be corrected for the pointer logic
# -> cv::Ptr<cv::Mat> _pts(new cv::Mat(1, N * N, CV_32FC2));
# -> cv::Point2f* pts = (cv::Point2f*) (_pts->data);
find . \( -name '*.cpp' -or -name '*.c' -or -name '*.hpp' -or -name '*.h' \) \
-exec sed -i \
-e 's/CV_IMWRITE_/cv::IMWRITE_/g' \
-e 's/CV_LOAD_IMAGE_ANYDEPTH/cv::IMREAD_ANYDEPTH/g' \
-e 's/CV_LOAD_IMAGE_COLOR/cv::IMREAD_COLOR/g' \
-e 's/CV_L2/cv::NORM_L2/g' \
-e 's/CV_TERMCRIT_EPS/cv::TermCriteria::EPS/g' \
-e 's/CV_TERMCRIT_ITER/cv::TermCriteria::MAX_ITER/g' \
-e 's/CV_CALIB_CB_/cv::CALIB_CB_/g' \
-e 's/CV_BGR2GRAY/cv::COLOR_BGR2GRAY/g' \
-e 's/CV_GRAY2BGR/cv::COLOR_GRAY2BGR/g' \
-e 's/CV_GRAY2RGB/cv::COLOR_GRAY2RGB/g' \
-e 's/CV_HAAR_/cv::CASCADE_/g' \
-e 's/CV_INTER_/cv::INTER_/g' \
-e 's/CV_WARP_INVERSE_MAP/cv::WARP_INVERSE_MAP/g' \
-e 's/CV_WINDOW_/cv::WINDOW_/g' \
-e 's/CV_WND_/cv::WND_/g' \
-e 's/CV_CAP_/cv::CAP_/g' \
-e 's/CV_LOAD_IMAGE_GRAYSCALE/cv::IMREAD_GRAYSCALE/g' \
-e 's/CV_LOAD_IMAGE_COLOR/cv::IMREAD_COLOR/g' \
-e 's/CV_FONT_/cv::FONT_/g' \
-e 's/CV_FOURCC/cv::VideoWriter::fourcc/g' \
-e 's/CvSize/cv::Size/g' \
-e 's/cvCreateMat/cv::Mat::zeros/g' \
-e 's/cvPoint2D32f/cv::Point2f/g' \
-e 's/CvPoint2D32f/cv::Point2f/g' \
-e 's/CvMat/cv::Mat/g' \
'{}' ';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment