示例#1
0
        private static ICaptureGrab BuildCaptureGrabber(CaptureConfig config = null)
        {
            var request = new CaptureRequest {Device = CaptureDevice.Usb};
            if (EnvironmentService.IsUnix)
            {
                request.Device = CaptureDevice.Pi;
            }

            if (config == null)
            {
                // Default capture
                request.Config = new CaptureConfig {Resolution = new Resolution(160, 120), Framerate = 50, Monochrome = false};
            }
            else
            {
                request.Config = config;
            }

            var capture = CaptureFactory.GetCapture(request);
            var actualConfig = capture.GetCaptureProperties();
            Log.Info($"Created capture: {actualConfig}");

            SafetyCheckRoi(_consoleOptions, actualConfig);
            return capture;
        }
示例#2
0
 // Function to save out captured image data to disk as png files(mainly for debugging)
 public static void SaveOutImages(CaptureRequest completedRequest)
 {
     int numValues = Mathf.Min(completedRequest.shadersList.Count, completedRequest.capturedImages.Count);
     for(int i = 0; i < numValues; ++i)
         SaveOutImages(completedRequest.capturedImages[i].pictureBuffer, i);
     fileIndex++;
 }
        public static CaptureResponse CaptureAction(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service, string amazonAuthorizationId, string orderAmount, string orderReferenceId, int indicator, string providerId, string creditAmountString)
        {
            //initiate the capture request
            CaptureRequest captureRequest = new CaptureRequest();
            captureRequest.SellerId = propertiesCollection.MerchantID;
            captureRequest.AmazonAuthorizationId = amazonAuthorizationId;

            Price price = new Price();
            price.Amount = orderAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;

            captureRequest.CaptureAmount = price;
            captureRequest.CaptureReferenceId = orderReferenceId.Replace('-', 'c') + "captureRef" + indicator.ToString();
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditAmountString))
            {
                ProviderCredit providerCredit = new ProviderCredit();
                providerCredit.ProviderId= providerId;
                Price creditAmount = new Price();
                creditAmount.Amount = creditAmountString;
                creditAmount.CurrencyCode = propertiesCollection.CurrencyCode;
                providerCredit.CreditAmount= creditAmount;
                ProviderCreditList providerCreditList = new ProviderCreditList();
                providerCreditList.member = new List<ProviderCredit>();
                providerCreditList.member.Add(providerCredit);
                captureRequest.ProviderCreditList = providerCreditList;
            }

            return CaptureSample.InvokeCapture(service, captureRequest);
        }
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
        {
            if (loadingDialog != null)
            {
                loadingDialog.Dismiss();
            }

            base.OnCaptureCompleted(session, request, result);
        }
示例#5
0
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
        {
            base.OnCaptureCompleted(session, request, result);
            //Owner.ShowToast("Saved: " + Owner.mFile);

            //Log.Debug(TAG, Owner.mFile.ToString());

            Owner.UnlockFocus();
        }
 private XDocument Write(CaptureRequest entity)
 {
     return(new XDocument(
                XName.Get("EPCISDocument", EpcisNamespaces.Capture),
                new XAttribute("creationDate", entity.Header.DocumentTime.ToString("yyyy-MM-ddThh:MM:ssZ")),
                new XAttribute("schemaVersion", entity.Header.SchemaVersion),
                new XElement("EPCISBody", new XElement("EventList", entity.EventList.Select(new XmlEventFormatter().Format)))
                ));
 }
        public override void OnCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult)
        {
            base.OnCaptureProgressed(session, request, partialResult);

            this._owner.CaptureResult = partialResult;

            ProcessOnCapture();
            //Process(partialResult);
        }
示例#8
0
        public System.Threading.Tasks.Task <CaptureResponse> CaptureAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, Input Input)
        {
            CaptureRequest inValue = new CaptureRequest();

            inValue.Security      = Security;
            inValue.RequestHeader = RequestHeader;
            inValue.Input         = Input;
            return(((CaptureV01)(this)).CaptureAsync(inValue));
        }
        public override void OnCaptureStarted(CameraCaptureSession session, CaptureRequest request, long timestamp, long frameNumber)
        {
            loadingDialog = new ProgressDialog(context);
            loadingDialog.SetMessage(context.Resources.GetString(Resource.String.PleaseWait));
            loadingDialog.Indeterminate = true;
            loadingDialog.Show();

            base.OnCaptureStarted(session, request, timestamp, frameNumber);
        }
示例#10
0
 public override CaptureRequest WantsCapture(InputState input)
 {
     if (input.bLeftStickPressed ^ input.bRightStickPressed)
     {
         CaptureSide eSide = (input.bLeftStickPressed) ? CaptureSide.Left : CaptureSide.Right;
         return(CaptureRequest.Begin(this, eSide));
     }
     return(CaptureRequest.Ignore);
 }
示例#11
0
 public void newRequest(ScreenshotRequest request)
 {
     try
     {
         lock (requestLock)
         {
             if (request is PauseRequest)
             {
                 paused = true;
             }
             else if (request is StopRequest)
             {
                 paused = true;
                 if (frameTarget != null)
                 {
                     frameTarget.close();
                     frameTarget = null;
                 }
             }
             else if (request is ResumeRequest)
             {
                 if (frameTarget != null)
                 {
                     paused = false;
                 }
             }
             else if (request is StreamRequest)
             {
                 StreamRequest streamRequest = (StreamRequest)request;
                 frameTarget = new FrameServer(streamRequest.Host, streamRequest.Port);
                 this.captureRect = streamRequest.Region;
                 this.freq = 1 / streamRequest.Fps;
                 paused = false;
             }
             else if (request is CaptureRequest)
             {
                 CaptureRequest captureRequest = (CaptureRequest)request;
                 frameTarget = new IPCHostSink(ProcessId, request.RequestId, Interface);
                 this.captureRect = captureRequest.Region;
                 this.freq = 1 / captureRequest.Fps;
                 paused = false;
             }
         }
     }
     catch (Exception e)
     {
         paused = true;
         if (frameTarget != null)
         {
             frameTarget.close();
             frameTarget = null;
         }
         ErrorMessage("Exception when processing request" + request + "\n\r" + e);
         paused = true;
     }
 }
 public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
 {
     base.OnCaptureCompleted(session, request, result);
     if (request.Tag?.ToString() == "FOCUS")
     {
         fragment.FocusComplete();
         //the focus trigger is complete -
         //resume repeating (preview surface will get frames), clear AF trigger
     }
 }
示例#13
0
        public override void OnCaptureStarted(CameraCaptureSession session, CaptureRequest request, long timestamp, long frameNumber)
        {
            _session = session;
            //_isReady = true;

            if (!_timer.Enabled)
            {
                _timer.Start();
            }
        }
示例#14
0
        public override void OnCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult)
        {
            base.OnCaptureProgressed(session, request, partialResult);

            CaptureProgressed?.Invoke(this, new CameraCaptureListenerEventArgs
            {
                CaptureRequest = request,
                CaptureResult  = partialResult
            });
        }
示例#15
0
        private static async Task <CaptureResponse> CaptureSaleAsync(string paymentId, IPagadorClient client)
        {
            var request = new CaptureRequest
            {
                Amount    = 100000,
                PaymentId = paymentId
            };

            return(await client.CaptureAsync(request));
        }
            public override void OnCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult)
            {
                var handler = CaptureProgressed;

                if (handler != null)
                {
                    handler(session, new CameraCaptureEventArgs {
                        Request = request, Result = partialResult
                    });
                }
            }
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
        {
            // If something goes wrong with the save (or the handler isn't even
            // registered, this code will toast a success message regardless...)
            // owner.ShowToast("Saved: " + owner.mFile);

            Log.Debug(TAG, owner.mFile.ToString());
            //  owner.UnlockFocus();

            //     owner.FinishActivity(owner.mFile.ToString());
        }
        public void Work <TState>(CameraCaptureSession session, CaptureRequest request, CaptureResult result,
                                  ref TState captureState) where TState : class
        {
            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);

            if (aeState == null || aeState.IntValue() != (int)ControlAEState.Precapture)
            {
                captureState = (TState)CaptureStateFactory.GetCaptureState(CaptureStates.PictureTaken);
                _captureStillPhoto();
            }
        }
示例#19
0
        public async Task AuthorizeAndCapture_Test()
        {
            var authorization = new AuthorizeRequest
            {
                Amount = new Amount
                {
                    BaseAmount = 1000
                },
                Card = new Card
                {
                    CardPresent     = false,
                    Cvv             = "123",
                    ExpirationMonth = "12",
                    ExpirationYear  = "21",
                    Pan             = "5105105105105100"
                },
                Mid      = _merchantId,
                Terminal = new Terminal
                {
                    EntryType    = EntryType.Keypad,
                    TerminalId   = _terminalId,
                    TerminalType = TerminalType.ECommerce
                },
                Payer = new Payer
                {
                    BillingAddress = new Address
                    {
                        PostalCode = "76132"
                    }
                },
                Order = new Order
                {
                    OrderNumber = "testing"
                }
            };

            var response = await _client.AuthorizeAmountAsync(authorization);

            var capture = new CaptureRequest
            {
                TransactionId = response.TransactionId,
                Mid           = _merchantId,
                Terminal      = new Terminal
                {
                    EntryType    = EntryType.Keypad,
                    TerminalId   = _terminalId,
                    TerminalType = TerminalType.ECommerce
                }
            };

            var captureResponse = await _client.CaptureAmountAsync(capture);

            Assert.IsNotNull(capture.TransactionId);
        }
            public override void OnCaptureCompleted(CameraCaptureSession session,
                                                    CaptureRequest request,
                                                    TotalCaptureResult result)
            {
                // Only update UI every so many frames
                // Use an odd number here to ensure both even and odd exposures get an occasional update
                long frameNumber = result.FrameNumber;

                if (frameNumber % 3 != 0)
                {
                    return;
                }

                Integer exposureComp = result.Get(CaptureResult.ControlAeExposureCompensation) as Integer;

                if (exposureComp == null)
                {
                    throw new RuntimeException("Cannot get exposure compensation.");
                }

                // Format exposure time nicely
                Rational exposureStep = mParent.mCameraInfo.ExposureState.ExposureCompensationStep;
                string   exposureText = (exposureComp.FloatValue() * exposureStep.FloatValue()).ToString("0.00");

                if (mParent.mRenderMode == ViewfinderProcessor.ModeNormal)
                {
                    mParent.mAutoExposureText.Text = exposureText;

                    mParent.mEvenExposureText.Enabled = false;
                    mParent.mOddExposureText.Enabled  = false;
                    mParent.mAutoExposureText.Enabled = true;

                    if (exposureComp.IntValue() != mParent.mAutoExposure)
                    {
                        mParent.mCameraControl.SetExposureCompensationIndex(mParent.mAutoExposure);
                    }
                }
                else if ((frameNumber & 1) == 0)
                {
                    mParent.mEvenExposureText.Text = exposureText;

                    mParent.mEvenExposureText.Enabled = true;
                    mParent.mOddExposureText.Enabled  = true;
                    mParent.mAutoExposureText.Enabled = false;
                }
                else
                {
                    mParent.mOddExposureText.Text = exposureText;

                    mParent.mEvenExposureText.Enabled = true;
                    mParent.mOddExposureText.Enabled  = true;
                    mParent.mAutoExposureText.Enabled = false;
                }
            }
示例#21
0
        public override void OnOpened(CameraDevice camera)
        {
            CaptureRequest.Builder builder = camera.CreateCaptureRequest(CameraTemplate.Preview);
            builder.AddTarget(_surface);
            builder.AddTarget(_reader.Surface);
            CaptureRequest captureRequest = builder.Build();

            camera.CreateCaptureSession(new List <Surface> {
                _surface, _reader.Surface
            }, new MySessionCallback(captureRequest, _cameraPreviewView, _reader), new Handler(msg => { }));
        }
        public void Work <TState>(CameraCaptureSession session, CaptureRequest request, CaptureResult result,
                                  ref TState captureState) where TState : class
        {
            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);

            if (aeState == null || aeState.IntValue() == (int)ControlAEState.Precapture ||
                aeState.IntValue() == (int)ControlAEState.FlashRequired)
            {
                captureState = (TState)CaptureStateFactory.GetCaptureState(CaptureStates.WaitingNonPrecapture);
            }
        }
            public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
            {
                var handler = CaptureCompleted;

                if (handler != null)
                {
                    handler(session, new CameraCaptureEventArgs {
                        Request = request, Result = result
                    });
                }
            }
示例#24
0
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                                                TotalCaptureResult result)
        {
            base.OnCaptureCompleted(session, request, result);

            CaptureComplete?.Invoke(this, new CameraCaptureListenerEventArgs
            {
                CaptureRequest = request,
                CaptureResult  = result
            });
        }
        public Output Capture(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, Input Input)
        {
            CaptureRequest inValue = new CaptureRequest();

            inValue.Security      = Security;
            inValue.RequestHeader = RequestHeader;
            inValue.Input         = Input;
            CaptureResponse retVal = ((CaptureV02)(this)).Capture(inValue);

            Security = retVal.Security;
            return(retVal.Output);
        }
        public static Dictionary<string, string> CaptureApiCall()
        {
            string captureId = "";
            string uniqueReferenceId = GenerateRandomUniqueString();

            // If the captureNow was not true then capture the amount for the Authorization ID
            if (!captureNow)
            {
                CaptureRequest captureRequestParameters = new CaptureRequest();
                captureRequestParameters.WithAmazonAuthorizationId(amazonAuthorizationId)
                    // The below code can be used to get the amount from the session. the amount was added into session in the SetPaymentDetails.aspx
                    //.WithAmount(decimal.Parse(Session["amount"].ToString()))

                    //For example we will be authorizing amount value of 1.99
                    .WithAmount((decimal)1.99)
                    .WithCurrencyCode(Regions.currencyCode.USD)
                    .WithCaptureReferenceId(uniqueReferenceId)
                    .WithSellerCaptureNote("customNote");

                CaptureResponse captureResponse = client.Capture(captureRequestParameters);
                apiResponse["captureResponse"] = captureResponse.GetJson();

                if (!captureResponse.GetSuccess())
                {
                    // API CALL FAILED, get the Error code and Error Message
                    string errorCode = captureResponse.GetErrorCode();
                    string errorMessage = captureResponse.GetErrorMessage();
                }
                else
                {
                    return apiResponse;
                }
            }
            else
            {
                // The captureNow was true therefore just disply the Captured response details
                GetCaptureDetailsRequest getCaptureRequestParameters = new GetCaptureDetailsRequest();
                foreach (string id in amazonCaptureIdList)
                {
                    // Here there can be multiple Capture ID's. For example purposes we are considering a single Capture ID.
                    captureId = id;
                }
                getCaptureRequestParameters.WithAmazonCaptureId(captureId);

                CaptureResponse getCaptureDetailsResponse = client.GetCaptureDetails(getCaptureRequestParameters);
                apiResponse["captureResponse"] = getCaptureDetailsResponse.GetJson();
                if (getCaptureDetailsResponse.GetSuccess())
                {
                    return apiResponse;
                }
            }
            return apiResponse;
        }
示例#27
0
 override public CaptureRequest WantsCapture(InputState input)
 {
     if (input.bLeftTriggerPressed ^ input.bRightTriggerPressed)
     {
         CaptureSide eSide = (input.bLeftTriggerPressed) ? CaptureSide.Left : CaptureSide.Right;
         //ITool tool = context.ToolManager.GetActiveTool((int)eSide);
         //if (tool != null && tool is TwoPointMeasureTool) {
         return(CaptureRequest.Begin(this, eSide));
         //}
     }
     return(CaptureRequest.Ignore);
 }
        protected CaptureRequest CreateCaptureTestRequest(string pspReference)
        {
            var captureRequest = new CaptureRequest
            {
                MerchantAccount    = "MerchantAccount",
                ModificationAmount = new Amount("EUR", 150),
                Reference          = "capture - " + DateTime.Now.ToString("yyyyMMdd"),
                OriginalReference  = pspReference
            };

            return(captureRequest);
        }
        public Charge Capture(string customer_id, string charge_id, Decimal?amount)
        {
            if (charge_id == null)
            {
                throw new ArgumentNullException("charge_id cannot be null");
            }
            string         ep      = GetEndPoint(customer_id, charge_id) + "/capture";
            CaptureRequest request = new CaptureRequest();

            request.Amount = amount;
            return(this.httpClient.Post <Charge>(ep, request));
        }
示例#30
0
        public static Dictionary <string, string> CaptureApiCall()
        {
            string captureId         = "";
            string uniqueReferenceId = GenerateRandomUniqueString();

            // If the captureNow was not true then capture the amount for the Authorization ID
            if (!captureNow)
            {
                CaptureRequest captureRequestParameters = new CaptureRequest();
                captureRequestParameters.WithAmazonAuthorizationId(amazonAuthorizationId)
                // The below code can be used to get the amount from the session. the amount was added into session in the SetPaymentDetails.aspx
                //.WithAmount(decimal.Parse(Session["amount"].ToString()))

                //For example we will be authorizing amount value of 1.99
                .WithAmount((decimal)1.99)
                .WithCurrencyCode(Regions.currencyCode.USD)
                .WithCaptureReferenceId(uniqueReferenceId)
                .WithSellerCaptureNote("customNote");

                CaptureResponse captureResponse = client.Capture(captureRequestParameters);
                apiResponse["captureResponse"] = captureResponse.GetJson();

                if (!captureResponse.GetSuccess())
                {
                    // API CALL FAILED, get the Error code and Error Message
                    string errorCode    = captureResponse.GetErrorCode();
                    string errorMessage = captureResponse.GetErrorMessage();
                }
                else
                {
                    return(apiResponse);
                }
            }
            else
            {
                // The captureNow was true therefore just disply the Captured response details
                GetCaptureDetailsRequest getCaptureRequestParameters = new GetCaptureDetailsRequest();
                foreach (string id in amazonCaptureIdList)
                {
                    // Here there can be multiple Capture ID's. For example purposes we are considering a single Capture ID.
                    captureId = id;
                }
                getCaptureRequestParameters.WithAmazonCaptureId(captureId);

                CaptureResponse getCaptureDetailsResponse = client.GetCaptureDetails(getCaptureRequestParameters);
                apiResponse["captureResponse"] = getCaptureDetailsResponse.GetJson();
                if (getCaptureDetailsResponse.GetSuccess())
                {
                    return(apiResponse);
                }
            }
            return(apiResponse);
        }
        public async Task CaptureDocument(CaptureRequest captureDocument, CancellationToken cancellationToken)
        {
            captureDocument.EventList.ForEach(EpcisEventValidator.Validate);

            await _unitOfWork.Execute(async tx =>
            {
                var headerId = await tx.RequestStore.Store(captureDocument.Header, _userContext.Current, cancellationToken);

                await tx.MasterDataManager.Store(headerId, captureDocument.MasterDataList, cancellationToken);
                await tx.EventStore.Store(headerId, captureDocument.EventList, cancellationToken);
            });
        }
 public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
 {
     if (Fragment != null && File != null)
     {
         Activity activity = Fragment.Activity;
         if (activity != null)
         {
             Toast.MakeText(activity, "Saved: " + File.ToString(), ToastLength.Short).Show();
             Fragment.StartPreview();
         }
     }
 }
示例#33
0
        public ModificationResult Capture(string pspReference, string currency, int amount)
        {
            var modification   = new Modification(_client);
            var captureRequest = new CaptureRequest
            {
                MerchantAccount    = _adyenConfiguration.MerchantAccount,
                ModificationAmount = new Amount(currency, amount),
                OriginalReference  = pspReference
            };

            return(modification.Capture(captureRequest));
        }
示例#34
0
 public Task <CaptureResponse> CapturePayment(
     string paymentId,
     CaptureRequest captureRequest,
     string idempotencyKey = null,
     CancellationToken cancellationToken = default)
 {
     CheckoutUtils.ValidateParams("paymentId", paymentId);
     return(ApiClient.Post <CaptureResponse>(BuildPath(PaymentsPath, paymentId, "captures"),
                                             SdkAuthorization(),
                                             captureRequest,
                                             cancellationToken,
                                             idempotencyKey));
 }
示例#35
0
 public void RequestCaptures(CaptureRequest newRequest)
 {
     if (_captureRequests.Contains(newRequest))
     {
         Debug.Log("Already have a pending request");
         return;
     }
     if (newRequest.shadersList == null)
     {
         newRequest.shadersList = new List<Shader>();
         newRequest.shadersList.Add(null);
     }
     _captureRequests.Enqueue(newRequest);
     StartCoroutine(CaptureCoroutine());
 }
        public void CaptureApiCall()
        {
            string captureId = "";
            string uniqueReferenceId = GenerateRandomUniqueString();

            // If the capture has not happened on the previous Authorize API call then capture the amount.
            if (!captureNow)
            {
                CaptureRequest captureRequestParameters = new CaptureRequest();
                captureRequestParameters.WithAmazonAuthorizationId(amazonAuthorizationId)
                    .WithAmount(decimal.Parse(Session["amount"].ToString()))
                    .WithCurrencyCode(Regions.currencyCode.USD)
                    .WithCaptureReferenceId(uniqueReferenceId)
                    .WithSellerCaptureNote("customNote");

                CaptureResponse captureResponse = client.Capture(captureRequestParameters);

                // Capture was not a success Get the Error code and the Error message
                if (!captureResponse.GetSuccess())
                {
                    string errorCode = captureResponse.GetErrorCode();
                    string errorMessage = captureResponse.GetErrorMessage();
                    capture.InnerHtml = "Capture API call Failed" + Environment.NewLine + captureResponse.GetJson();
                }
                else
                {
                    // In this example the below is to simply display the output
                    capture.InnerHtml = captureResponse.GetJson();
                }
            }
            else
            {
                // In this case the capture had already happened . running the GetCaptureDetails API call to get the output of the capture.
                GetCaptureDetailsRequest getCaptureRequestParameters = new GetCaptureDetailsRequest();
                foreach (string id in amazonCaptureIdList)
                {
                    captureId = id;
                }
                getCaptureRequestParameters.WithAmazonCaptureId(captureId);

                CaptureResponse getCaptureDetailsResponse = client.GetCaptureDetails(getCaptureRequestParameters);

                if (getCaptureDetailsResponse.GetSuccess())
                {
                    capture.InnerHtml = getCaptureDetailsResponse.GetJson();
                }
            }
        }
 public override void OnCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult)
 {
     Process(partialResult);
 }
 public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
 {
     Process(result);
 }
示例#39
0
        static void Main(string[] args)
        {
            var appData = ExecutionEnvironment.GetApplicationMetadata();
            Log.Info(appData);

            var options = new ConsoleOptions(args);

            if (options.ShowHelp)
            {
                Console.WriteLine("Options:");
                options.OptionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            ICaptureGrab capture = null;

            CapturePi.DoMatMagic("CreateCapture");

            var noCaptureGrabs = new[] { Mode.simple, Mode.pantiltjoy };
            var i2cRequired = new[] { Mode.pantiltface, Mode.pantiltjoy ,Mode.pantiltcolour };
            CaptureConfig captureConfig = null;
            if (!noCaptureGrabs.Contains(options.Mode))
            {
                var request = new CaptureRequest { Device = CaptureDevice.Usb };
                if (EnvironmentService.IsUnix)
                {
                    request.Device = CaptureDevice.Pi;
                }

                request.Config = new CaptureConfig { Resolution = new Resolution(160,120), Framerate = 10, Monochrome = false };

                capture = CaptureFactory.GetCapture(request);
                captureConfig = capture.GetCaptureProperties();
                Log.Info(m => m("Capture properties read: {0}", captureConfig));

                SafetyCheckRoi(options, captureConfig);
            }

            IPanTiltMechanism panTiltMech = null;
            IScreen screen = null;
            if (i2cRequired.Contains(options.Mode))
            {
                var pwmDeviceFactory = new Pca9685DeviceFactory();
                var pwmDevice = pwmDeviceFactory.GetDevice(options.UseFakeDevice);
                panTiltMech = new PanTiltMechanism(pwmDevice);
                screen = new ConsoleScreen();
                screen.Clear();
            }

            IRunner runner;
            Log.Info(options);
            switch (options.Mode)
            {
                case Mode.noop: runner = new NoopRunner(capture);
                    break;

                case Mode.simple:runner = new SimpleCv();
                    break;

                case Mode.colourdetect:
                    var colorDetector = new ColorDetectRunner(capture);
                    if (options.HasColourSettings)
                    {
                        colorDetector.Settings = options.ColourSettings;
                    }
                    runner = colorDetector;
                    break;

                case Mode.haar:
                    var relativePath = string.Format(@"haarcascades{0}haarcascade_frontalface_default.xml", Path.DirectorySeparatorChar);
                    var cascadeFilename = Path.Combine(appData.ExeFolder, relativePath);
                    var cascadeContent = File.ReadAllText(cascadeFilename);
                    runner = new CascadeRunner(capture, cascadeContent);
                    break;

                case Mode.servosort:
                    runner = new ServoSorter(capture, options);
                    break;

                case Mode.pantiltjoy:
                    var joyController = new JoystickPanTiltController(panTiltMech);
                    runner = new TimerRunner(joyController, screen);
                    break;

                case Mode.pantiltface:
                    var controllerF = new FaceTrackingPanTiltController(panTiltMech, captureConfig);
                    runner = new CameraBasedPanTiltRunner(panTiltMech, capture, controllerF, screen);
                    break;

                case Mode.pantiltcolour:
                    var controllerC = new ColourTrackingPanTiltController(panTiltMech, captureConfig);
                    if (options.HasColourSettings)
                    {
                        controllerC.Settings = options.ColourSettings;
                    }
                    else
                    {
                        throw KrakenException.Create("Colour settings not found");
                    }
                    runner = new CameraBasedPanTiltRunner(panTiltMech, capture, controllerC, screen);
                    break;

                default:
                    throw KrakenException.Create("Option mode {0} needs wiring up", options.Mode);
            }

            runner.Run();
        }
        public void Capture(AmazonPayClient client, CapturePaymentRequest capture, CapturePaymentResult result)
        {
            result.NewPaymentStatus = capture.Order.PaymentStatus;

            var request = new CaptureRequest();
            request.SellerId = client.Settings.SellerId;
            request.AmazonAuthorizationId = capture.Order.AuthorizationTransactionId;
            request.CaptureReferenceId = GetRandomId("Capture");
            //request.SellerCaptureNote = client.Settings.SellerNoteCapture.Truncate(255);

            request.CaptureAmount = new Price()
            {
                Amount = capture.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture),
                CurrencyCode = capture.Order.CustomerCurrencyCode ?? "EUR"
            };

            var response = client.Service.Capture(request);

            if (response != null && response.IsSetCaptureResult() && response.CaptureResult.IsSetCaptureDetails())
            {
                var details = response.CaptureResult.CaptureDetails;

                result.CaptureTransactionId = details.AmazonCaptureId;

                if (details.IsSetCaptureStatus() && details.CaptureStatus.IsSetState())
                {
                    result.CaptureTransactionResult = details.CaptureStatus.State.ToString().Grow(details.CaptureStatus.ReasonCode, " ");

                    if (details.CaptureStatus.State == PaymentStatus.COMPLETED)
                        result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.Paid;
                }
            }
        }
        private void OnConfigured(CameraCaptureSession session)
        {
            // The camera is already closed
            if (null != CameraDevice)
            {

                // When the session is ready, we start displaying the preview.
                _captureSession = session;

                try
                {
                    // Auto focus should be continuous for camera preview.
                    _previewRequestBuilder.Set(CaptureRequest.ControlAfMode, new Integer((int)ControlAFMode.ContinuousPicture));
                    // Flash is automatically enabled when necessary.
                    _previewRequestBuilder.Set(CaptureRequest.ControlAeMode, new Integer((int)ControlAEMode.OnAutoFlash));

                    // Finally, we start displaying the camera preview.
                    _previewRequest = _previewRequestBuilder.Build();
                    _captureSession.SetRepeatingRequest(_previewRequest, _captureCallback, _backgroundHandler);
                }
                catch (CameraAccessException e)
                {
                    e.PrintStackTrace();
                }
            }
        }
示例#42
0
			public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
			{
				if (Fragment != null && File != null)
				{
					Activity activity = Fragment.Activity;
					if (activity != null)
					{
						Fragment.PictureTaken(File.AbsolutePath);
					}
				}
			}
		/// <summary>
		/// Sets up capture request builder.
		/// </summary>
		/// <param name="builder">Builder.</param>
		private void SetUpCaptureRequestBuilder(CaptureRequest.Builder builder)
		{
			// In this sample, w just let the camera device pick the automatic settings
			builder.Set (CaptureRequest.ControlMode, new Java.Lang.Integer((int)ControlMode.Auto));
		}
			public override void OnCaptureCompleted (CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
			{
				if (Fragment != null && File != null)
				{
					Activity activity = Fragment.Activity;
					if (activity != null)
					{
						Toast.MakeText(activity, "Saved: " + File.ToString(), ToastLength.Short).Show();
						Fragment.StartPreview ();
					}
				}
			}
示例#45
0
        private void SetUpCaptureRequestBuilder(CaptureRequest.Builder builder)
        {
            builder.Set (CaptureRequest.ControlMode, new Java.Lang.Integer((int)ControlMode.Auto));

            builder.Set (CaptureRequest.ControlAfMode, new Java.Lang.Integer ((int)ControlAFMode.Off));

            var focusDistanceCalibration = cCharacteristics.Get (CameraCharacteristics.LensInfoFocusDistanceCalibration);
            Log.WriteLine (LogPriority.Info, "CameraFragment: CameraCharacteristics", "lensFocusDistanceCalibration = " + focusDistanceCalibration);
            float minDistance = (float)cCharacteristics.Get (CameraCharacteristics.LensInfoMinimumFocusDistance);

            Toast.MakeText (Activity, "Tell Chris this: LensFocusDistanceCalibration = " + focusDistanceCalibration + "\n and: minFocusDistance = " + minDistance, ToastLength.Long);

            if (focusDistance > minDistance)
                builder.Set (CaptureRequest.LensFocusDistance, 1 / focusDistance);
            else
                builder.Set (CaptureRequest.LensFocusDistance, minDistance);
        }
        public static CaptureResponse InvokeCapture(IOffAmazonPaymentsService service, CaptureRequest request)
        {
            CaptureResponse response = null;
            try
            {
                response = service.Capture(request);
                Console.WriteLine("Service Response");
                Console.WriteLine("=============================================================================");
                Console.WriteLine();
                Console.WriteLine("        CaptureResponse");
                if (response.IsSetCaptureResult())
                {
                    Console.WriteLine("            CaptureResult");
                    CaptureResult captureResult = response.CaptureResult;
                    if (captureResult.IsSetCaptureDetails())
                    {
                        Console.WriteLine("                CaptureDetails");
                        CaptureDetails captureDetails = captureResult.CaptureDetails;
                        if (captureDetails.IsSetAmazonCaptureId())
                        {
                            Console.WriteLine("                    AmazonCaptureId");
                            Console.WriteLine("                        {0}", captureDetails.AmazonCaptureId);
                        }
                        if (captureDetails.IsSetCaptureReferenceId())
                        {
                            Console.WriteLine("                    CaptureReferenceId");
                            Console.WriteLine("                        {0}", captureDetails.CaptureReferenceId);
                        }
                        if (captureDetails.IsSetSellerCaptureNote())
                        {
                            Console.WriteLine("                    SellerCaptureNote");
                            Console.WriteLine("                        {0}", captureDetails.SellerCaptureNote);
                        }
                        if (captureDetails.IsSetCaptureAmount())
                        {
                            Console.WriteLine("                    CaptureAmount");
                            Price captureAmount = captureDetails.CaptureAmount;
                            if (captureAmount.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", captureAmount.Amount);
                            }
                            if (captureAmount.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", captureAmount.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetRefundedAmount())
                        {
                            Console.WriteLine("                    RefundedAmount");
                            Price refundedAmount = captureDetails.RefundedAmount;
                            if (refundedAmount.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", refundedAmount.Amount);
                            }
                            if (refundedAmount.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", refundedAmount.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetCaptureFee())
                        {
                            Console.WriteLine("                    CaptureFee");
                            Price captureFee = captureDetails.CaptureFee;
                            if (captureFee.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", captureFee.Amount);
                            }
                            if (captureFee.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", captureFee.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetCreationTimestamp())
                        {
                            Console.WriteLine("                    CreationTimestamp");
                            Console.WriteLine("                        {0}", captureDetails.CreationTimestamp);
                        }
                        if (captureDetails.IsSetProviderCreditSummaryList())
                        {
                            Console.WriteLine("                    ProviderCreditSummaryList");
                            foreach (ProviderCreditSummary providerCreditSummary in captureDetails.ProviderCreditSummaryList.member)
                            {
                                if (providerCreditSummary.IsSetProviderCreditId())
                                {
                                    Console.WriteLine("                         ProviderCreditId");
                                    Console.WriteLine("                             {0}", providerCreditSummary.ProviderCreditId);
                                }
                                if (providerCreditSummary.IsSetProviderId())
                                {
                                    Console.WriteLine("                         ProviderId");
                                    Console.WriteLine("                             {0}", providerCreditSummary.ProviderId);
                                }

                            }
                        }
                        if (captureDetails.IsSetCaptureStatus())
                        {
                            Console.WriteLine("                    CaptureStatus");
                            Status captureStatus = captureDetails.CaptureStatus;
                            if (captureStatus.IsSetState())
                            {
                                Console.WriteLine("                        State");
                                Console.WriteLine("                            {0}", captureStatus.State);
                            }
                            if (captureStatus.IsSetLastUpdateTimestamp())
                            {
                                Console.WriteLine("                        LastUpdateTimestamp");
                                Console.WriteLine("                            {0}", captureStatus.LastUpdateTimestamp);
                            }
                            if (captureStatus.IsSetReasonCode())
                            {
                                Console.WriteLine("                        ReasonCode");
                                Console.WriteLine("                            {0}", captureStatus.ReasonCode);
                            }
                            if (captureStatus.IsSetReasonDescription())
                            {
                                Console.WriteLine("                        ReasonDescription");
                                Console.WriteLine("                            {0}", captureStatus.ReasonDescription);
                            }
                        }
                    }
                }

                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

                Console.WriteLine();
            }

            catch (OffAmazonPaymentsServiceException ex)
            {
                PrintException(ex);
            }

            return response;
        }
示例#47
0
 private void ProcessCaptureRequest(CaptureRequest request)
 {
     if (request.capturedImages == null)
         request.capturedImages = new List<CapturedImage>();
     while(request.capturedImages.Count < request.shadersList.Count)
     {
         request.capturedImages.Add(new CapturedImage());
     //            Debug.Log("Capture count now: " + request.capturedImages.Count);
     }
     for (int i = 0; i < request.shadersList.Count; ++i)
     {
         if(DEBUG)
         {
             Debug.Log("SHADER CALL");
             Debug.Log(i);
         }
         request.capturedImages[i].pictureBuffer = TakeSnapshotNow(request.shadersList[i], request.outputFormatList[i]).pictureBuffer;
     }
     if (request.callbackFunc != null)
         request.callbackFunc(request);
 }
		private void setUpCaptureRequestBuilder(CaptureRequest.Builder builder)
		{
			builder.Set (CaptureRequest.ControlMode,new Java.Lang.Integer((int) ControlMode.Auto));

		}
 public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
 {
     Owner.ShowToast("Saved: " + Owner.mFile);
     Log.Debug(TAG, Owner.mFile.ToString());
     Owner.UnlockFocus();
 }