Skip to content

Instantly share code, notes, and snippets.

@TeddybearCrisis
Created May 3, 2020 01:07
Show Gist options
  • Save TeddybearCrisis/5b138f091e51b4e080212e076ee7f2ae to your computer and use it in GitHub Desktop.
Save TeddybearCrisis/5b138f091e51b4e080212e076ee7f2ae to your computer and use it in GitHub Desktop.
Update old OpenCV syntax to OpenCV 4
!#/bin/bash
# original: https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/912#issue-377202823
find src utils \( -name '*.cpp' -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_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_FOURCC/cv::VideoWriter::fourcc/g' \
'{}' ';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment