Ejemplo n.º 1
0
 private void NewTargetFound(YoloItem tmp)
 {
     TargetMutex.WaitOne();
     targetDetected = tmp;
     bTargetUpdated = true;
     TargetMutex.ReleaseMutex();
 }
Ejemplo n.º 2
0
 private void StartMouseMoveThread()
 {
     new Thread(() =>
     {
         Thread.CurrentThread.IsBackground = true;
         while (true)
         {
             Thread.Sleep(Math.Max(nextSleep, 2));
             if (bTargetUpdated)
             {
                 TargetMutex.WaitOne();
                 bTargetUpdated = false;
                 targetRendered = targetDetected;
                 TargetMutex.ReleaseMutex();
             }
             if (!IsAiming())
             {
                 continue;
             }
             if (targetRendered == null)
             {
                 continue;
             }
             var(curDx, curDy)   = GetAimPoint(targetRendered);
             var(xDelta, yDelta) = ApplyExperimentalSmooth(curDx, curDy);
             MoveMouse(xDelta, yDelta);
             targetRendered.X -= xDelta / GameSenseBase;
             targetRendered.Y -= yDelta / GameSenseBase;
         }
     }).Start();
 }
Ejemplo n.º 3
0
        private IEnumerable <YoloItem> Convert(BboxContainer container)
        {
            var yoloItems = new List <YoloItem>();

            foreach (var item in container.candidates.Where(o => o.h > 0 || o.w > 0))
            {
                if (!this._objectType.TryGetValue((int)item.obj_id, out var objectType))
                {
                    objectType = "unknown key";
                }

                var yoloItem = new YoloItem
                {
                    X          = (int)item.x,
                    Y          = (int)item.y,
                    Height     = (int)item.h,
                    Width      = (int)item.w,
                    Confidence = item.prob,
                    Type       = objectType
                };

                yoloItems.Add(yoloItem);
            }

            return(yoloItems);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws the connection line between two items and also the lenght
        /// </summary>
        /// <param name="uiImage"></param>
        /// <param name="item"></param>
        /// <param name="item2"></param>
        public void DrawLineFromItemToItem(Mat uiImage, YoloItem item, YoloItem item2, out Line line)
        {
            var startPoint = new OpenCvSharp.Point(item.Center().X *SCALE, item.Center().Y *SCALE);
            var endPoint   = new OpenCvSharp.Point(item2.Center().X *SCALE, item2.Center().Y *SCALE);

            line = new Line()
            {
                X1 = item.Center().X *SCALE,
                Y1 = item.Center().Y *SCALE,
                X2 = item2.Center().X *SCALE,
                Y2 = item2.Center().Y *SCALE
            };

            // Draw the line
            Cv2.Line(uiImage,
                     startPoint,
                     endPoint,
                     Scalar.Red, 2);

            // Draw distance and length
            // Casting from points to points is really annoying... TODO: Refactor that.
            var sysStartPoint = new System.Windows.Point(startPoint.X, startPoint.Y);
            var sysEndPoint   = new System.Windows.Point(endPoint.X, endPoint.Y);
            var distance      = GeometryHelper.Distance(sysStartPoint, sysEndPoint);
            var length        = distance * coordinateLength;
            var centerOfLine  = GeometryHelper.GetCenterOfLine(sysStartPoint, sysEndPoint);

            // Put text in it.
            DrawTextblockWithBackground(
                uiImage,
                centerOfLine,
                $"{string.Format("{0:0.00}", length)}m",
                Scalar.Red
                );
        }
Ejemplo n.º 5
0
        public void AddExpression(string name)
        {
            YoloItem item = new YoloItem(YoloItemType.Extension);

            item.Name = name;
            Expressions.Add(item);
        }
Ejemplo n.º 6
0
        private (float curDx, float curDy) GetAimPoint(YoloItem enemy)
        {
            if (enemy == null)
            {
                return(0, 0);
            }
            var nearestEnemyHead = Util.GetEnemyHead(enemy);
            var nearestEnemyBody = Util.GetEnemyBody(enemy);

            if (nearestEnemyHead.Height > Settings.MinHeadSize) // aim to neck
            {
                var curDx = nearestEnemyHead.Left + nearestEnemyHead.Width / 2f - s.SizeX / 2f;
                var curDy = nearestEnemyHead.Top + nearestEnemyHead.Height - s.SizeY / 2f;
                //IfInsideZone1SlowlyMoveToZone2(ref curDx, ref curDy, nearestEnemyBody, nearestEnemyHead);
                DontMoveInZone(nearestEnemyHead, ref curDx, ref curDy);
                return(curDx, curDy);
            }
            else // aim to middle body
            {
                var curDx = nearestEnemyBody.Left + nearestEnemyBody.Width / 2f - s.SizeX / 2f;
                var curDy = nearestEnemyBody.Top + nearestEnemyBody.Height / 2f - s.SizeY / 2f;
                //IfInsideZone1SlowlyMoveToZone2(ref curDx, ref curDy, nearestEnemyBody, nearestEnemyHead);
                DontMoveInZone(nearestEnemyBody, ref curDx, ref curDy);
                return(curDx, curDy);
            }
        }
Ejemplo n.º 7
0
        private Bitmap DrawBorder2Image(Bitmap bmp, List <YoloItem> items, YoloItem selectedItem = null)
        {
            //Load the image(probably from your stream)
            Image <Bgr, Byte> im = null;

            using (var canvas = Graphics.FromImage(bmp))
            {
                // Modify the image using g here...
                // Create a brush with an alpha value and use the g.FillRectangle function
                foreach (var item in items)
                {
                    var x      = item.X;
                    var y      = item.Y;
                    var width  = item.Width;
                    var height = item.Height;

                    using (var overlayBrush = new SolidBrush(Color.FromArgb(150, 255, 255, 102)))
                        using (var pen = this.GetBrush(item.Confidence, bmp.Width))
                        {
                            //if (item.Equals(selectedItem))
                            //{
                            //    canvas.FillRectangle(overlayBrush, x, y, width, height);
                            //}

                            canvas.DrawRectangle(pen, x, y, width, height);
                            canvas.Flush();
                        }
                }
                // im = new Image<Bgr, Byte>(bmp);
            }

            return(bmp);
        }
Ejemplo n.º 8
0
        unsafe private void ReceiverServerWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            /*Questa parte è da pulire creando un metodo nella classe di deserializzazione oppure nel puntamento*/
            packetHeader = deserializer.getPacketHeader(e.UserState as byte[]);
#if (_DEBUG)
            /*Display Frame header #BEG*/
            ServerText.Text = "Frame Counter  = " + packetHeader.counter + "\n" +
                              "Frame Tick     = " + packetHeader.frameTick + "\n" +
                              "Size of buffer = " + packetHeader.sizeofBuffer + "\n" +
                              "Size of header = " + packetHeader.sizeofHeader + "\n";
            /*Display Frame header #END*/
#endif
            byte[] var     = new byte[153600];
            int    counter = 153600;
            int    offset  = sizeof(streamerPacketHeader) + 66;
            counter = (e.UserState as byte[]).Length < 153600 ? (e.UserState as byte[]).Length : 153600;
            if ((counter + offset) > (e.UserState as byte[]).Length || ((e.UserState as byte[]).Length != 154202))   //quick and dirty, dimensione del pacchetto corretto al momento, da verificare di cosa si tratti
            {
                return;
            }
            try
            {
                for (int i = 0; i < counter; i++)
                {
                    var[i] = (e.UserState as byte[])[i + offset];
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
            ImageHolder.Source = null;
            Bitmap bmp = deserializer.CreateBitmap(320, 240, var, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
            using (MemoryStream ms = new MemoryStream())
            {
#if (_MEMORY_STREAM)
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                YoloItem tmp = pointer.AnalyzeStream(ms);
#else
                bmp.Save("C:\\temp\\stream.png", System.Drawing.Imaging.ImageFormat.Png);
                YoloItem tmp = pointer.AnalyzePng("C:\\temp\\stream.png");
#endif
                detectionObject obj;
                if (tmp != null)
                {
                    obj.nnItem       = tmp;
                    obj.originHeader = packetHeader;
                    obj.originHeader.targetInFrame   = true;
                    obj.originHeader.targetConfident = Convert.ToUInt16(tmp.Confidence * 10);
                    frameArrayHandler.AddElement(obj);
                    ServerText.Text += "Object found = " + tmp.Type.ToString() + "\n" +
                                       "Position X/Y = " + tmp.X + "/" + tmp.Y + "\n";
                }
            }
#if (_DEBUG)
            ImageHolder.Source = deserializer.ConvertBitmapToSource(bmp);
#endif
        }
Ejemplo n.º 9
0
 public YoloItem[][] GetRecognitionData()
 {
     byte[][]     frames = GetFrames();
     YoloItem[][] result = new YoloItem[frames.Length][];
     for (int i = 0; i < frames.Length; i++)
     {
         result[i] = Global.Detect(frames[i]);
     }
     return(result);
 }
Ejemplo n.º 10
0
        public static Rectangle GetEnemyHead(YoloItem nearestEnemy)
        {
            var nearestEnemyHead = Rectangle.Create(
                (float)nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width * (1f - Settings.HeadWidth) / 2f),
                y: Convert.ToInt32(nearestEnemy.Y),
                Convert.ToInt32(Settings.HeadWidth * nearestEnemy.Width),
                Convert.ToInt32(Settings.HeadHeight * nearestEnemy.Height));

            return(nearestEnemyHead);
        }
Ejemplo n.º 11
0
        public static Rectangle GetEnemyBody(YoloItem nearestEnemy)
        {
            var nearestEnemyBody = Rectangle.Create(
                (float)nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width * (1f - Settings.BodyWidth) / 2f),
                (float)nearestEnemy.Y + Convert.ToInt32(nearestEnemy.Height * (1f - Settings.BodyHeight) / 2f),
                Convert.ToInt32(Settings.BodyWidth * nearestEnemy.Width),
                Convert.ToInt32(Settings.BodyHeight * nearestEnemy.Height));

            return(nearestEnemyBody);
        }
Ejemplo n.º 12
0
        private void DrawItem(YoloItem enemy)
        {
            var head = Util.GetEnemyHead(enemy);
            var body = Util.GetEnemyBody(enemy);

            mainWnd.graphics.DrawRectangle(mainWnd.graphics.redBrush, body, 2);
            if (head.Height >= Settings.MinHeadSize)
            {
                mainWnd.graphics.DrawRectangle(mainWnd.graphics.redBrush, head, 2);
            }
        }
Ejemplo n.º 13
0
        //find all match based on distance
        private List <YoloItem> FindAllMatch(IEnumerable <YoloItem> items, int maxDistance, Dictionary <string, int> cat)
        {
            List <YoloItem> yItems        = new List <YoloItem>();
            var             distanceItems = items.Select(o => new { Cat = o.Type, Distance = this.Distance(o.Center(), this._trackingObject), Item = o }).Where(o => (cat.ContainsKey(o.Cat) && o.Distance <= maxDistance)).OrderBy(o => o.Distance);

            foreach (var item in distanceItems)
            {
                YoloItem yItem = item.Item;
                yItems.Add(yItem);
            }
            return(yItems);
        }
Ejemplo n.º 14
0
        public YoloTrackingItem(YoloItem yoloItem, int index, byte[] imageData)
        {
            this.X          = yoloItem.X;
            this.Y          = yoloItem.Y;
            this.Width      = yoloItem.Width;
            this.Height     = yoloItem.Height;
            this.Type       = yoloItem.Type;
            this.Confidence = yoloItem.Confidence;

            this.Index           = index;
            this.TaggedImageData = imageData;
        }
        //find all match based on distance
        private List <YoloItem> FindAllMatch(IEnumerable <YoloItem> items, int maxDistance, HashSet <string> category)
        {
            List <YoloItem> yItems        = new List <YoloItem>();
            var             distanceItems = items.Select(o => new { Category = o.Type, Distance = this.Distance(o.Center(), this._trackingObject), Item = o }).Where(o => (category.Count == 0 || category.Contains(o.Category)) && o.Distance <= maxDistance).OrderBy(o => o.Distance);

            foreach (var item in distanceItems)
            {
                YoloItem yItem = item.Item;
                yItems.Add(yItem);
            }
            return(yItems);
        }
Ejemplo n.º 16
0
        private void LogMsg(YoloItem item, VideoRecognitionResult result)
        {
            var msg = new StringBuilder();

            msg.AppendLine("Номер кадра: " + result.IndexFrame);
            msg.AppendLine("Координата центра X: " + item.X);
            msg.AppendLine("Координата центра Y: " + item.Y);
            msg.AppendLine("Ширина: " + item.Width);
            msg.AppendLine("Высота: " + item.Height);
            Logger.WriteLine(msg.ToString());
            _logTxtBx.AppendText(Logger.Messages.Last() + "\r\n");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Gets the center point of the yolo items rectangle object
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static OpenCvSharp.Point Center(this YoloItem item)
        {
            var drawnRectangle = new Rectangle()
            {
                X      = item.X,
                Y      = item.Y,
                Width  = item.Width,
                Height = item.Height
            };

            var center = GeometryHelper.GetCenterOfRectangle(drawnRectangle);

            return(new OpenCvSharp.Point(center.X, center.Y));
        }
Ejemplo n.º 18
0
        private void DrawLabel(Bitmap frame, YoloItem item)
        {
            using (Graphics g = Graphics.FromImage(frame))
            {
                string name       = item.Type;
                Font   fnt        = new Font("Verdana", 50, GraphicsUnit.Pixel);
                Brush  brs        = new SolidBrush(Color.DarkOrange);
                var    stringSize = g.MeasureString(name, fnt);
                g.DrawRectangle(new Pen(Color.CornflowerBlue, 3), item.X, item.Y, item.Width, item.Height);


                g.DrawString(name, fnt, brs, item.X, item.Y + 10);
            }
        }
Ejemplo n.º 19
0
        private void DrawImage(List <YoloItem> items, MemoryStream ms, YoloItem selectedItem = null)
        {
            Image image = Image.FromStream(ms);

            using (var canvas = Graphics.FromImage(image))
            {
                // Modify the image using g here...
                // Create a brush with an alpha value and use the g.FillRectangle function
                foreach (var item in items.Where(x => x.Confidence > 0.5))
                {
                    var x      = item.X;
                    var y      = item.Y;
                    var width  = item.Width;
                    var height = item.Height;

                    Console.WriteLine("Drawing:" + item.Type);
                    using (var overlayBrush = new SolidBrush(Color.FromArgb(150, 255, 255, 102)))
                        using (var pen = this.GetBrush(item.Confidence, image.Width))
                        {
                            if (item.Equals(selectedItem))
                            {
                                canvas.FillRectangle(overlayBrush, x, y, width, height);
                            }

                            canvas.DrawRectangle(pen, x, y, width, height);

                            Font         drawFont   = new Font("Arial", 24);
                            SolidBrush   drawBrush  = new SolidBrush(Color.Red);
                            StringFormat drawFormat = new StringFormat();
                            canvas.DrawString(item.Type, drawFont, drawBrush, x - 10, y - 45, drawFormat);
                            canvas.Flush();
                        }
                }
            }

            var oldImage = this._pictureBox1.Image;

            if (_pictureBox1.InvokeRequired)
            {
                _pictureBox1.BeginInvoke(new MethodInvoker(() => { this._pictureBox1.Image = image; }));
            }
            else
            {
                this._pictureBox1.Image = image;
            }

            oldImage?.Dispose();
            ev.Set();
        }
        public YoloItem GetYoloItem()
        {
            YoloItem item = new YoloItem();

            item.X          = this.X;
            item.Y          = this.Y;
            item.Width      = this.Width;
            item.Height     = this.Height;
            item.Type       = this.Type;
            item.Confidence = this.Confidence;
            item.ObjId      = this.ObjId;
            item.TrackId    = this.TrackId;

            return(item);
        }
        public YoloTrackingItem(YoloItem yoloItem, int index, byte[] taggedImageData, byte[] croppedImageData)
        {
            this.X          = yoloItem.X;
            this.Y          = yoloItem.Y;
            this.Width      = yoloItem.Width;
            this.Height     = yoloItem.Height;
            this.Type       = yoloItem.Type;
            this.Confidence = yoloItem.Confidence;
            this.ObjId      = yoloItem.ObjId;
            this.TrackId    = yoloItem.TrackId;

            this.Index            = index;
            this.TaggedImageData  = taggedImageData;
            this.CroppedImageData = croppedImageData;
        }
Ejemplo n.º 22
0
        private IEnumerable <YoloItem> Convert(BboxContainer container)
        {
            var yoloItems = new List <YoloItem>();

            foreach (var item in container.candidates.Where(o => o.h > 0 || o.w > 0))
            {
                var objectType = this._objectType[(int)item.obj_id];
                var yoloItem   = new YoloItem()
                {
                    X = (int)item.x, Y = (int)item.y, Height = (int)item.h, Width = (int)item.w, Confidence = item.prob, Type = objectType
                };
                yoloItems.Add(yoloItem);
            }

            return(yoloItems);
        }
Ejemplo n.º 23
0
        private byte[] CropImage(byte[] imageData, YoloItem item)
        {
            using (var memoryStream = new MemoryStream(imageData))
                using (var image = Image.FromStream(memoryStream))
                {
                    Rectangle cropRect     = new Rectangle(item.X, item.Y, Math.Min(image.Width - item.X, item.Width), Math.Min(image.Height - item.Y, item.Height));
                    Bitmap    bmpImage     = new Bitmap(image);
                    Image     croppedImage = bmpImage.Clone(cropRect, bmpImage.PixelFormat);

                    using (var memoryStream2 = new MemoryStream())
                    {
                        croppedImage.Save(memoryStream2, ImageFormat.Bmp);
                        return(memoryStream2.ToArray());
                    }
                }
        }
Ejemplo n.º 24
0
        private byte[] DrawImage(byte[] imageData, YoloItem item, Brush color)
        {
            using (var memoryStream = new MemoryStream(imageData))
                using (var image = Image.FromStream(memoryStream))
                    using (var canvas = Graphics.FromImage(image))
                        using (var pen = new Pen(color, 3))
                        {
                            canvas.DrawRectangle(pen, item.X, item.Y, item.Width, item.Height);
                            canvas.Flush();

                            using (var memoryStream2 = new MemoryStream())
                            {
                                image.Save(memoryStream2, ImageFormat.Bmp);
                                return(memoryStream2.ToArray());
                            }
                        }
        }
Ejemplo n.º 25
0
 public void DrawPlaying(YoloItem enemy, bool isAiming)
 {
     mainWnd.window.X = 1920 / 2 - s.SizeX / 2;
     mainWnd.window.Y = 1080 / 2 - s.SizeY / 2;
     mainWnd.graphics.BeginScene();
     mainWnd.graphics.ClearScene();
     // draw area
     //mainWnd.graphics.DrawRectangle(mainWnd.graphics.blueBrush, 0, 0, s.SizeX, s.SizeY, 2);
     // draw crossfire
     mainWnd.graphics.FillRectangle(isAiming ? mainWnd.graphics.redBrush : mainWnd.graphics.blueBrush,
                                    Rectangle.Create(s.SizeX / 2 - 2, s.SizeY / 2 - 2, 4, 4));
     //mainWnd.graphics.WriteText(
     //    $"FPS {mainWnd.graphics.FPS}");
     // draw targets
     DrawItem(enemy);
     mainWnd.graphics.EndScene();
 }
Ejemplo n.º 26
0
        private double GetSizeDifferencePercentage(YoloTrackingItemExtended item1, YoloItem item2)
        {
            var area1 = item1.Width * item1.Height;
            var area2 = item2.Width * item2.Height;

            if (area1 == area2)
            {
                return(0);
            }

            if (area1 > area2)
            {
                var change1 = 100.0 * area2 / area1;
                return(100 - change1);
            }

            var change = 100.0 * area1 / area2;

            return(100 - change);
        }
Ejemplo n.º 27
0
        private void DrawBoundingBoxes(List <YoloItem> items, YoloItem selectedItem = null)
        {
            var imageInfo = GetCurrentImage();
            //Load the image(probably from your stream)
            var image = Image.FromFile(imageInfo.Path);

            using (var canvas = Graphics.FromImage(image))
            {
                foreach (var item in items)
                {
                    var x      = item.X;
                    var y      = item.Y;
                    var width  = item.Width;
                    var height = item.Height;

                    var brush   = GetBrush(item.Confidence);
                    var penSize = image.Width / 100.0f;

                    using (var pen = new Pen(brush, penSize))
                        using (var overlayBrush = new SolidBrush(Color.FromArgb(150, 255, 255, 102)))
                        {
                            if (item.Equals(selectedItem))
                            {
                                canvas.FillRectangle(overlayBrush, x, y, width, height);
                            }

                            canvas.DrawRectangle(pen, x, y, width, height);
                        }
                }

                canvas.Flush();
            }

            var oldImage = pictureBox1.Image;

            pictureBox1.Image = image;
            oldImage?.Dispose();
        }
Ejemplo n.º 28
0
        public static string Detect()
        {
            if (_yoloWrapper == null)
            {
                return("wrapper error");
            }

            var    memoryTransfer = true;
            string p = path + "\\yoloData\\test.jpg";

            var imageData = File.ReadAllBytes(p);

            var sw = new Stopwatch();

            sw.Start();
            List <YoloItem> items;

            if (memoryTransfer)
            {
                items = _yoloWrapper.Detect(imageData).ToList();
            }
            else
            {
                items = _yoloWrapper.Detect(p).ToList();
            }
            sw.Stop();

            string s = "";

            for (int i = 0; i < items.Count; i++)
            {
                YoloItem item = items.ElementAt(i);
                s += item.Type + " - " + item.Width + " : " + item.Height + "<br><br>";
            }

            return(s);
        }
Ejemplo n.º 29
0
        private void DrawBorder2Image(List <YoloItem> items, YoloItem selectedItem = null)
        {
            var imageInfo = this.GetCurrentImage();
            //Load the image(probably from your stream)
            var image = Image.FromFile(imageInfo.Path);

            using (var canvas = Graphics.FromImage(image))
            {
                // Modify the image using g here...
                // Create a brush with an alpha value and use the g.FillRectangle function
                foreach (var item in items)
                {
                    var x      = item.X;
                    var y      = item.Y;
                    var width  = item.Width;
                    var height = item.Height;

                    using (var overlayBrush = new SolidBrush(Color.FromArgb(150, 255, 255, 102)))
                        using (var pen = this.GetBrush(item.Confidence, image.Width))
                        {
                            if (item.Equals(selectedItem))
                            {
                                canvas.FillRectangle(overlayBrush, x, y, width, height);
                            }

                            canvas.DrawRectangle(pen, x, y, width, height);
                            canvas.Flush();
                        }
                }
            }

            var oldImage = this.pictureBox1.Image;

            this.pictureBox1.Image = image;
            oldImage?.Dispose();
        }
Ejemplo n.º 30
0
            public static INewCEPExpression MakeExt(YoloItem item, out string compileErrors)
            {
                string emptystr = " ";

                if (item.Usings == null)
                {
                    item.Usings = emptystr;
                }
                if (item.References == null)
                {
                    item.References = emptystr;
                }
                string code = Resources.ExtensionTemplate;

                code = code.Replace("@@USINGS@@", item.Usings);
                code = code.Replace("@@EXTCLASS@@", item.Code);

                //string code = File.ReadAllText(TEMPLATE_PATH).Replace(REPLACE_TOKEN, lambda);

                var provider = new CSharpCodeProvider(
                    new Dictionary <String, String> {
                    { "CompilerVersion", "v4.0" }
                });
                ICodeCompiler compiler = provider.CreateCompiler();

                var compilerparams = new CompilerParameters();

                compilerparams.GenerateExecutable = false;
                compilerparams.GenerateInMemory   = true;

                IEnumerable <string> referencedAssemblies = typeof(YoloWrapper).Assembly.GetReferencedAssemblies().Select(a => a.Name);

                foreach (string referencedAssembly in referencedAssemblies)
                {
                    string name = referencedAssembly + ".dll";
                    if (name != "WindowsBase.dll")
                    {
                        compilerparams.ReferencedAssemblies.Add(name);
                    }
                }

                //compilerparams.ReferencedAssemblies.Add(typeof(YoloWrapper).Assembly.GetName().Name + ".exe");

                foreach (string f in Directory.GetFiles(Environment.CurrentDirectory, "*.dll"))
                {
                    compilerparams.ReferencedAssemblies.Add(f);
                }
                string          allcode = code;
                CompilerResults results = RuntimeCodeCompiler.CompileCode(code);

                if (results.Errors.HasErrors)
                {
                    var errors = new StringBuilder("Compiler Errors :\r\n");
                    foreach (CompilerError error in results.Errors)
                    {
                        errors.AppendFormat("Line {0},{1}\t: {2}\n",
                                            error.Line, error.Column, error.ErrorText);
                    }
                    Console.Write("-");
                    compileErrors = errors.ToString();
                    throw new Exception(errors.ToString());
                }
                else
                {
                    CompiledExtensionFunctions += "\n " + code;
                }

                //Assembly assm = results.CompiledAssembly;
                //INewCEPExpression expr2 = Yolo.Express();
                //foreach (Type t in assm.DefinedTypes)
                //{
                //    object wrapper = Activator.CreateInstance(t);
                //    expr2 = (INewCEPExpression)t.InvokeMember("Generate", BindingFlags.InvokeMethod, null, wrapper, null);
                //}

                //if (item.ItemType == YoloItemType.Component)
                //{
                //    Yolo.Manager.Register(expr2 as INewComponent, item.Name, 0);
                //}
                //if (item.ItemType == YoloItemType.Extension)
                //{
                //    Yolo.Expressions.AddExpression(item.Name);
                //}
                compileErrors = "";
                //return expr2;

                return(null);
            }