Esempio n. 1
0
        void SetStar(CaptureView capture, RegionView region)
        {
            var xSize = region.VisibleWidth;
            var ySize = region.VisibleHeight;

            var sub = Photometry.GetSubImage(2,
                                             capture.ImageArray,
                                             capture.YSize,
                                             capture.XSize,
                                             region.VisibleY,
                                             region.VisibleX,
                                             region.VisibleY + ySize,
                                             region.VisibleX + xSize);

            var unclipped = Photometry.KappaSigmaClip(sub[0], 1.0, 3);

            var signal  = new ushort[sub[0].Length - unclipped.Count];
            var signals = 0;

            var background  = new ushort[unclipped.Count];
            var backgrounds = 0;

            for (var i = 0; i < sub[0].Length; i++)
            {
                if (unclipped.Contains(i))
                {
                    background[backgrounds++] = sub[0][i];
                }
                else
                {
                    signal[signals++] = sub[0][i];
                }
            }

            var regionMean      = Photometry.FindMean(sub[0]);
            var backgroundSigma = Photometry.FindStandardDeviation(background);
            var backgroundMean  = Photometry.FindMean(background);

            Focus.Star.SetStats(signals, backgrounds, regionMean, backgroundSigma, backgroundMean);

            var snr = regionMean / backgroundSigma;

            var bg = Focus.UsePhdBackgroundFormula ? regionMean + backgroundSigma * 2.0 : regionMean;

            Photometry.Subtract(sub[0], (ushort)bg);

            if (Focus.UseMedianFilter)
            {
                sub[0] = Photometry.MedianBoxFilter(sub[0], xSize, ySize);
            }

            Focus.Region.Capture = new CaptureView
            {
                XSize      = xSize,
                YSize      = ySize,
                ImageArray = sub[0],
                Image      = new Mat(ySize, xSize, MatType.CV_16UC1, sub[0])
            };

            Focus.RegionChanged();

            if (signals < 5)
            {
                Focus.Star.SetStarNotFound();
            }
            else
            {
                var brightestX = 0;
                var brightestY = 0;
                var br         = 0;

                for (var y = 0; y < ySize; y++)
                {
                    for (var x = 0; x < xSize; x++)
                    {
                        var brightest = brightestY * xSize + brightestX;

                        if (sub[0][brightest] < sub[0][y * xSize + x])
                        {
                            brightestX = x;
                            brightestY = y;
                            br         = sub[0][brightest];
                        }
                    }
                }

                var center = Photometry.FindCenterOfMass(sub[0], xSize, ySize);

                ushort peak = 0;

                for (var i = 0; i < sub[0].Length; i++)
                {
                    if (sub[0][i] > peak)
                    {
                        peak = sub[0][i];
                    }
                }

                var weightedCenterX = (center.X / (double)xSize) * 100.0;
                var weightedCenterY = (center.Y / (double)ySize) * 100.0;
                var brightestPixelX = (brightestX / (double)xSize) * 100.0;
                var brightestPixelY = (brightestY / (double)ySize) * 100.0;

                Focus.Star.SetMeasurements(
                    snr,
                    peak,
                    weightedCenterX,
                    weightedCenterY,
                    brightestPixelX,
                    brightestPixelY);

                var samples = new ushort[40];
                var max     = 0.0;

                for (var x = 0; x < 40; x++)
                {
                    samples[x] = sub[0][(int)center.Y * 40 + x];
                    max        = samples[x] > max ? samples[x] : max;
                }

                Focus.SetProfileSamples(samples);
            }
        }
Esempio n. 2
0
    void updateScrollView(DataTable dt)
    {
        foreach (DataRow dr in dt.Rows)
        {
            var item = GameObject.Instantiate(prefab) as RectTransform;
            item.SetParent(transform, false);

            listViewNode node = item.gameObject.GetComponent <listViewNode>();
            node.setOwner(this);

            //詳細情報をノードに設定する

            photoDetailInfo info = new photoDetailInfo();
            info.photoID = int.Parse(dr["id"].ToString());
            node.setDetailInfo(info);


            listViewNodes.Add(node);



            //childImageName.sprite = Resources.Load<Sprite>("Icon");

            //Debug.Log(dr["name"]);

            //お店の名前の取得
            Text childTitleName = item.gameObject.transform.Find("titleText").gameObject.GetComponent <Text>();
            childTitleName.text = dr["name"].ToString(); //jn["titlename"].Get<string>();

            Image ratingStar = item.gameObject.transform.Find("ratingonImage").gameObject.GetComponent <Image>();


            //評価の星を取得
            string rate = dr["myrating"].ToString();

            /*
             * if (float.Parse(rate) == 0)
             * {
             *  rate = dr["rating"].ToString();
             * }
             *
             */

            ratingStar.fillAmount = float.Parse(rate) / 5.0f;


            //自分で評価した内容
            myComment = item.gameObject.transform.Find("descriptionText ").gameObject.GetComponent <Text>();
            string comment = dr["mycomment"].ToString();
            if (comment != "")
            {
                myComment.text = comment;
            }

            //データベースから取得した情報を、各カラムに保存する。
            //画像エリアの取得



            Image childImageName = item.gameObject.transform.Find("Image").gameObject.GetComponent <Image>();

            var imagePath = dr["image_path"];

            if (imagePath != null)
            {
                Debug.Log(dr["image_path"].ToString());

                CaptureView captureView = new CaptureView();
                childImageName.sprite = captureView.GetSprite(dr["image_path"].ToString());
            }
        }

        if (listViewNodes.Count != 0)
        {
            //scrollBar.SetActive(false);
            noDataText.SetActive(false);
        }
        //スクロールビューの頭から表示されるように
        scrollRect = scrollView.GetComponent <ScrollRect>();
        scrollRect.verticalNormalizedPosition = 1;
    }
Esempio n. 3
0
        public void Capture()
        {
            Focus.StartCapturing();

            if (Focus.IsSubFrameActive)
            {
                var frame = Focus.GetSubFrame();

                CameraService.SetRegion(frame.ChipX1, frame.ChipY1, frame.ChipX2 - frame.ChipX1, frame.ChipY2 - frame.ChipY1);
                Camera.SetRegion(frame.ChipX1, frame.ChipY1, frame.ChipX2 - frame.ChipX1, frame.ChipY2 - frame.ChipY1);
            }
            else
            {
                CameraService.SetRegion(0, 0, Camera.BinnedX, Camera.BinnedY);
                Camera.SetRegion(0, 0, Camera.BinnedX, Camera.BinnedY);
            }

            var task = CameraService.Capture(Focus.Exposure);

            task.ContinueWith(x =>
            {
                if (x.Status == TaskStatus.RanToCompletion)
                {
                    var result = x.Result;

                    var capture = new CaptureView
                    {
                        BinnedX = Camera.BinnedX,
                        BinnedY = Camera.BinnedY,
                        ChipX   = Camera.UnbinnedX,
                        ChipY   = Camera.UnbinnedY,
                        XSize   = result.XSize,
                        YSize   = result.YSize
                    };

                    if (Camera.IsSubFrameActive)
                    {
                        capture.Frame = new SubFrame
                        {
                            ChipX1 = Camera.SubFrameX,
                            ChipY1 = Camera.SubFrameY,
                            ChipX2 = Camera.SubFrameX + Camera.SubFrameWidth,
                            ChipY2 = Camera.SubFrameY + Camera.SubFrameHeight
                        };
                    }

                    capture.ImageArray = result.Image;
                    capture.Image      = new Mat(capture.XSize, capture.YSize, MatType.CV_16UC1, result.Image);

                    Focus.SetCapture(capture);

                    Camera.ChangeActualSize(capture.GetWidth(), capture.GetHeight());

                    if (Focus.IsStarSelected)
                    {
                        SelectStar();
                    }

                    Focus.FrameChanged();

                    if (Focus.IsLoopingCapture)
                    {
                        Capture();
                    }
                    else
                    {
                        Focus.StopCapturing();
                    }
                }
                else
                {
                    Focus.StopCapturing();
                }
            });

            task.Start();
        }
    // Use this for initialization
    void Start()
    {
        shopName = GameObject.Find("shopName").GetComponent <Text>();

        // データを条件指定して1件取得
        DataRow drone = DataControl.getOneData("id=" + SceneUtility.photoid.ToString());

        var imagePath = drone["image_path"];

        if (imagePath != null)
        {
            CaptureView captureView = new CaptureView();
            photoPicture.sprite = captureView.GetSprite(drone["image_path"].ToString());
        }


        //店舗名の更新
        var name = drone["name"];

        if (name != null)
        {
            shopName.text = drone["name"].ToString();
        }
        else
        {
            shopName.text = "";
        }

        float myrating = 0;

        if (drone["myrating"] != null)
        {
            myrating = float.Parse(drone["myrating"].ToString());
        }
        string rate = "0";

        //rate = drone["rating"].ToString().ToString();
        //Debug.Log(rate);

        //レビュー表記の更新

        if (myrating != 0  && myrating > 0)
        {
            if (drone["myrating"] != null)
            {
                rate = drone["myrating"].ToString();
            }
        }


        //星の画像を調整するための値を取得
        float tempReviewNum = 0;

        if (rate != "0")
        {
            tempReviewNum = float.Parse(rate) / 5.0f;
        }
        //reviewStars.fillAmount =  tempReviewNum;
        myReviewStars.fillAmount = tempReviewNum;
        //reviewNumber.text = rate;

        //使用者がコメントした内容を表示
        myComment.text = drone["mycomment"].ToString();

        if (myComment.text == "")
        {
            myCommentView.SetActive(false);
        }

        if (drone["phone_number"] != null)
        {
            phoneNumber.text = "電話番号:" + drone["phone_number"].ToString();
        }


        if (drone["address"] != null)
        {
            postCode.text = "所在地:" + drone["address"].ToString();
        }


        string tags = "";

        for (int i = 1; i < 6; i++)
        {
            if (drone[("tag" + i.ToString())] == null || drone[("tag" + i.ToString())].ToString() == "")
            {
                continue;
            }
            string str = (drone[("tag" + i.ToString())].ToString());
            if (str != null)
            {
                Debug.Log(str);
                if (i != 1)
                {
                    str = "," + str;
                }
                tags = tags + str;
            }
            else
            {
            }
        }

        tagView.text = "tag:" + tags;
    }