private async void GalleryButton_Tapped(object sender, EventArgs e)
        {
            var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Photos);

            if (results == null || results[PermissionType.Photos] != PermissionStatus.Granted)
            {
                return;
            }

            cleanup = false;
            try
            {
                Stream stream = await DependencyService.Get <IPicturePicker>().GetImageStreamAsync();

                if (stream != null)
                {
                    if (CurrentOperation == CameraOperationType.Normal)
                    {
                        CreateUpdateBusinessCardPage(null, stream);
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            HomePage.Instance.PopCameraPage();
                            PictureTaken?.Invoke(this, new PictureTakenEventArgs(null, stream, CurrentOperation));
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private void LeadCamera_PictureReceived(Leadtools.Camera.Xamarin.FrameHandlerEventArgs e)
        {
            if (_enableAutoCapture)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    autoCaptureLabel.AbortAnimation("FadeInOut");
                    autoCaptureLabel.Opacity = 1;
                    autoCaptureLabel.Text    = "Business Card Detected";
                });
            }

            if (CurrentOperation == CameraOperationType.Normal)
            {
                if (e.Image != null)
                {
                    CreateUpdateBusinessCardPage(e.Image);

                    if (e.Image != null && !e.Image.IsDisposed)
                    {
                        e.Image.Dispose();
                    }
                }
            }
            else
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    HomePage.Instance.PopCameraPage();
                    PictureTaken?.Invoke(this, new PictureTakenEventArgs(e.Image, null, CurrentOperation));
                });
            }
        }
Beispiel #3
0
        public void EventTriggered(object Sender, EventArgs Event)
        {
            PictureTaken CreatedEvent = new PictureTaken();

            CreatedEvent.Image = new System.IO.FileInfo(GetFilename(false));
            this.OnPicture(CreatedEvent);
        }
        public void TakePhoto(string imageFileName)
        {
            ImageBuffer noCameraImage = new ImageBuffer(640, 480);
            Graphics2D  graphics      = noCameraImage.NewGraphics2D();

            graphics.Clear(Color.White);
            graphics.DrawString("No Camera Detected", 320, 240, pointSize: 24, justification: Agg.Font.Justification.Center);
            graphics.DrawString(DateTime.Now.ToString(), 320, 200, pointSize: 12, justification: Agg.Font.Justification.Center);
            AggContext.ImageIO.SaveImageData(imageFileName, noCameraImage);

            PictureTaken?.Invoke(null, null);
        }
Beispiel #5
0
        public override void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                                      CMSampleBuffer photoSampleBuffer,
                                                      CMSampleBuffer previewPhotoSampleBuffer,
                                                      AVCaptureResolvedPhotoSettings resolvedSettings,
                                                      AVCaptureBracketedStillImageSettings bracketSettings,
                                                      NSError error)
        {
            if (photoSampleBuffer != null)
            {
                _photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Error capturing photo: {0}", error.LocalizedDescription));
            }

            PictureTaken?.Invoke(this, _photoData);
        }
    //--------------- Processing Information -----------------------
    void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
    {
        string message = Encoding.Default.GetString(e.Message);

        Debug.Log(message);

        Debug.Log(e.Topic);
        //Debug.Log("Altitude is: " + pos.Altitude);
        //Debug.Log("Azimuth is: " + pos.Azimuth);

        if (e.Topic == "IC.embedded/friends/unity/sensors")
        {
            ReceivedTelescopePos pos = JsonUtility.FromJson <ReceivedTelescopePos>(message);
            Debug.Log("Altitude is: " + pos.Altitude);
            Debug.Log("Azimuth is: " + pos.Azimuth);
            OnReceivePosUpdate(pos);


            TelsecopeUpdate = message;
        }
        else if (e.Topic == "IC.embedded/friends/unity/camera")
        {
            PictureTaken pic = JsonUtility.FromJson <PictureTaken>(message);
            Debug.Log(pic.Altitude);
            Debug.Log(pic.Azimuth);
            Debug.Log(pic.DayTaken);
            Debug.Log(pic.HourTaken);

            AASharp.AAS2DCoordinate coor = CoordinateTransformation.ToCelestialCoordinates(pic.Latitude, pic.Longitude, pic.Azimuth, pic.Altitude);

            OnReceivePic(pic, (float)coor.Y, (float)coor.X);

            ImageUpdate = message;


            //create new image data
            ImageData newImageData = new ImageData((float)coor.Y, (float)coor.X, pic.YearTaken, pic.HourTaken, pic.MinuteTaken, pic.ImageName);

            ALL_IMAGES.Add(newImageData);
            SaveData();
        }
    }
Beispiel #7
0
 public void OnPictureTaken(byte[] data, Android.Hardware.Camera camera)
 {
     try
     {
         PictureTaken?.Invoke(this, ExportBitmapAsPng(data));
         Toast.MakeText(Context, "PICTURE TAKEN SUCESSFULLY", ToastLength.Long).Show();
     }
     catch (Exception e)
     {
         Toast.MakeText(Context, e.Message, ToastLength.Long).Show();
     }
     try
     {
         _mCamera?.StartPreview();
     }
     catch (Exception e)
     {
         Toast.MakeText(Context, e.Message, ToastLength.Long).Show();
     }
 }
        public void OnPictureTaken(byte[] data, Camera camera)
        {
            FileStream outt;

            try
            {
                outt = new FileStream(thumbnailfilename, FileMode.CreateNew);
                outt.Write(data, 0, data.Length);
                outt.Flush(true);
                outt.Close();
                PictureTaken?.Invoke();
            }
            catch (Exception)
            {
            }
            finally
            {
                mPreview.StartCameraPreview();
            }
        }
 //------------------ CallBack Functions ------------------------
 void OnReceivePic(PictureTaken data, float dec, float ra)
 {
     //PhotoManager.Instance.OnReceivedNewImage(dec, ra, data.DayTaken, data.HourTaken, data.MinuteTaken, data.ImageName);
 }
Beispiel #10
0
 protected virtual void OnPicture(PictureTaken Event)
 {
     PictureNotify?.Invoke(this, Event);
 }