-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcplusplus_functions.cpp
More file actions
38 lines (27 loc) · 1.04 KB
/
cplusplus_functions.cpp
File metadata and controls
38 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "cplusplus_header.h"
/* UNIVERSITY OF SAO PAULO - ICMC - GBDI http://www.gbdi.icmc.usp.br/
* Author: Jonathan Ramos, [email protected]
* File: cplusplus_functions.cpp
*/
/**
* Returns a string of bytes from a cv:Mat type.
* <p>
* This method always assume the image is in RGB, i.e., there are three channels
* The encoding is always in .jpg format (OpenCV default quality params)
*
* @param the image in OpenCV mat format.
* @return string with the ByteArray as a String (byteArrayAsString)
*/
cv::Mat cannyEdgeDetection(cv::Mat& image) {
cv::Mat srcGray, edges;
edges.create(image.size(), CV_8UC1);
if (image.channels() > 1) {
// Convert the input image to gray-scale using the OpenCV cvtColor function
cv::cvtColor(image, srcGray, cv::COLOR_BGR2GRAY);
}
// Smooth the gray-scale image to reduce noise by using the OpenCV blur function.
cv::blur(srcGray, edges, cv::Size(3, 3));
// Call the OpenCV Canny function to find edges.
cv::Canny(edges, edges, 10, 30, 3);
return edges;
}