Paparazzi UAS  v5.14.0_stable-0-g3f680d1
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 int opencv_example(char *img, int width, int height)
38 {
39  // Create a new image, using the original bebop image.
40  Mat M(height, width, CV_8UC2, img);
41  Mat image;
42  // If you want a color image, uncomment this line
43 // cvtColor(M, image, CV_YUV2BGR_Y422);
44  // For a grayscale image, use this one
45  cvtColor(M, image, CV_YUV2GRAY_Y422);
46 
47  // Blur it, because we can
48 // blur(image, image, Size(5, 5));
49 
50  // Canny edges, only works with grayscale image
51  int edgeThresh = 35;
52  Canny(image, image, edgeThresh, edgeThresh * 3);
53 
54  // Convert back to YUV422, and put it in place of the original image
55  grayscale_opencv_to_yuv422(image, img, width, height);
56 // colorrgb_opencv_to_yuv422(image, img, width, height);
57 
58  return 0;
59 }
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...