• 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 danielhernandez_animec · May 27, 2014 at 03:16 PM · emgucv

cannot convert `System.Drawing.Size' expression to type `System.Drawing.Size'?

I'm working with emgu in unity. I'm trying to test CascadeClassifier for face detection. I want to call DetectMultiScale from the CascadeClassifier class, which is defined as:

       /// </summary>
       /// <param name="image">The image where the objects are to be detected from</param>
       /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%</param>
       /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure. Use 3 for default.</param>
       /// <param name="minSize">Minimum window size. Use Size.Empty for default, where it is set to the size of samples the classifier has been trained on (~20x20 for face detection)</param>
       /// <param name="maxSize">Maxumum window size. Use Size.Empty for default, where the parameter will be ignored.</param>
       /// <returns>The objects detected, one array per channel</returns>
       public Rectangle[] DetectMultiScale(IInputArray image, double scaleFactor = 1.1, int minNeighbors = 3, Size minSize = new Size(), Size maxSize = new Size())
       {
          using (Util.VectorOfRect rectangles = new Util.VectorOfRect())
          {
             CvCascadeClassifierDetectMultiScale(_ptr, image.InputArrayPtr, rectangles, scaleFactor, minNeighbors, 0, ref minSize, ref maxSize);
             return rectangles.ToArray();
          }
       }




The call in my code is as:

 Image<Bgr, byte> picture = new Image<Bgr, byte>("lena.jpg");
 
 Image<Gray, byte> img_gray = image.Convert<Gray, byte>();
 
 CascadeClassifier haar = new CascadeClassifier("haarcascade_frontalface_default.xml");
 
 Rectangle[] face = haar.DetectMultiScale( img_gray, 1.1, 10, Size.Empty, Size.Empty);
 

But I'm getting errors:

error CS1502: The best overloaded method match for Emgu.CV.CascadeClassifier.DetectMultiScale(Emgu.CV.IInputArray, double, int, System.Drawing.Size, System.Drawing.Size)' has some invalid arguments > error CS1503: Argument #4' cannot convert System.Drawing.Size' expression to type System.Drawing.Size'

Can anyone help?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · May 27, 2014 at 07:29 PM

Unity doesn't support classes from the System.Drawing namespace.

Possible workaround: http://answers.unity3d.com/questions/53170/using-drawing-package-like-systemdrawing.html

Comment
Add comment · Show 1 · 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 danielhernandez_animec · May 28, 2014 at 11:18 AM 0
Share

Ok. I have already done the workaround in your link, and have done other simple examples with emgu that instructed me to do that to see if it worked and they were ok. But since I didn't have any other ideas I went and recopy System.Drawing.dll from %UnityFolder%\Editor\Data\$$anonymous$$ono\lib\mono\2.0 to my plugins folder and now is working! I not sure were I have gotten the System.Drawing.dll file that was before I copy the one on %UnityFolder%\Editor\Data\$$anonymous$$ono\lib\mono\2.0. Could the problem have been there?? Anyway thanks a lot. I try to vote up your answer but it doesn't let me.

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cloud recognition in Vuforia 0 Answers

Constant force cancellation if not on ground 2 Answers

Blue screen in Unity? 0 Answers

What is RotationAxes.MouseXAndY? 1 Answer

Help - Kinect for windows v2, Gesture recoginition 3 Answers

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