Exemplo n.º 1
0
        public void takeTheImage(int binning, string imageType, double duration)
        {
            var d = new imageData
            {
                BINNING = binning, IMAGETYPE = imageType, DURATION = duration
            };
            var t1 = new System.Threading.Thread(t_takeImage);

            t1.Start(d);
        }
Exemplo n.º 2
0
        void HandleAttachment(IAttachment attachment, IGuild guild, ulong id)
        {
            var data = new imageData()
            {
                Attachment = attachment,
                Guild      = guild,
                MessageId  = id
            };

#if THREADED
            var thr = new Thread(downloadAttachmentThread);
            thr.Name = $"dl-{attachment.Filename}";
            thr.Start(data);
#else
            downloadAttachmentThread(data);
#endif
        }
        /// <summary>
        /// First populates the bit array for values then sets up the event listener
        /// </summary>
        /// <param name="p_toInit">The initialization frame</param>
        public void initialize(imageData p_toInit)
        {
            Image toInit = p_toInit.Image;
            Image edges  = ImageProcess.findEdges(toInit);

            //Convert if edges size doesn't match given image size
            if (edges.PixelFormat != toInit.PixelFormat)
            {
                convert2PixelFormat(ref toInit);
                p_toInit.Image = toInit;
            }

            m_isInitialized = false;
            populateValidPixels(toInit, edges);
            setupFilter();
            m_center        = new Point(toInit.Width / 2, toInit.Height / 2);
            m_isInitialized = true;

            setupListener();
            doWork(p_toInit);
        }
Exemplo n.º 4
0
        private void t_takeImage(object o)
        {
            imageData d = (imageData)o;

            switch (d.IMAGETYPE)
            {
            case "Light":
            case "Bias":
            case "Flat":
                isLightFrame = true;
                break;

            case "Dark":
                isLightFrame = false;
                break;
            }

            StartExposure(d.DURATION, isLightFrame);
            writetolog("Taking exposure\r\n", true);
            ExposureTimer.Enabled = true;
        }
Exemplo n.º 5
0
 public ActionResult UploadFile(HttpPostedFileBase file, imageData iData)
 {
     try
     {
         if (file.ContentLength > 0)
         {
             string _FileName = Path.GetFileName(file.FileName);
             string _path     = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
             file.SaveAs(_path);
             iData.Title    = _FileName;
             iData.ImageUrl = "/UploadedFiles/" + _FileName;
             db.ImageDetails.Add(iData);
             db.SaveChanges();
         }
         ViewBag.Message = "File Uploaded Successfully!!";
         return(View());
     }
     catch
     {
         ViewBag.Message = "File upload failed!!";
         return(View());
     }
 }
Exemplo n.º 6
0
        public IHttpActionResult PostsaveImgToDb(string id, imageData image)
        {
            byte[] img = Convert.FromBase64String(image.imageBase64);

            var data = db.tblBiddersInfoes.Where(user => user.BiddersId == id).SingleOrDefault();

            if (image.type == 0)
            {
                data.UserImg = img;
            }
            else if (image.type == 1)
            {
                data.CardImgFront = img;
            }
            else if (image.type == 2)
            {
                data.CardImgBack = img;
            }

            db.SaveChanges();

            return(Json(img));
        }
        /// <summary>
        /// Uses inner to outer search to find a strong feature then
        /// scans from outside to in of a more reduced area to find a more accurate center
        /// </summary>
        /// <param name="p_imageData">Image data</param>
        /// <param name="p_data">bitmap data</param>
        /// <param name="p_buffer">used for testing</param>
        private void findHand(imageData p_imageData, BitmapData p_data, byte[] p_buffer)
        {
            Point handCenter = m_center;

            int[] xProjection = new int[p_data.Width];
            int[] yProjection = new int[p_data.Height];
            int[] xSmoothed   = new int[p_data.Width];
            int[] ySmoothed   = new int[p_data.Height];

            int xMax, yMax;

            xMax = yMax = 0;

            //Popluate histogram for x and y intesities
            foreach (Point point in p_imageData.Datapoints)
            {
                ++xProjection[point.X];
                ++yProjection[point.Y];

                //Because each point in the histogram is only increasing by one i can get away with this
                if (xProjection[point.X] > xMax)
                {
                    ++xMax;
                }
                if (yProjection[point.Y] > yMax)
                {
                    ++yMax;
                }
            }

            #region Smoothing
            smoothing(ref xProjection, ref xSmoothed);
            smoothing(ref yProjection, ref ySmoothed);
            #endregion

            #region find bounds around the previous center
            // work from the center out.  This will help ignore outside noise.
            //The bounds represent strong points in the histogram
            int xLeftBound, xRightBound;
            xLeftBound = xRightBound = handCenter.X;
            int yTopBound, yBottomBound;
            yTopBound = yBottomBound = handCenter.Y;

            Parallel.Invoke(
                () =>
            {
                findBound(ref yTopBound, ySmoothed, -1, m_filterArea.Width / 8, true);
            },
                () =>
            {
                findBound(ref yBottomBound, ySmoothed, 1, m_filterArea.Width / 8, true);
            },
                () =>
            {
                findBound(ref xLeftBound, xSmoothed, -1, m_filterArea.Height / 8, true);
            },
                () =>
            {
                findBound(ref xRightBound, xSmoothed, 1, m_filterArea.Height / 8, true);
            });
            #endregion

            #region Second pass
            Point closest = new Point();

            //Save the center from first pass as this will be the start of the second
            closest.X = (xLeftBound + xRightBound) / 2;
            closest.Y = (yTopBound + yBottomBound) / 2;

            //Rectangles X and Y are based on the top right so adjustment is necesary
            m_filterArea.X = closest.X - m_filterArea.Width / 2;
            m_filterArea.Y = closest.Y - m_filterArea.Height / 2;

            //Create a smaller window
            xProjection = new int[m_filterArea.Width];
            yProjection = new int[m_filterArea.Height];
            xSmoothed   = new int[m_filterArea.Width];
            ySmoothed   = new int[m_filterArea.Height];

            List <Point> pointsInFilter = new List <Point>();

            //Populate it with only data points that are within the rectangle
            foreach (Point point in p_imageData.Datapoints)
            {
                if (m_filterArea.Contains(point))
                {
                    ++xProjection[point.X - m_filterArea.X];
                    ++yProjection[point.Y - m_filterArea.Y];
                    pointsInFilter.Add(point);
                }
            }

            p_imageData.Datapoints = pointsInFilter;

            //Smooth it out before the finding the center
            smoothing(ref xProjection, ref xSmoothed);
            smoothing(ref yProjection, ref ySmoothed);
            #endregion

            #region find bounds around the first center
            //This second pass will work over a reduced area so I work from the outside
            // of the rectangle in , not worrying about noise
            xLeftBound   = xRightBound = closest.X - m_filterArea.X;
            yTopBound    = xLeftBound = 1;
            yBottomBound = m_filterArea.Height - 2;
            xRightBound  = m_filterArea.Width - 2;

            Parallel.Invoke(
                () =>
            {
                findBound(ref yTopBound, ySmoothed, 1, m_filterArea.Width / 8, false);
            },
                () =>
            {
                findBound(ref yBottomBound, ySmoothed, -1, m_filterArea.Width / 8, false);
            },
                () =>
            {
                findBound(ref xLeftBound, xSmoothed, 1, m_filterArea.Height / 8, false);
            },
                () =>
            {
                findBound(ref xRightBound, xSmoothed, -1, m_filterArea.Height / 8, false);
            });
            #endregion
            closest.X = ((xLeftBound + xRightBound) / 2) + m_filterArea.X;
            closest.Y = ((yTopBound + yBottomBound) / 2) + m_filterArea.Y;

            //Update center and filter
            m_center = new Point(closest.X, closest.Y);

            m_filterArea.X = m_center.X - m_filterArea.Width / 2;
            m_filterArea.Y = m_center.Y - m_filterArea.Height / 2;
        }
Exemplo n.º 8
0
        public ActionResult MultipleUpload(IEnumerable <HttpPostedFileBase> attachments, imageData iData)
        {
            try
            {
                foreach (var file in attachments)
                {
                    if (file.ContentLength > 0)
                    {
                        string _FileName = Path.GetFileName(file.FileName);
                        string _path     = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
                        file.SaveAs(_path);
                        iData.Title    = _FileName;
                        iData.ImageUrl = "/UploadedFiles/" + _FileName;
                        db.ImageDetails.Add(iData);
                        db.SaveChanges();
                    }
                }

                ViewBag.Message = "Files Uploaded Successfully!!";
                return(View());
            }
            catch {
                ViewBag.Message = "File upload failed!!";
                return(View());
            }



            return(View());
        }