After opencv2.0, the question and Implementation of the mat matrix single-row assignment and matrix merging of the C ++ interface will be added (painstaking research has been done for many days !)

Source: Internet
Author: User

Background: there are now n cvmat matrices, each of which is a 1 * m row vector, that is, each cvmat represents a sample feature vector.

Now we need to apply for an N * M matrix, that is, a matrix of N rows and M columns. Each row represents a sample feature vector. The dimension of the feature vector is M. This problem is also entangled in my multi-day matrix merging problem.

 Solution:

Cvmat * palm = (cvmat *) cvload (PATH); // obtain a row vector.

Mat tempmat = MAT (Palm, true); // convert cvmat to mat
Mat dsttemp = M. Row (n); // m is the target matrix N * m
Tempmat. copyto (dsttemp );//

How can I check the m value? I can say cout <m on the Internet, but I am not successful on my computer. I don't know what's going on.

My own method:

Const float * pdata = M. PTR <float> (1); // This is the value of the second row. If you view the first row, change it to <float> (0)
For (INT I = 0; I <M. Cols; I ++)
Cout <pdata [I] <Endl;

Now, the problem is solved perfectly !!! Nnd, let me study for a few days.

Refer:

(1) http://stackoverflow.com/questions/8005627/opencv-2-3-copyto-function-not-working-as-it-was-in-2-2

(2) http://hi.baidu.com/%BE%B2%C7%C4%C7%C4%B5%D8%B0% AE %D7%C5%C4%E3/blog/item/509b7d198c12742734fa417e.html#0 I follow this method, error:

Error: no matching function for call to 'cv: mat: copyto (CV: mat) '(3) http://www.opencv.org.cn/forum/viewtopic.php? P = 2987 is implemented based on the cvmat type. It is too troublesome. I have no experiment. Let me know the result!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.