Skip to content

Commit

Permalink
"filter" app to process and store image
Browse files Browse the repository at this point in the history
  • Loading branch information
npazosmendez committed Nov 25, 2018
1 parent b3d50ac commit 63c0551
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ inpainter
linedetector
flowcalculator
tests
filter

# Directories
docs/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ifeq ($(shell uname -s),Linux)
endif

# Apps
APPS := inpainter linedetector flowcalculator tests timer
APPS := inpainter linedetector flowcalculator tests timer filter

apps: CPPFLAGS += -O3 -g
apps: $(APPS)
Expand Down
75 changes: 75 additions & 0 deletions apps/filter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <iostream>
extern "C" {
#include "c/c-filters.h"
}
#include "opencl/opencl-filters.hpp"
#include <set>
#include <map>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;


int width;
int height;

Mat source_image;

Mat image1;
Mat image2;

map<string, string> parse_args(int argc, const char** argv){
map<string, string> result;
for (int i = 0; i < argc; ++i){
string key = argv[i];
if (key.size() > 1 and key[0] == '-' and key[1] == '-'){
if (i+1 < argc){
result[key] = argv[i+1];
}else{
result[key] = "";
}
}
}
return result;
}

int main(int argc, const char** argv) {

map<string, string> arguments = parse_args(argc, argv);

if (arguments.count("--help")){
cout << "Timing application for the filters. For custom timing try:" << endl;
cout << "\t--filter <filter_name> (canny/hough/kanade/inpainting)" << endl;
cout << "\t--image <image_path>" << endl;
cout << "\t--output <output_image_path>" << endl;
cout << "\t--help" << endl;
return 0;
}

if (not arguments.count("--filter")){
cerr << "No filter selected" << endl;
abort();
}
if (not arguments.count("--output")){
cerr << "No output path specified" << endl;
abort();
}

string filter = arguments["--filter"];
string output = arguments["--output"];

if (filter == "canny"){
image1 = imread(arguments["--image"], CV_LOAD_IMAGE_COLOR);
CL_canny((char*)image1.ptr(), image1.size().width, image1.size().height, 100, 70);
imwrite(output, image1);
}else if(filter == "hough"){
image1 = imread(arguments["--image"], CV_LOAD_IMAGE_COLOR);
CL_hough((char*)image1.ptr(), image1.size().width, image1.size().height, 300, 300, NULL);
imwrite(output, image1);
}


return 0;
}

0 comments on commit 63c0551

Please sign in to comment.