loading intrisinc parameters

Ask questions on using Emgu CV with C++
Post Reply
zlc
Posts: 12
Joined: Tue Apr 21, 2009 7:38 am

loading intrisinc parameters

Post by zlc » Fri May 22, 2009 8:29 am

In OpenCv in order to load the intrisinc parameters from an xml file i use:
CvMat *intrinsic = (CvMat*)cvLoad("Intrinsics.xml");

how it would be in EmguCV?

canming
Site Admin
Posts: 1038
Joined: Thu Feb 28, 2008 4:16 pm

Re: loading intrisinc parameters

Post by canming » Fri May 22, 2009 3:06 pm

To load an OpenCV format XML matrix file, you can do

Code: Select all

IntPtr mat = CvInvoke.cvLoad("Intrinsics.xml", IntPtr.Zero, null, IntPtr.Zero);
Matrix<double> intrinsicMatrix = new Matrix<double>(3, 3);
CvInvoke.cvCopy(mat, intrinsicMatrix, IntPtr.Zero);
CvInvoke.cvRelease(ref mat);
I am writing it in C# syntax, it should be easy to translation it to Manage C++.

zlc
Posts: 12
Joined: Tue Apr 21, 2009 7:38 am

Re: loading intrisinc parameters

Post by zlc » Sat May 23, 2009 2:12 pm

I rewrote it to c++/cli but have some problems.

Code: Select all

IntPtr mat = CvInvoke::cvLoad("Intrinsics.xml", IntPtr::Zero, NULL, IntPtr::Zero);
In this line i get error: cannot convert parameter 3 from 'int' to 'System::String ^'
So i convert it to

Code: Select all

IntPtr mat = CvInvoke::cvLoad("Intrinsics.xml", IntPtr::Zero, NULL.ToString(), IntPtr::Zero);
next problem in line:

Code: Select all

Matrix<double> intrinsincMatrix = gcnew Matrix<double>(3, 3);
in this line i get error: error C2664: 'Emgu::CV::Matrix<TDepth>::Matrix(cli::array<Type> ^)' : cannot convert parameter 1 from 'Emgu::CV::Matrix<TDepth> ^' to 'cli::array<Type> ^'

so it obvious that the code

Code: Select all

CvInvoke::cvCopy(mat, intrinsicMatrix, IntPtr.Zero);
can't be compiled

And in the line

CvInvoke.cvRelease(ref mat); in c++/cli i don't have cvRelease method

Please help me to deal with this.

canming
Site Admin
Posts: 1038
Joined: Thu Feb 28, 2008 4:16 pm

Re: loading intrisinc parameters

Post by canming » Sat May 23, 2009 4:19 pm

CvMat *mat = (CvMat*)cvLoad("Intrinsics.xml");
Matrix<double>^ intrinsicMatrix = gcnew Matrix<double>(3, 3);
cvCopy(mat, intrinsicMatrix.Ptr.ToPointer());
cvReleaseMat(& mat);[/code]

Post Reply