• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by marwi · Jan 07, 2015 at 07:00 PM · opencvemgucv

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

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Visual_Lies · Jan 29, 2015 at 11:01 AM 0
Share

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!

avatar image marwi · Jan 29, 2015 at 02:01 PM 0
Share

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/

avatar image Visual_Lies · Jan 29, 2015 at 03:13 PM 0
Share

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

avatar image meat5000 ♦ · Jan 29, 2015 at 03:19 PM 0
Share

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.

avatar image marwi · Jan 29, 2015 at 07:43 PM 0
Share

Visual_Lies: I'd appreciate If you'd share your experience with me once you got it running or get stuck or something! :)

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image marwi · Apr 28, 2015 at 03:54 PM 0
Share

Hi Ben, that's great. I'm looking forward to try it as soon as I have some time. Thanks for sharing it :-)

avatar image marwi · Apr 28, 2015 at 11:58 PM 0
Share

ah sorry for that!

avatar image
0

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)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

OpenCV integration 2 Answers

EMGUCV with Unity : System.Windows.Forms.dll assembly is referenced by user code, but is not supported on Android platform. 1 Answer

Open CV (Emgu CV) integration with unity 2018.1 0 Answers

Mono and missing types using external library 2 Answers

Computer Vision integration (OpenCV,EmguCV) 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges