예제 #1
0
        public override async Task GetCameraStream(DummyQ request, IServerStreamWriter <CameraStreamQ> responseStream, ServerCallContext context)
        {
            Console.WriteLine("Connect host: " + context.Host + " \nmethod: " + context.Method);

            SampleImage sampleImage = new SampleImage(400, 300);

            int count = 0;

            while (true)
            {
                if (count > 100)
                {
                    break;
                }

                byte[] img = new byte[] { (byte)0x88 };
                img = sampleImage.getSample();

                Console.WriteLine(DateTime.Now.ToString(SampleImage.timeformat) + ": response img data size: " + img.Length);

                await responseStream.WriteAsync(new CameraStreamQ()
                {
                    Streams = { new CameraStream()
                                {
                                    Data = Google.Protobuf.ByteString.CopyFrom(img)
                                } }
                });

                count++;
            }
        }
예제 #2
0
 public void OnImageSelected(SampleImage image)
 {
     ImagesNavigationHelper.AddImageId(ImageGalleryViewSelectedIdKey, image.ID);
     _connectedAnimationService.SetListDataItemForNextConnectedAnnimation(image);
     _navigationService.For <ImageGalleryViewDetailViewModel>()
     .WithParam(v => v.ID, image.ID)
     .Navigate();
 }
        public void OnImageSelected(SampleImage image)
        {
            _imagesGridView.PrepareConnectedAnimation(ImageGalleryViewAnimationOpen, image, "galleryImage");

            _navigationService.For <ImageGalleryViewDetailViewModel>()
            .WithParam(v => v.ID, image.ID)
            .Navigate();
        }
        private async void TranslateButtonOnClicked(object sender, EventArgs e)
        {
            await SampleImage.TranslateTo(100, 0, 1000, Easing.CubicInOut);

            await SampleImage.TranslateTo(0, 0, 1000, Easing.CubicInOut);

            await SampleImage.TranslateTo(-100, 0, 1000, Easing.CubicInOut);

            await SampleImage.TranslateTo(0, 0, 1000, Easing.CubicInOut);
        }
        private async void ScaleButtonOnClicked(object sender, EventArgs e)
        {
            if (Device.RuntimePlatform == Device.UWP)
            {
                await DisplayAlert("Error", "Currently this function isn't supported on UWP.", "Ok");

                return;
            }

            await SampleImage.ScaleTo(2, 1000, Easing.BounceOut);

            await SampleImage.ScaleTo(1, 1000, Easing.BounceOut);
        }
예제 #6
0
        /// <summary>
        /// Compares the images into the given result.
        /// </summary>
        private unsafe void CompareData(ComparisonResult result)
        {
            sampleData = null;
            masterData = BitmapUtils.LockBitmapDataRead(MasterImage);
            try
            {
                sampleData = BitmapUtils.LockBitmapDataRead(SampleImage);

                int width = MasterScanLineWidth;
                positions         = PositionDelta.ForWithinDistance(Criteria.MaxPixelDistance);
                maxSquareDistance = (255 * 255 + 255 * 255 + 255 * 255) *
                                    Criteria.MaxColorDistance;
                minSquareDistance = (255 * 255 + 255 * 255 + 255 * 255) *
                                    Criteria.MinColorDistance;

                int errorCount = 0;
                for (int y = 0; y < MasterSize.Height; y++)
                {
                    PixelData *masterPixels = (PixelData *)
                                              ((byte *)masterData.Scan0.ToPointer() + y * width);
                    PixelData *samplePixels = (PixelData *)
                                              ((byte *)sampleData.Scan0.ToPointer() + y * width);
                    for (int x = 0; x < MasterSize.Width; x++)
                    {
                        bool match = PixelsEqual(*masterPixels, *samplePixels);
                        if (!match || minSquareDistance != 0)
                        {
                            result.SetIdentical(false);
                            CheckPixel(x, y, result, ref errorCount);
                            if (errorCount > MaxErrorCount)
                            {
                                result.SetCriteriaMet(false);
                                return;
                            }
                        }
                        masterPixels++;
                        samplePixels++;
                    }
                }
            }
            finally
            {
                MasterImage.UnlockBits(masterData);
                if (sampleData != null)
                {
                    SampleImage.UnlockBits(sampleData);
                }
                masterData = null;
                sampleData = null;
            }
        }
예제 #7
0
        private unsafe void CompareData(ComparisonResult result)
        {
            BitmapData sampleData = null;
            BitmapData masterData = MasterImage.LockBits(MasterRectangle,
                                                         ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);

            try
            {
                sampleData = SampleImage.LockBits(SampleRectangle,
                                                  ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                int        width      = MasterScanLineWidth;
                int        errorCount = 0;
                PixelData *masterPixels;
                PixelData *samplePixels = (PixelData *)sampleData.Scan0;
                for (int y = 0; y < MasterSize.Height; y++)
                {
                    masterPixels = (PixelData *)
                                   ((byte *)masterData.Scan0.ToPointer() + y * width);
                    samplePixels = (PixelData *)
                                   ((byte *)sampleData.Scan0.ToPointer() + y * width);
                    for (int x = 0; x < MasterSize.Width; x++)
                    {
                        bool match = PixelsEqual(*masterPixels, *samplePixels);
                        if (!match)
                        {
                            result.AddDifference(
                                new PixelColorDifference(x, y,
                                                         masterPixels->red, masterPixels->green, masterPixels->blue,
                                                         samplePixels->red, samplePixels->green, samplePixels->blue));
                            result.SetIdentical(false);
                            errorCount++;
                            if (errorCount > MaxErrorCount)
                            {
                                result.SetCriteriaMet(false);
                                return;
                            }
                        }
                        masterPixels++;
                        samplePixels++;
                    }
                }
            }
            finally
            {
                MasterImage.UnlockBits(masterData);
                if (sampleData != null)
                {
                    SampleImage.UnlockBits(sampleData);
                }
            }
        }
        private List <SampleImage> CreateNewImagesByGivenUrls(List <string> imgUrls)
        {
            var imgs = new List <SampleImage>();

            foreach (var url in imgUrls)
            {
                SampleImage newImg = new SampleImage()
                {
                    Url = url
                };

                imgs.Add(newImg);
            }

            return(imgs);
        }
예제 #9
0
        /// <summary>
        /// Calculates sizes and other metrics for the given images. Stores
        /// relevant metrics in the result.
        /// </summary>
        /// <param name="result">Comparison result to set metrics on.</param>
        protected void CalculateMetrics(ComparisonResult result)
        {
            // Calculate sizes.
            GraphicsUnit unit       = GraphicsUnit.Pixel;
            RectangleF   masterRect = MasterImage.GetBounds(ref unit);

            this.masterSize = new Size((int)masterRect.Width, (int)masterRect.Height);
            RectangleF sampleRect = SampleImage.GetBounds(ref unit);

            this.sampleSize      = new Size((int)sampleRect.Width, (int)sampleRect.Height);
            this.masterRectangle =
                new Rectangle(0, 0, MasterSize.Width, MasterSize.Height);
            this.sampleRectangle =
                new Rectangle(0, 0, SampleSize.Width, SampleSize.Height);
            this.maxErrorCount = (int)
                                 (MasterPixelCount * Criteria.MaxErrorProportion);

            // Add relevant metrics to comparison result.
            result.SetMasterImagePixelCount(MasterPixelCount);
            result.SetErrorProportion(Criteria.MaxErrorProportion);
        }
        private async void FadeButtonOnClicked(object sender, EventArgs e)
        {
            await SampleImage.FadeTo(0, 1000, Easing.Linear);

            await SampleImage.FadeTo(1, 1000, Easing.Linear);
        }
        private async void RotateButtonOnClicked(object sender, EventArgs e)
        {
            await SampleImage.RotateTo(180, 1000, Easing.SpringOut);

            await SampleImage.RotateTo(0, 1000, Easing.SpringOut);
        }