close

Mat::copyTo

Copies the matrix to another one.

C++: void Mat::copyTo(OutputArray m) const
C++: void Mat::copyTo(OutputArray m, InputArray mask) const
Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[,fillValue]) constructor. A new array of the specified size and type is allocated. type has the same meaning as in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel arrayCV_32FC2 means a 2-channel (complex) floating-point array, and so on.

// add the 5-th row, multiplied by 3 to the 3rd row
M.row(3) = M.row(3) + M.row(5)*3;

// now copy the 7-th column to the 1-st column
// M.col(1) = M.col(7); // this will not work
Mat M1 = M.col(1);
M.col(7).copyTo(M1);

// create a new 320x240 image
Mat img(Size(320,240),CV_8UC3);
// select a ROI
Mat roi(img, Rect(10,10,100,100));
// fill the ROI with (0,255,0) (which is green in RGB space);
// the original 320x240 image will be modified
roi = Scalar(0,255,0);

 

    int i=0;
    while(true)
    {
        frame = cvQueryFrame(capture);  <-------------一定要有,不然下張圖(frame)不會出現!
        cvWriteFrame(writer,frame);

        cvShowImage("Webcam",frame);
        printf("%d\n",i);

        if(cvWaitKey(20)>0)     break;
        i++;
    }

 ref:

http://docs.opencv.org/modules/core/doc/basic_structures.html#mat

arrow
arrow
    全站熱搜

    大玩家闖天涯 發表在 痞客邦 留言(0) 人氣()