- Home /
EmguCV CalibrateCamera - EntryPointNotFoundException
I'm trying to get EmguCV's CalibrateCamera function to work so that I can estimate the camera position off of points on a planar surface.
this is a snippet of my code with four 3D pseudo positions for testing positions in my scene and four 2D pseudo positions)
Emgu.CV.Structure.MCvPoint3D32f[][] objectPoints = { new MCvPoint3D32f[4] };
for (int i = 0; i < cornerPoints.Length; i++)
{
Vector3 pos = cornerPoints [i].transform.position;
objectPoints [0] [i] = new MCvPoint3D32f(pos.x, pos.y, pos.z);
}
int x1 = 50;
int y1 = 50;
int diff = 10;
PointF[][] imagePoints = { new PointF[4] };
imagePoints [0] [0] = new PointF(-x1, y1);
imagePoints [0] [1] = new PointF(x1, y1);
imagePoints [0] [2] = new PointF(-x1 - diff, -y1);
imagePoints [0] [3] = new PointF(x1 + diff, -y1);
IntrinsicCameraParameters cameraParams = new IntrinsicCameraParameters();
System.Drawing.Size imgSize = new System.Drawing.Size(640,480);
ExtrinsicCameraParameters[] extrinsicParams = new ExtrinsicCameraParameters[1];
Emgu.CV.CameraCalibration.CalibrateCamera(objectPoints,
imagePoints,
imgSize,
cameraParams,
Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_ASPECT_RATIO,
new MCvTermCriteria(0.05),
out extrinsicParams);
unfortunately that's the error I get and I have no idea how to solve it
EntryPointNotFoundException: mono_win32_compat_CopyMemory Emgu.CV.CameraCalibration.ToMatrix[MCvPoint3D32f] (Emgu.CV.Structure.MCvPoint3D32f[][] data) Emgu.CV.CameraCalibration.CalibrateCamera (Emgu.CV.Structure.MCvPoint3D32f[][] objectPoints, System.Drawing.PointF[][] imagePoints, Size imageSize, Emgu.CV.IntrinsicCameraParameters intrinsicParam, CALIB_TYPE calibrationType, MCvTermCriteria termCriteria, Emgu.CV.ExtrinsicCameraParameters[]& extrinsicParams) MyCameraCalibration.Start () (at Assets/CVKinect/Scripts/EmguCV/MyCameraCalibration.cs:76)
it would be great if someone could help me with that. I'm using 4.6.0f3 on win8 64bit
Sorry this isn't an answer but very interested in if you find a solution. I still have to wrap my head around getting OpenCVsharp into unity but this was the exact sort of thing I was hoping to work on but on macosx. Hope you find a solution and will try to contribute once I get set up. Good luck!
Unfortunately I didn't find a solution to this particular problem so I switches to AForge later which worked fine on windows. In less than a day I got the camera calibration roughly working without worrying about camera intrinsics too much. $$anonymous$$aybe this helps you if you don't rely on OpenCV (or combine them both): http://www.aforgenet.com/articles/posit/
I bet the bullet and paid for the OpenCV Java asset that is on the asset store because of the support provided through the publisher I imagine I'll be able to accomplish my goal and have the necessary support to make it functional if I run into any errors
To hazard a total Noobian guess:
mono_win32_compat_Copy$$anonymous$$emory is a dll of mono. This dll is not being properly accessed.
I can't tell what line 76 is in your code.
I am a little inexperienced with this, but perhaps you need to DllImport the dll you wish to utilise.
Visual_Lies: I'd appreciate If you'd share your experience with me once you got it running or get stuck or something! :)
Answer by Ben-Kuper · Apr 28, 2015 at 03:18 AM
Hi, i managed to fix the error by modifying DllImport in ToolBox.cs, line 455 (EmguCV 2.4.10) and recompiling EmguCV solution
this looks like this now :
[DllImport("kernel32.dll")]//, EntryPoint = "CopyMemory")] public static extern void memcpy(IntPtr dest, IntPtr src, int len);
Basically, i just commented out the EntryPoint name as i read someone indicating that memcpy is already linked to CopyMemory in kernel32.dll
I just tested with Unity 4.6.2f1 on Win8.1 x64 and it works :)
You can either recompile EmguCV yourself or download directly my modified version here : https://drive.google.com/file/d/0B_NjgJ40OskwTDBpbVR2X1VMUXc/view?usp=sharing
Cheers Ben Kuper
Hi Ben, that's great. I'm looking forward to try it as soon as I have some time. Thanks for sharing it :-)
Answer by Ben-Kuper · Apr 28, 2015 at 06:45 AM
By the way, if you're looking for an EmguCV / Unity demo of CameraCalibration, i have an operational setup, both x64 and x86 here :
https://github.com/benkuper/Mappity
If you want to build and export an executable, be sure that you copy all the opencv related dll files from _Data/Plugins in your application root folder (see Export/x86 and Export/x64 folders)