718c41634f
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
100 lines
2.3 KiB
C++
100 lines
2.3 KiB
C++
/*
|
|
* npr_demo.cpp
|
|
*
|
|
* Author:
|
|
* Siddharth Kherada <siddharthkherada27[at]gmail[dot]com>
|
|
*
|
|
* This tutorial demonstrates how to use OpenCV Non-Photorealistic Rendering Module.
|
|
* 1) Edge Preserve Smoothing
|
|
* -> Using Normalized convolution Filter
|
|
* -> Using Recursive Filter
|
|
* 2) Detail Enhancement
|
|
* 3) Pencil sketch/Color Pencil Drawing
|
|
* 4) Stylization
|
|
*
|
|
*/
|
|
|
|
#include <signal.h>
|
|
#include "opencv2/photo.hpp"
|
|
#include "opencv2/imgproc.hpp"
|
|
#include "opencv2/imgcodecs.hpp"
|
|
#include "opencv2/highgui.hpp"
|
|
#include "opencv2/core.hpp"
|
|
#include <iostream>
|
|
#include <stdlib.h>
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
cv::CommandLineParser parser(argc, argv, "{help h||show help message}{@image|lena.jpg|input image}");
|
|
if (parser.has("help"))
|
|
{
|
|
parser.printMessage();
|
|
return 0;
|
|
}
|
|
string filename = samples::findFile(parser.get<string>("@image"));
|
|
|
|
Mat I = imread(filename);
|
|
|
|
int num,type;
|
|
|
|
if(I.empty())
|
|
{
|
|
cout << "Image not found" << endl;
|
|
return 1;
|
|
}
|
|
|
|
cout << endl;
|
|
cout << " Edge Preserve Filter" << endl;
|
|
cout << "----------------------" << endl;
|
|
|
|
cout << "Options: " << endl;
|
|
cout << endl;
|
|
|
|
cout << "1) Edge Preserve Smoothing" << endl;
|
|
cout << " -> Using Normalized convolution Filter" << endl;
|
|
cout << " -> Using Recursive Filter" << endl;
|
|
cout << "2) Detail Enhancement" << endl;
|
|
cout << "3) Pencil sketch/Color Pencil Drawing" << endl;
|
|
cout << "4) Stylization" << endl;
|
|
cout << endl;
|
|
|
|
cout << "Press number 1-4 to choose from above techniques: ";
|
|
|
|
cin >> num;
|
|
|
|
Mat img;
|
|
|
|
if(num == 1)
|
|
{
|
|
cout << endl;
|
|
cout << "Press 1 for Normalized Convolution Filter and 2 for Recursive Filter: ";
|
|
|
|
cin >> type;
|
|
|
|
edgePreservingFilter(I,img,type);
|
|
imshow("Edge Preserve Smoothing",img);
|
|
|
|
}
|
|
else if(num == 2)
|
|
{
|
|
detailEnhance(I,img);
|
|
imshow("Detail Enhanced",img);
|
|
}
|
|
else if(num == 3)
|
|
{
|
|
Mat img1;
|
|
pencilSketch(I,img1, img, 10 , 0.1f, 0.03f);
|
|
imshow("Pencil Sketch",img1);
|
|
imshow("Color Pencil Sketch",img);
|
|
}
|
|
else if(num == 4)
|
|
{
|
|
stylization(I,img);
|
|
imshow("Stylization",img);
|
|
}
|
|
waitKey(0);
|
|
}
|