Skip to content

Instantly share code, notes, and snippets.

@rodolfoap
Last active September 17, 2020 09:54
Show Gist options
  • Save rodolfoap/728014d9388507362892c298a6aea3ea to your computer and use it in GitHub Desktop.
Save rodolfoap/728014d9388507362892c298a6aea3ea to your computer and use it in GitHub Desktop.
Compiling filter
/bilateral_filter.*
/build/
#include <iostream>
#include <opencv2/opencv.hpp>
#include "bilateral_filter.simd.hpp"
int main(int argc, char** argv) {
if(argc<5){ std::cerr<<"Usage: "<<argv[0]<<" [INPUT OUTPUT DIAMETER SIGMA_COLOR SIGMA_SPACE]"<<std::endl; exit(1); }
cv::Mat input=cv::imread(argv[1]), output;
bilateralFilter(input, output, std::stoi(argv[3]), std::stod(argv[4]), std::stoi(argv[5]), cv::BORDER_DEFAULT);
cv::namedWindow("Result", cv::WINDOW_NORMAL);
cv::imwrite(argv[2], output);
cv::imshow("Result", output);
cv::waitKey(0);
return 0;
}
cmake_minimum_required(VERSION 3.10)
project(app)
# Force C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Equivalent to (CFLAGS) -g
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Equivalent to (CFLAGS) -g
set(CMAKE_C_FLAGS "-g")
# OPENCV ####################################
find_package(OpenCV REQUIRED)
add_executable(app app.cpp bilateral_filter.dispatch.cpp)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(app ${OpenCV_LIBS})
#!/bin/bash
[ -f bilateral_filter.dispatch.cpp ] || wget https://raw.githubusercontent.com/opencv/opencv/master/modules/imgproc/src/bilateral_filter.dispatch.cpp
[ -f bilateral_filter.simd.hpp ] || wget https://raw.githubusercontent.com/opencv/opencv/master/modules/imgproc/src/bilateral_filter.simd.hpp
[ -d build ] || mkdir build;
[ -f app ] || { pushd build &>/dev/null; cmake ..; make -j$(nproc); popd &>/dev/null; }
./app vis1000.jpg result.jpg 3 75 75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment