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 *.transform.position;*

_ objectPoints [0] = 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

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 :slight_smile:

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

By the way, if you’re looking for an EmguCV / Unity demo of CameraCalibration, i have an operational setup, both x64 and x86 here :

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)