简体   繁体   English

来自 c# 代码的 Bitmap 类型在统一 2018 中无法识别

[英]Type Bitmap from a c# code not recognized in unity 2018

I have visual studio 2017 and unity 2018. I'm trying to work with a script of a neural network to be attached to an object in the scene that, in order to be trained, makes use of the bitmap class.我有visual studio 2017和unity 2018。我正在尝试使用要连接到场景中object的神经网络脚本,为了接受训练,使用bitmap ZA2F2ED4F8EBC2CABD4C2。 The problem is that the console of unity gives me the error: 'The type or namespace 'Bitmap' could not be found'.问题是统一的控制台给了我错误:'找不到类型或命名空间'位图'。 Does anyone know how I can do?有谁知道我该怎么做? I'm making use of the directives:我正在使用指令:

using System;

using System.Collections.Generic;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks; 

Here is the script:  

 

     public void Train()
            {
                //Convert to Pixel Array
                Bitmap img = new Bitmap(@"C:\Users\Marc\Desktop\media\resoureces\sites.jpeg");
                double[,,] pixelvalues = new double[3, img.Width, img.Height];
                for (int i = 0; i < img.Width; i++)
                {
                    for (int j = 0; j < img.Height; j++)
                    {
                        Color pixel = img.GetPixel(i, j);
                        pixelvalues[0, i, j] = pixel.R;
                        pixelvalues[1, i, j] = pixel.G;
                        pixelvalues[2, i, j] = pixel.B;
                        //if (pixel == *somecondition *)
                        //{
                        //    **Store pixel here in a array or list or whatever**
                        //}
                    }
                }

Find System.Drawing.dll in your Unity Editor Install Folder.在 Unity 编辑器安装文件夹中找到 System.Drawing.dll。

C:\UnityEditors\2018.4.28f1\Editor\Data\MonoBleedingEdge\lib\mono\gac\System.Drawing\4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll

Move this dll into your Assets/Plugins folder:将此 dll 移动到您的Assets/Plugins文件夹中:
资产插件

Make sure that you uncheck Validate References :确保取消选中Validate References
取消选中ValidateRef

Success:成功:
在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM