opencv-Mat补充

opencv2.4.3所给代码如下:

/*  For description look into the help() function. */

#include "opencv2/core/core.hpp"
#include <iostream>
//#include <opencv2/core/core.hpp>
//#include <opencv2/highgui/highgui.hpp>
//#include <cv.h>
//#include <iostream>

using namespace std;
using namespace cv;

void help()
{
    cout
    << "\n--------------------------------------------------------------------------" << endl
    << "This program shows how to create matrices(cv::Mat) in OpenCV and its serial"
    << " out capabilities"                                                            << endl
    << "That is, cv::Mat M(...); M.create and cout << M. "                            << endl
    << "Shows how output can be formated to OpenCV, python, numpy, csv and C styles." << endl
    << "Usage:"                                                                       << endl
    << "./cvout_sample"                                                               << endl
    << "--------------------------------------------------------------------------"   << endl
    << endl;
}

int main(int,char**)
{
    help();
    // create by using the constructor
    Mat M(2,2, CV_8UC3, Scalar(0,0,255));
    cout << "M = " << endl << " " << M << endl << endl;

    // create by using the create function()
    M.create(4,4, CV_8UC(2));
    cout << "M = "<< endl << " "  << M << endl << endl;

    // create multidimensional matrices
    int sz[3] = {2,2,2};
    Mat L(3,sz, CV_8UC(1), Scalar::all(0));
    // Cannot print via operator <<

    // Create using MATLAB style eye, ones or zero matrix
    Mat E = Mat::eye(4, 4, CV_64F);
    cout << "E = " << endl << " " << E << endl << endl;

    Mat O = Mat::ones(2, 2, CV_32F);
    cout << "O = " << endl << " " << O << endl << endl;

    Mat Z = Mat::zeros(3,3, CV_8UC1);
    cout << "Z = " << endl << " " << Z << endl << endl;

    // create a 3x3 double-precision identity matrix
    Mat C = (Mat_<double>(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
    cout << "C = " << endl << " " << C << endl << endl;

    Mat RowClone = C.row(1).clone();
    cout << "RowClone = " << endl << " " << RowClone << endl << endl;

    // Fill a matrix with random values
    Mat R = Mat(3, 2, CV_8UC3);
    randu(R, Scalar::all(0), Scalar::all(255));

    // Demonstrate the output formating options
    cout << "R (default) = " << endl <<        R           << endl << endl;
    cout << "R (python)  = " << endl << format(R,"python") << endl << endl;
    cout << "R (numpy)   = " << endl << format(R,"numpy" ) << endl << endl;
    cout << "R (csv)     = " << endl << format(R,"csv"   ) << endl << endl;
    cout << "R (c)       = " << endl << format(R,"C"     ) << endl << endl;

    Point2f P(5, 1);
    cout << "Point (2D) = " << P << endl << endl;

    Point3f P3f(2, 6, 7);
    cout << "Point (3D) = " << P3f << endl << endl;


    vector<float> v;
    v.push_back( (float)CV_PI);   v.push_back(2);    v.push_back(3.01f);

    cout << "Vector of floats via Mat = " << Mat(v) << endl << endl;

    vector<Point2f> vPoints(20);
    for (size_t E = 0; E < vPoints.size(); ++E)
        vPoints[E] = Point2f((float)(E * 5), (float)(E % 7));

    cout << "A vector of 2D Points = " << vPoints << endl << endl;
    return 0;
}


g++ -std=c++11 -I/usr/local/include -I/home/tian/ofcs/src/SeetaFace6OpenBinary-main/CPU/SeetaFace/index/build/include -I/home/tian/opencv-4.1.0/include -I/home/tian/opencv-4.1.0/build -I/home/tian/opencv-4.1.0/modules/core/include -I/home/tian/opencv-4.1.0/modules/calib3d/include -I/home/tian/opencv-4.1.0/modules/features2d/include -I/home/tian/opencv-4.1.0/modules/flann/include -I/home/tian/opencv-4.1.0/modules/dnn/include -I/home/tian/opencv-4.1.0/modules/objdetect/include -I/home/tian/opencv-4.1.0/modules/stitching/include -I/home/tian/opencv-4.1.0/modules/ml/include -I/home/tian/opencv-4.1.0/modules/imgproc/include -I/home/tian/opencv-4.1.0/modules/photo/include -I/home/tian/opencv-4.1.0/modules/video/include -I/home/tian/opencv-4.1.0/modules/videoio/include -I/home/tian/opencv-4.1.0/modules/imgcodecs/include -I/home/tian/opencv-4.1.0/modules/highgui/include -o test test.o -L/usr/local/lib -L/home/tian/ofcs/src/SeetaFace6OpenBinary-main/CPU/SeetaFace/index/build/lib64 -L/home/tian/ofcs/src/SeetaFace6OpenBinary-main/CPU/SeetaFace/index/build/lib -lSeetaFaceDetector600 -lSeetaFaceLandmarker600 -lSeetaFaceRecognizer610 -lopencv_world test.o: In function `test1()': test.cpp:(.text+0x76f): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' test.cpp:(.text+0xa3d): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' test.cpp:(.text+0xaf7): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' test.cpp:(.text+0xd85): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' /home/tian/ofcs/src/SeetaFace6OpenBinary-main/CPU/SeetaFace/index/build/lib64/libtennis.so: undefined reference to `exp@GLIBC_2.29' /home/tian/ofcs/src/SeetaFace6O
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Digital2Slave

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值