~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* npr_demo.cpp
 
3
*
 
4
* Author:
 
5
* Siddharth Kherada <siddharthkherada27[at]gmail[dot]com>
 
6
*
 
7
* This tutorial demonstrates how to use OpenCV Non-Photorealistic Rendering Module.
 
8
* 1) Edge Preserve Smoothing
 
9
*    -> Using Normalized convolution Filter
 
10
*    -> Using Recursive Filter
 
11
* 2) Detail Enhancement
 
12
* 3) Pencil sketch/Color Pencil Drawing
 
13
* 4) Stylization
 
14
*
 
15
*/
 
16
 
 
17
#include <signal.h>
 
18
#include "opencv2/photo.hpp"
 
19
#include "opencv2/imgproc.hpp"
 
20
#include "opencv2/highgui.hpp"
 
21
#include "opencv2/core.hpp"
 
22
#include <iostream>
 
23
#include <stdlib.h>
 
24
 
 
25
using namespace std;
 
26
using namespace cv;
 
27
 
 
28
int main(int argc, char* argv[])
 
29
{
 
30
    if(argc < 2)
 
31
    {
 
32
        cout << "usage: " << argv[0] << " <Input image> "  << endl;
 
33
        exit(0);
 
34
    }
 
35
 
 
36
    int num,type;
 
37
 
 
38
    Mat I = imread(argv[1]);
 
39
 
 
40
    if(I.empty())
 
41
    {
 
42
        cout <<  "Image not found" << endl;
 
43
        exit(0);
 
44
    }
 
45
 
 
46
    cout << endl;
 
47
    cout << " Edge Preserve Filter" << endl;
 
48
    cout << "----------------------" << endl;
 
49
 
 
50
    cout << "Options: " << endl;
 
51
    cout << endl;
 
52
 
 
53
    cout << "1) Edge Preserve Smoothing" << endl;
 
54
    cout << "   -> Using Normalized convolution Filter" << endl;
 
55
    cout << "   -> Using Recursive Filter" << endl;
 
56
    cout << "2) Detail Enhancement" << endl;
 
57
    cout << "3) Pencil sketch/Color Pencil Drawing" << endl;
 
58
    cout << "4) Stylization" << endl;
 
59
    cout << endl;
 
60
 
 
61
    cout << "Press number 1-4 to choose from above techniques: ";
 
62
 
 
63
    cin >> num;
 
64
 
 
65
    Mat img;
 
66
 
 
67
    if(num == 1)
 
68
    {
 
69
        cout << endl;
 
70
        cout << "Press 1 for Normalized Convolution Filter and 2 for Recursive Filter: ";
 
71
 
 
72
        cin >> type;
 
73
 
 
74
        edgePreservingFilter(I,img,type);
 
75
        imshow("Edge Preserve Smoothing",img);
 
76
 
 
77
    }
 
78
    else if(num == 2)
 
79
    {
 
80
        detailEnhance(I,img);
 
81
        imshow("Detail Enhanced",img);
 
82
    }
 
83
    else if(num == 3)
 
84
    {
 
85
        Mat img1;
 
86
        pencilSketch(I,img1, img, 10 , 0.1f, 0.03f);
 
87
        imshow("Pencil Sketch",img1);
 
88
        imshow("Color Pencil Sketch",img);
 
89
    }
 
90
    else if(num == 4)
 
91
    {
 
92
        stylization(I,img);
 
93
        imshow("Stylization",img);
 
94
    }
 
95
    waitKey(0);
 
96
}