Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Camera] demo crashes after startup #113

Closed
han-k59 opened this issue Aug 20, 2022 · 23 comments
Closed

[Camera] demo crashes after startup #113

han-k59 opened this issue Aug 20, 2022 · 23 comments
Assignees
Labels
bug Something isn't working

Comments

@han-k59
Copy link

han-k59 commented Aug 20, 2022

The camera demo crashes after started in Android 32 bit.
No error messages except that android application has stopped with message "Unfortunately CameraDemo has stopped".

Samsung J5, Android version 6.0.1
Delphi 10.4

Note for the CD.CameraView form TNativeEllipse, class TnativeImage are not found.

Older camera demos from 2020 an onward do not work either but crash as soon an image is taken.

Note: I'm looking for a simple camera application where the exposure time can be set long like 2 seconds.

Han

@DelphiWorlds DelphiWorlds self-assigned this Aug 20, 2022
@DelphiWorlds DelphiWorlds added the question Further information is requested label Aug 20, 2022
@DelphiWorlds
Copy link
Owner

In regards to the issue where the application crashes, when exactly does this happen? e.g. when the app starts, or when it attempts to start the camera?

For the issue regarding TNativeEllipse etc, please ensure you install the controls package called KastriFMX, here:

https://github.com/DelphiWorlds/Kastri/tree/master/Packages/D104

I'm looking for a simple camera application where the exposure time can be set long like 2 seconds.

The code does not have this feature as yet, but I will consider adding it

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

install control package
If I select COMPONENT, INSTALL PACKAGE it is asking for a .bpl package. Not for .dproj. Im familiar with Lazarus not Delphi. So i have no idea how to install/use package D104.

It is strange to me that the compiler is not producing an error for the missing package D104??

I tried the debug an older version (Kastri-c5f28201c2cb5d5ac0f8bc4919308301741a0080). I can press the blue camera button and then an error occurs in line:

FImageStream.CopyFrom(AImageStream, AImageStream.Size); (The size is 170868)

and in system.classes

Source.ReadBuffer(Buffer, N);

See screenshots.
error1
error2

I had the impression the exposure time was adjustable in the latest version. That would be great for my Astronomy application. I you can share something working without a package required that would be great.

Thanks, Han

@DelphiWorlds
Copy link
Owner

i have no idea how to install/use package D104.

To install a package from source, open KastriFMX.dproj, right-click the project in the Project Manager window to bring up the context menu and click Install

then an error occurs in line..

What exactly is the error?

I had the impression the exposure time was adjustable in the latest version

Not the exposure time, the exposure value that corresponds to the ISO value can be adjusted.

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

What exactly is the error?
The application crashes.

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

I successfully installed the KastriFMX.dproj. I can now see the form of CD.view.Camera. Unfortunately the application still crashes immediately with Android message "Unfortunately CameraDemo has stopped". The log in Delphi disappears.

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

The application crashes at line 55 in CD.main.view:

FCameraView := TCameraView.Create(CameraTab);

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

In CD.view.Camera it crashes in line 91:
inherited Create(Application);

Android 6.01 is not happy about something in the forms?

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

I have fixed the old version of the CameraDemo by bypassing FImageStream as follows:

procedure TCameraView.CameraImageCapturedHandler(Sender: TObject; const AImageStream: TStream);
begin
// FImageStream.Clear;
// FImageStream.CopyFrom(AImageStream, AImageStream.Size);
// FCaptureImage.LoadFromStream(FImageStream);

FCaptureImage.LoadFromStream(AImageStream);

TabControl.ActiveTab := CaptureTab;
EnableButtons(True);
FAcceptImage.Visible := True;
FCameraSwapImage.Visible := False;
end;

I tried also add the Exposure setting but in the old version Fcamera.exposure is missing. I don't understand why this property is in the new version but not in the old version of the CameraDemo. I could find a definition of this exposure property. Where is this property created?

I'm pretty sure KastriFMX is causing problems in Android 6.0.1 but the debugger shows nothing.

Han

@han-k59
Copy link
Author

han-k59 commented Aug 21, 2022

As soon I add a TNativeSlider to the old application it crashes immediately after start.

Found Fcamera.exposure (ISO) in the latest DW.camera.pas under features.

@DelphiWorlds
Copy link
Owner

I'm pretty sure KastriFMX is causing problems in Android 6.0.1 but the debugger shows nothing

I've pushed a fix for the issue of the app crashing at startup. When the Delphi 11 project was updated, the Delphi 10.4 project was not.

I don't understand why this property is in the new version but not in the old version of the CameraDemo.

Because it was added to the new version. There are some problems with this property anyway - I haven't been able to get it to work quite right on Android. It works OK on iOS.

@han-k59
Copy link
Author

han-k59 commented Aug 22, 2022

I tried the new update. Application is started. But as soon I press the start button I get following error:
java.lang.NullpointerException: Attempt to invoke virtual method 'java.lang.Comparable android.utils.Range.getLower()' on a null object reference.

@DelphiWorlds
Copy link
Owner

I've now pushed a change that should resolve this error

@han-k59
Copy link
Author

han-k59 commented Aug 22, 2022

I have downloaded the latest code. Uninstalled/installed KastriFMX. As soon I click on the blue camera button it now crashes without any message at line 127:

FCamera.CaptureImage;

@han-k59
Copy link
Author

han-k59 commented Aug 22, 2022

Note the so called "exposure slider" was not visible in the app.

@DelphiWorlds DelphiWorlds added bug Something isn't working and removed question Further information is requested labels Aug 22, 2022
@DelphiWorlds
Copy link
Owner

Note the so called "exposure slider" was not visible in the app.

You need to tap the circle in the middle to show/hide the slider, as is necessary in the built in camera app on Android.

I have downloaded the latest code. Uninstalled/installed KastriFMX. As soon I click on the blue camera button it now crashes without any message at line 127:

Are you running the app via the debugger? Does the debugger just quit without any message?

I have a debugging tool called Device Lens, here, that might help resolve this issue. There's some basic instructions in the "Device Lens main window" section for how to filter for messages for the app you're running. In this case the package name will be com.embarcadero.CameraDemo

@han-k59
Copy link
Author

han-k59 commented Aug 23, 2022

  1. After clicking on the white circle the slider becomes visible. As soon I move the slider the android application crashes with "... has stopped." no debug log. The crash happen BEFORE code line FCamera.Exposure := ExposureSlider.Value;

  2. If I click on the blue camera button and step into DW.Camara.Android the application crashes at line 628: LRequestHelper.setIntegerValue(TJCaptureRequest.JavaClass.CONTROL_AE_MODE, TJCaptureRequest.JavaClass.CONTROL_AE_MODE_ON);

  3. This is not related to this problem but note the older CAMERADemos without KastriFMX work as long I convert the stream directly with CaptureImage.LoadFromStream(AImageStream);

  4. Device lens. Which SDK to select? Options are Android-19 up to Android-33 ????

Han

@DelphiWorlds
Copy link
Owner

Which SDK to select? Options are Android-19 up to Android-33 ????

From your description, it seems you have started the SDK installer, which you should not need to do if Delphi is already configured to use an SDK.

If you close Device Lens, go to the C:\Users\Public\Documents\DeviceLens folder and delete the AndroidConfig.json file, start Device Lens again and click on No when prompted - this will allow you to select the existing SDK that Delphi uses. It will be the same path as in the Delphi SDK Manager, e.g:

image

@DelphiWorlds
Copy link
Owner

DelphiWorlds commented Aug 23, 2022

I've pushed changes which may fix the latest issues. NOTE: If your camera does not support controlling exposure, the slider will now be disabled (i.e. you will not be able to change it) when making it appear. Unfortunately I do not have the same device as you are using, so I'm unable to fully test the changes.

@han-k59
Copy link
Author

han-k59 commented Aug 23, 2022

No success. It crashes now both on touching the white circle and blue camera button.

After touching the blue camera button it crashes in DW.Camera.Android.pas line 634:
LRequestHelper.setIntegerValue(TJCaptureRequest.JavaClass.CONTROL_AE_MODE, TJCaptureRequest.JavaClass.CONTROL_AE_MODE_ON);

I have added the SDK path to DeviceLens:
C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203
I assume it is required to select a device in DeviceLens but the button is greyed.

@han-k59
Copy link
Author

han-k59 commented Aug 23, 2022

I have tried with an other phone, Galaxy S7 64bit running Android 8.0.0. Exactly the same crashes when touching the white circle and blue camera button.

However if I test the CameraDemo version from yesterday, I can click on the white circle and move the slider for the first time. But the screen is too dark even at brightest setting.

Taking a picture with the software version from yesterday give this error:
Untitled2

In line Androidapi.JNIMarshal, line 872
PInteger(PResult)^ := JNIEnv^.GetStaticIntField(JNIEnv, JNIClass(InvokeData.Instance), InvokeData.MethodID);

Han

@DelphiWorlds
Copy link
Owner

Exactly the same crashes when touching the white circle and blue camera button.

I've pushed a change that should fix it

I assume it is required to select a device in DeviceLens but the button is greyed.

Yes, there should be devices listed on the left, if the device is connected to the machine and USB debugging is enabled on the device. Once a device is selected, a list of running processes should appear in the list to the right of the device list

But the screen is too dark even at brightest setting

As I indicated earlier, the exposure is problematic - something I'm still working out.

@han-k59
Copy link
Author

han-k59 commented Aug 24, 2022

Thanks. Now it works on my 64 bit phone (S7) Images are taken and displayed.

Hopefully you can fix the brightness slider for Android and maybe add exposure time. That would be great.

@DelphiWorlds
Copy link
Owner

You can follow this issue for progress on the exposure level. I'll create a separate one for exposure time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants