简体   繁体   English

带有 IFMXCameraService 错误的 FMX TCameraComponent

[英]FMX TCameraComponent with IFMXCameraService bug

In the app I need to scan a Barcode, then access the camera to take photos followed by further Barcode scanning.在应用程序中,我需要扫描条码,然后访问相机拍照,然后进一步扫描条码。

Therefore, I use both the TCameraComponent and IFMXCameraService interface.因此,我同时使用 TCameraComponent 和 IFMXCameraService 接口。

The problem occurs once I start the TCameraComponent (for scanning a Barcode code), then deactivate it and take a photo... when i go back to TCameraComponent i get error: raised exception class EJNIException with message 'java.lang.RuntimeException: getParameters failed (empty parameters)' .一旦我启动 TCameraComponent(用于扫描条形码),然后将其停用并拍照……当我回到 TCameraComponent 时,我收到错误:引发异常类 EJNIException 并带有消息 'java.lang.RuntimeException: getParameters失败(空参数)'

An important clarification: if you first get a photo, and then open the barcode scanner, there is no error.一个重要的澄清:如果你先拿到一张照片,然后打开条码扫描仪,没有错误。 The error appears if you open the barcode scanner at least once, close it, take a photo, and open the scanner again.如果您至少打开条码扫描器一次,关闭它,拍照,然后再次打开扫描器,则会出现错误。

Start scanner:启动扫描仪:

    if ( Length( AGrantResults ) = 1 ) and ( AGrantResults[ 0 ] = TPermissionStatus.Granted ) then
     begin
      SetCaptureSetting();
      FBuffer.Clear( TAlphaColors.White );
      FActive := True;
      LabelFPS.Text := 'Start capturing...';
      FCamera.Active := True;
      StartStopWatch();
      lblScanning.Text := 'Scan On';
      FaLblScanning.Enabled := True;
     end else
      Showmessage( '' );

Stop scanner:停止扫描仪:

 lblScanning.Text := 'Scan Off';
 FaLblScanning.Enabled := False;
 FActive := False;
 DisplaySlowWarning(False);
 FCamera.Active := False; 
 LabelFPS.Text := '';

Take photo:拍照:

var
 Params: TParamsPhotoQuery;
 Service: IFMXCameraService;
begin
 if TPlatformServices.Current.SupportsPlatformService( IFMXCameraService, Service ) then
  begin
   Params.Editable := False;
   Params.NeedSaveToAlbum    := False;
   Params.RequiredResolution := TSize.Create( 1080, 1920 );
   Params.OnDidFinishTaking  := DoDidFinish;
   Service.TakePhoto( btnTakePhoto, Params );
  end else
   ShowMessage('This device does not support the camera service');

I tried making Service global, and using Service := nil after taking photo, did not help.我尝试将 Service 设为全局,并在拍照后使用 Service := nil ,但没有帮助。

在激活相机之前尝试添加属性

CameraComponent.Quality := FMX.Media.TVideoCaptureQuality.MediumQuality;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM