OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 01 May 2015 09:41:44 -0500Construct a Mat of pointers to a Mathttp://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/ Hi all!
I've tried to google this a lot - but without any luck. Hope you can help!
Basically I want to construct the following cyclic matrix<br>
M = <br>
|*a *b *c|<br>
|*b *c *a|<br>
|*c *a *b|
where the elements are pointers to a 1D Mat<br>
v = (a b c)<br>
Such that whenever I change a value in the vector the matrix is then updated accordingly, and I can multiply the matrix M with another matrix for instance.
Am I supposed to use something like Ptr<Mat> to initialise M? And how do I assign pointers to this matrix?
I'm using C++.
Best AlThu, 30 Apr 2015 09:23:32 -0500http://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/Comment by berak for <p>Hi all!</p>
<p>I've tried to google this a lot - but without any luck. Hope you can help!</p>
<p>Basically I want to construct the following cyclic matrix<br/></p>
<p>M = <br/>
|<em>a *b *c|<br/>
|</em>b <em>c *a|<br/>
|</em>c *a *b|</p>
<p>where the elements are pointers to a 1D Mat<br/> </p>
<p>v = (a b c)<br/></p>
<p>Such that whenever I change a value in the vector the matrix is then updated accordingly, and I can multiply the matrix M with another matrix for instance.</p>
<p>Am I supposed to use something like Ptr<mat> to initialise M? And how do I assign pointers to this matrix?
I'm using C++.</p>
<p>Best Al</p>
http://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/?comment=60955#post-id-60955i don't think this is possible. also, Mat is a smartpointer on it's own already, so moving the address of it around will inevitably lead to refcounting trouble.
since constructing a new Mat like: `Mat_<float> m(3,3); m<<a,c,b,b,c,a,c,a,b;` is so easy, i would not even bother to go 'artistic' here.Thu, 30 Apr 2015 09:41:58 -0500http://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/?comment=60955#post-id-60955Comment by boaz001 for <p>Hi all!</p>
<p>I've tried to google this a lot - but without any luck. Hope you can help!</p>
<p>Basically I want to construct the following cyclic matrix<br/></p>
<p>M = <br/>
|<em>a *b *c|<br/>
|</em>b <em>c *a|<br/>
|</em>c *a *b|</p>
<p>where the elements are pointers to a 1D Mat<br/> </p>
<p>v = (a b c)<br/></p>
<p>Such that whenever I change a value in the vector the matrix is then updated accordingly, and I can multiply the matrix M with another matrix for instance.</p>
<p>Am I supposed to use something like Ptr<mat> to initialise M? And how do I assign pointers to this matrix?
I'm using C++.</p>
<p>Best Al</p>
http://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/?comment=61012#post-id-61012Or you can implement this data structure yourself, it shouldn't be too hard.. once you have that you can easily create conversion functions from/to this data structure. Happy coding :)!Fri, 01 May 2015 09:41:44 -0500http://answers.opencv.org/question/60954/construct-a-mat-of-pointers-to-a-mat/?comment=61012#post-id-61012