Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
opencv_example.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) C. De Wagter
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
27 #include "opencv_example.h"
28 
29 
30 
31 using namespace std;
32 #include <opencv2/core/core.hpp>
33 #include <opencv2/imgproc/imgproc.hpp>
34 using namespace cv;
35 #include "opencv_image_functions.h"
36 
37 
38 int opencv_example(char *img, int width, int height)
39 {
40  // Create a new image, using the original bebop image.
41  Mat M(height, width, CV_8UC2, img);
42  Mat image;
43 
44 #if OPENCVDEMO_GRAYSCALE
45  // Grayscale image example
46  cvtColor(M, image, CV_YUV2GRAY_Y422);
47  // Canny edges, only works with grayscale image
48  int edgeThresh = 35;
49  Canny(image, image, edgeThresh, edgeThresh * 3);
50  // Convert back to YUV422, and put it in place of the original image
51  grayscale_opencv_to_yuv422(image, img, width, height);
52 #else // OPENCVDEMO_GRAYSCALE
53  // Color image example
54  // Convert the image to an OpenCV Mat
55  cvtColor(M, image, CV_YUV2BGR_Y422);
56  // Blur it, because we can
57  blur(image, image, Size(5, 5));
58  // Convert back to YUV422 and put it in place of the original image
59  colorbgr_opencv_to_yuv422(image, img, width, height);
60 #endif // OPENCVDEMO_GRAYSCALE
61 
62  return 0;
63 }
void grayscale_opencv_to_yuv422(Mat image, char *img, int width, int height)
int opencv_example(char *img, int width, int height)
A small library with functions to convert between the Paparazzi used YUV422 arrays and the opencv ima...
void colorbgr_opencv_to_yuv422(Mat image, char *img, int width, int height)