Ejemplo n.º 1
0
 public void pump(ref AdvertDetails _advertDetails)
 {
     Image<Gray, Byte> image;
     if (!_advertDetails.CarFound)
         image = _advertDetails.Image.Convert<Gray, Byte>();
     else
     {
         image = _advertDetails.Image.GetSubRect(_advertDetails.Rect).Convert<Gray, Byte>();
         image.Resize(480, 320, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
     }
     Image<Gray, float> con = image.Laplace(1);
     float sum = calculateBlur(con.ToBitmap());
     _advertDetails.BlurValue = sum / ((image.Width-1) * (image.Height-1)) * 100;
     if (_advertDetails.BlurValue < blurTreshold)
     {
         _advertDetails.Blurry = true;
         _advertDetails.Error += "; image is blury";
     }
     else
     {
         if (_advertDetails.BlurValue < blurTreshold + (blurTreshold * 0.125))
             _advertDetails.blurRating = 1;
         else
             _advertDetails.blurRating = 2;
     }
 }
 /// <summary>
 /// Implements the coverage detector filter and adds the details to the advertDetails object
 /// </summary>
 /// <param name="_advertDetails">The advertDetails object where information about coverage is stored</param>
 public void pump(ref AdvertDetails _advertDetails)
 {
     if(!_advertDetails.CarFound)
         throw new Exception("Cannot calculate coverage if car not found");
     float totalArea = _advertDetails.Image.Width * _advertDetails.Image.Height;
     float area = _advertDetails.Rect.Width * _advertDetails.Rect.Height;
     float coverage = area/totalArea * 100;
     _advertDetails.CoverageValue = coverage;
     _advertDetails.CoverageRating = calculateCoverageRating(coverage);
 }
Ejemplo n.º 3
0
 public void pump(ref AdvertDetails _advertDetails)
 {
     CascadeClassifier cc = new CascadeClassifier(VWclassifier);
     bool carExitst = _advertDetails.CarFound?true:false;
     Image<Gray, byte> image;
     if(carExitst)
         image = _advertDetails.Image.GetSubRect(_advertDetails.Rect).Convert<Gray, byte>();
     else
         image = _advertDetails.Image.Convert<Gray, byte>();
     Rectangle[] logosFound = cc.DetectMultiScale(image, 1.05, 1, new Size(20,20), new Size(40,40));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Implements the car detector filter and adds the details to the advertDetails object
        /// </summary>
        /// <param name="_advertDetails">The advertDetails object where information about the advert is stored</param>
        public virtual void pump(ref AdvertDetails _advertDetails)
        {
            Rectangle rect = new Rectangle();
            String view = "Unknown";

            Image<Gray, Byte> image = _advertDetails.Image.Convert<Gray, byte>();

            CascadeClassifier classifier = new CascadeClassifier(frontClassifier);
            Rectangle[] rectangleList = new Rectangle[0];

            classifier = new CascadeClassifier(sideClassifier);
            Rectangle[] temp = classifier.DetectMultiScale(image, scaleFac, numNeighbours, side_minSize, maxSize);
            if (temp.Length > rectangleList.Length)
            {
                rectangleList = temp;
                view = "Side";
            }

            if(view != "Side")
            {
                 temp = classifier.DetectMultiScale(image, scaleFac, numNeighbours, fb_minSize, maxSize);;
                if(temp.Length > rectangleList.Length)
                {
                    rectangleList = temp;
                    view = "Front";
                }

                classifier = new CascadeClassifier(backClassifier);
                temp = classifier.DetectMultiScale(image, scaleFac, numNeighbours, fb_minSize, maxSize);
                if (temp.Length > rectangleList.Length)
                {
                    rectangleList = temp;
                    view = "Back";
                }
            }

            if (rectangleList.Length > 0)
            {
                rect = getLargest(rectangleList);
                _advertDetails.Rect = rect;
                _advertDetails.CarFound = true;
                _advertDetails.View = view;
                _advertDetails.CarRating = 1;
            }
            else
            {
                _advertDetails.CarFound = false;
                _advertDetails.Error = "No car found.";
            }
        }
 public void pump(ref AdvertDetails _advertDetails)
 {
     if (!_advertDetails.CarFound)
     {
         _advertDetails.Error +=";car not found";
         return;
     }
     Bitmap img = _advertDetails.Image.ToBitmap().Clone(_advertDetails.Rect, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
     int width = img.Width;
     int height = img.Height;
     String[] colours = loopThroughPixels(colourBuckets, width, height, img);
     _advertDetails.Colour1 = colours[0];
     _advertDetails.Colour2 = colours[1];
     _advertDetails.Colour3 = colours[2];
     _advertDetails.Hex1 = colours[3];
     _advertDetails.Hex2 = colours[4];
     _advertDetails.Hex3 = colours[5];
 }
Ejemplo n.º 6
0
        public AdvertDetails GetById(int id)
        {
            if (id == 0)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var adverts  = _advertRepository.GetAll();
            var dbAdvert = adverts.FirstOrDefault(x => !x.IsClosed && x.Id == id);

            if (dbAdvert == null)
            {
                throw new ArgumentException("Partner id is invalid or doesn't exists.");
            }

            var advert = new AdvertDetails()
            {
                AccountId      = dbAdvert.AccountId,
                Tags           = dbAdvert.Tags.Select(c => c.Value).ToList(),
                Reward         = dbAdvert.Reward,
                Text           = dbAdvert.Text,
                CreationDate   = dbAdvert.CreationDate,
                Title          = dbAdvert.Title,
                AccountDetails = new AccountDetails()
                {
                    FirstName   = dbAdvert.Account.FirstName,
                    LastName    = dbAdvert.Account.LastName,
                    PhoneNumber = dbAdvert.Account.AccountPhoneNumbers.Select(x => x.PhoneNumber)
                },
                AdvertAddressDetails = new AdvertAddressDetails()
                {
                    City   = dbAdvert.AdvertAddressDetails.City,
                    Street = dbAdvert.AdvertAddressDetails.Street
                },
                AdvertImages = dbAdvert.AdvertImages.Select(x => new ImageInfo()
                {
                    Name = x.Name,
                    Url  = x.Url
                }).ToList()
            };

            return(advert);
        }
Ejemplo n.º 7
0
 static void Main(string[] args)
 {
     String s;
     while ((s = Console.ReadLine()) != "q")
     {
         Byte[] image = File.ReadAllBytes("pipe/" + s + ".jpg");
         AdvertDetails advertDetails = new AdvertDetails(image);
         Filter[] filters = { new CarDetector("classifiers/frontClassifier.xml", "classifiers/backClassifier.xml", "classifiers/sideClassifier.xml"), new ColourDetector(), new CoverageDetector() };
         List<Filter> filterList = new List<Filter>(filters);
         Pipe pipe = new Pipe(filterList, advertDetails);
         advertDetails = pipe.flow();
         Console.WriteLine(advertDetails.retrieveDetails());
         String input = Console.ReadLine();
         /*BlurDetector bd = new BlurDetector(0.5);
         Image<Gray, Byte> image = new Image<Gray,byte>("EdgeTest/image.jpg");
         ArrayList a = bd.getEdgedPixels(image);
         float f = bd.calculateBlur(image.ToBitmap(), a);
         Console.WriteLine("value: " + f);
         Console.ReadLine(); */
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// The constructor that creates the Pipe object
 /// </summary>
 /// <param name="_filters">A list of all the filters that this pipe must execute in their relevant order</param>
 /// <param name="_advertDetails">The advertDetails object (which initially has no information) which is subsequently filled with information as each filter gets executed</param>
 public Pipe(List<Filter> _filters, AdvertDetails _advertDetails)
 {
     filtersList = _filters;
     advertDetails = _advertDetails;
 }