1 #include <opencv2/core.hpp>
2 #include <opencv2/imgproc.hpp>
3 #include <opencv2/imgcodecs.hpp>
4 #include <opencv2/highgui.hpp>
5
6 using namespace cv;
7 const char* message = "Hello Android!";
8
main(int argc,char * argv[])9 int main(int argc, char* argv[])
10 {
11 (void)argc; (void)argv;
12 // print message to console
13 printf("%s\n", message);
14
15 // put message to simple image
16 Size textsize = getTextSize(message, FONT_HERSHEY_COMPLEX, 3, 5, 0);
17 Mat img(textsize.height + 20, textsize.width + 20, CV_32FC1, Scalar(230,230,230));
18 putText(img, message, Point(10, img.rows - 10), FONT_HERSHEY_COMPLEX, 3, Scalar(0, 0, 0), 5);
19
20 // save\show resulting image
21 #if ANDROID
22 imwrite("/mnt/sdcard/HelloAndroid.png", img);
23 #else
24 imshow("test", img);
25 waitKey();
26 #endif
27 return 0;
28 }
29