~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/ImgTrans/Laplace_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
 * @file Laplace_Demo.cpp
 
3
 * @brief Sample code showing how to detect edges using the Laplace operator
 
4
 * @author OpenCV team
 
5
 */
 
6
 
 
7
#include "opencv2/imgproc/imgproc.hpp"
 
8
#include "opencv2/imgcodecs.hpp"
 
9
#include "opencv2/highgui/highgui.hpp"
 
10
#include <stdlib.h>
 
11
#include <stdio.h>
 
12
 
 
13
using namespace cv;
 
14
 
 
15
/**
 
16
 * @function main
 
17
 */
 
18
int main( int, char** argv )
 
19
{
 
20
 
 
21
  Mat src, src_gray, dst;
 
22
  int kernel_size = 3;
 
23
  int scale = 1;
 
24
  int delta = 0;
 
25
  int ddepth = CV_16S;
 
26
  const char* window_name = "Laplace Demo";
 
27
 
 
28
  /// Load an image
 
29
  src = imread( argv[1] );
 
30
 
 
31
  if( src.empty() )
 
32
    { return -1; }
 
33
 
 
34
  /// Remove noise by blurring with a Gaussian filter
 
35
  GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
 
36
 
 
37
  /// Convert the image to grayscale
 
38
  cvtColor( src, src_gray, COLOR_RGB2GRAY );
 
39
 
 
40
  /// Create window
 
41
  namedWindow( window_name, WINDOW_AUTOSIZE );
 
42
 
 
43
  /// Apply Laplace function
 
44
  Mat abs_dst;
 
45
 
 
46
  Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
 
47
  convertScaleAbs( dst, abs_dst );
 
48
 
 
49
  /// Show what you got
 
50
  imshow( window_name, abs_dst );
 
51
 
 
52
  waitKey(0);
 
53
 
 
54
  return 0;
 
55
}