【发布时间】:2020-11-15 19:56:40
【问题描述】:
在应用程序中,我需要扫描条形码,然后访问相机拍照,然后进一步扫描条形码。
因此,我同时使用了 TCameraComponent 和 IFMXCameraService 接口。
一旦我启动 TCameraComponent(用于扫描条形码),然后将其停用并拍照......当我返回 TCameraComponent 时,我收到错误:引发异常类 EJNIException,消息为“java” .lang.RuntimeException: getParameters failed (empty parameters)'.
一个重要的澄清:如果你先得到一张照片,然后打开条形码扫描仪,没有错误。如果您至少打开一次条形码扫描仪,然后将其关闭、拍照并再次打开扫描仪,则会出现此错误。
启动扫描仪:
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( '' );
停止扫描仪:
lblScanning.Text := 'Scan Off';
FaLblScanning.Enabled := False;
FActive := False;
DisplaySlowWarning(False);
FCamera.Active := False;
LabelFPS.Text := '';
拍照:
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');
我尝试将 Service 设为全局,并在拍照后使用 Service := nil,但没有帮助。
【问题讨论】:
-
SetCaptureSetting() 是做什么的,你说的“条码扫描器”是什么?
-
SetCaptureSetting() 函数设置 FCamera.CaptureSetting := CaptureSettings[ CaptureSettingsIndex ]; CaptureSettings: TArray
;这是之前获得的设置数组。我使用:github.com/Spelt/ZXing.Delphi 但我不认为问题出在扫描仪上。我试图完全禁用它,这里描述了另一个扫描仪的类似问题,但没有找到解决方案 delphi-developers-archive.blogspot.com/2016/06/hi-guys.html
标签: android delphi camera firemonkey