2010-11-20 10:04:41 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* cvout_sample just demonstrates the serial out capabilities of cv::Mat
|
|
|
|
* That is, cv::Mat M(...); cout << M; Now works.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-02-15 21:37:29 +08:00
|
|
|
#include "opencv2/core.hpp"
|
2010-11-16 01:40:57 +08:00
|
|
|
#include <iostream>
|
2010-11-14 14:28:41 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
|
2020-02-23 21:38:04 +08:00
|
|
|
static void help(char** argv)
|
2010-11-20 10:04:41 +08:00
|
|
|
{
|
2012-06-08 01:21:29 +08:00
|
|
|
cout
|
|
|
|
<< "\n------------------------------------------------------------------\n"
|
|
|
|
<< " This program shows the serial out capabilities of cv::Mat\n"
|
|
|
|
<< "That is, cv::Mat M(...); cout << M; Now works.\n"
|
2018-02-08 18:51:54 +08:00
|
|
|
<< "Output can be formatted to OpenCV, matlab, python, numpy, csv and \n"
|
2014-04-16 09:56:27 +08:00
|
|
|
<< "C styles Usage:\n"
|
2020-02-23 21:38:04 +08:00
|
|
|
<< argv[0]
|
|
|
|
<< "\n------------------------------------------------------------------\n\n"
|
2012-06-08 01:21:29 +08:00
|
|
|
<< endl;
|
2010-11-20 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-01 23:24:23 +08:00
|
|
|
int main(int argc, char** argv)
|
2010-11-14 14:28:41 +08:00
|
|
|
{
|
2015-08-01 23:24:23 +08:00
|
|
|
cv::CommandLineParser parser(argc, argv, "{help h||}");
|
|
|
|
if (parser.has("help"))
|
|
|
|
{
|
2020-02-23 21:38:04 +08:00
|
|
|
help(argv);
|
2015-08-01 23:24:23 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2012-06-12 22:46:12 +08:00
|
|
|
Mat I = Mat::eye(4, 4, CV_64F);
|
|
|
|
I.at<double>(1,1) = CV_PI;
|
2013-04-02 19:18:17 +08:00
|
|
|
cout << "I = \n" << I << ";" << endl << endl;
|
2010-11-16 01:40:57 +08:00
|
|
|
|
|
|
|
Mat r = Mat(10, 3, CV_8UC3);
|
|
|
|
randu(r, Scalar::all(0), Scalar::all(255));
|
|
|
|
|
2013-04-02 19:18:17 +08:00
|
|
|
cout << "r (default) = \n" << r << ";" << endl << endl;
|
2014-04-16 09:56:27 +08:00
|
|
|
cout << "r (matlab) = \n" << format(r, Formatter::FMT_MATLAB) << ";" << endl << endl;
|
2013-04-02 19:18:17 +08:00
|
|
|
cout << "r (python) = \n" << format(r, Formatter::FMT_PYTHON) << ";" << endl << endl;
|
|
|
|
cout << "r (numpy) = \n" << format(r, Formatter::FMT_NUMPY) << ";" << endl << endl;
|
|
|
|
cout << "r (csv) = \n" << format(r, Formatter::FMT_CSV) << ";" << endl << endl;
|
|
|
|
cout << "r (c) = \n" << format(r, Formatter::FMT_C) << ";" << endl << endl;
|
2010-11-16 01:40:57 +08:00
|
|
|
|
|
|
|
Point2f p(5, 1);
|
|
|
|
cout << "p = " << p << ";" << endl;
|
|
|
|
|
|
|
|
Point3f p3f(2, 6, 7);
|
|
|
|
cout << "p3f = " << p3f << ";" << endl;
|
|
|
|
|
|
|
|
vector<float> v;
|
|
|
|
v.push_back(1);
|
|
|
|
v.push_back(2);
|
|
|
|
v.push_back(3);
|
2012-06-08 01:21:29 +08:00
|
|
|
|
2010-11-16 01:40:57 +08:00
|
|
|
cout << "shortvec = " << Mat(v) << endl;
|
2012-06-08 01:21:29 +08:00
|
|
|
|
2010-11-16 01:40:57 +08:00
|
|
|
vector<Point2f> points(20);
|
|
|
|
for (size_t i = 0; i < points.size(); ++i)
|
2010-11-26 00:55:46 +08:00
|
|
|
points[i] = Point2f((float)(i * 5), (float)(i % 7));
|
2010-11-16 01:40:57 +08:00
|
|
|
|
|
|
|
cout << "points = " << points << ";" << endl;
|
|
|
|
return 0;
|
2010-11-14 14:28:41 +08:00
|
|
|
}
|