Jump to content

tomye

Members
  • Content Count

    47
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by tomye


  1. 14 hours ago, Rollo62 said:

    @tomye Thanks, thats a very interesting project.

    That makes Rockchip an interesting option, when it comes to neural networks.

    I assume that you run this project under Android.

    There are at least some boards in the market that come with Android naturally, are these boards supported by Delphi out-of-the-box,
    like a Samsung or Pixel phone, or do we need special drivers or other measures, drivers or modules to make it compatible?
     

    Maybe you can tell us also something about the hardware you used too, which would be needed to run that smoothly?

    I assume a Firefly board would be a good choice, but it seems also to be quite costly, about 200 -300 USD.

    https://en.t-firefly.com/doc/download/207.html

     

    While a Radxa Rock 5A is available from 22 USD, I would expect from the data that it has NPU too, perhaps there are some drawbacks for that price.

    https://radxa.com/products/rock5/5a/

     

    I have not checked where the differences in detail are, I assume both support the NPU in the same way, but I'm not an Rockchip expert.

    Maybe there are subtle differences in the Rockchip model code, which lead to biggers differences, which CPU model will be the most promising?

     

    Do you have recommendations for some capable Rockchip boards for testing, maybe there are many other boards than the two above,
    which are newer and more powerful, I'm not aware of.
     

    the rknn4Delphi only supports ROCKCHIP chip's products, the Android must be run under their chip then you can use the rknn4Delphi 

     

    i highly recommond the ORGANGEPI, see at http://www.orangepi.org/

     

    their product which is named Pi5B, only USD80, built-in rk3588s, has 3 cores of NPU and their Pi3B built-in rk3566 with single core of NPU only USD35

     

    https://item.taobao.com/item.htm?id=711193432489&pisk=g9fZbVThj5FN8X_PA_AqLFRKUGY6ZIr77stXoZbD5hxMfssVoEYrjfvMnwYHuHGbWCwvgi-FDh96ssWKgaQA1PdbWCQ9MIq7V7tVWNdYhJswxsRH-ET8GxcMSCd3fiHiJ7N5Wwu6Sz_3N19k4vYinjjDIpAHkHcmihjDtHY9xfYmsIx38HLDiFDMmvmHyEDMSnjmxBYXuVcMmhvH-FLwinjmsy7HvElMvsfZThJguGofCuDLydKlSHlma4LwIu7Zhjl2PFvNZZKFd91e7d-WpGoWN1jCo119p-D2Mw6P0tjYFvdNoOAMPNFZTQbGds8CGrM2jGCF-19EzbRNnGC2BOuYywAGvTKJIJEp811W33pExlbC8hvP3GZKih6P-MJ5ODGWMMBcmESnbgPqDe0JcsHEixJMJe-78yPvSj2ba-JoTxHvKyLeVzzrHxpGve-78ykxHpYJ83azz&spm=a1z10.1-c-s.w4004-23020891405.24.52168ec18wwe34&skuId=4983526316401

     

    O1CN01.thumb.png.0da497d1ac5ab8388477f6e0633a5d94.png

     


  2. On 1/17/2025 at 9:16 AM, bravesofts said:

    Resolving .idsig Issues in Delphi Android Apps

    Understand the .idsig File Role

    The .idsig file is generated during APK signing with APK Signature Scheme V2/V3.

    It ensures APK integrity. Deleting it forces fallback to legacy signing (V1).

    Update Your SDK Tools

    Use the latest Android SDK and Build Tools compatible with Delphi.

    Ensure Android SDK Build Tools 30.0.0 or higher is installed.

    Verify SDK paths in Tools > Options > SDK Manager.

    Prevent App Disappearance After Reboot

    Ensure consistent and trusted APK signing with a proper keystore.

    Avoid modifying the APK (e.g., deleting .idsig) after signing.

    Test on Multiple Devices

    Test your app on various devices and Android versions, focusing on 7.0 and above.

    Check for Manufacturer-Specific Issues

    Investigate device-specific forums for issues with customized Android versions.

    Use Logcat for Debugging

    Gather installation/runtime logs using:

    
    adb shell logcat | grep "com.yourCompany.yourAppName"

    Share the log file with us here for further analysis.

    *Always use at least Android SDK Build Tools 30.0.0 or higher to avoid outdated signing issues.*

     

    thank you , help me a lot 🙂

    • Like 1

  3. This issue has been troubling me for a long time. When developing Android applications with Delphi, a .idsig signature file is automatically generated after compilation. However, on some Android systems, this signature file is rejected. The APK can be installed, but it either fails to run or, after a system reboot, my app disappears. There are many problems like this. I can only delete the .idsig file to proceed with the installation, and in most cases, it works fine. However, occasionally, the app still disappears after the Android system reboots. How should I properly configure this .idsig file?


  4. On 12/28/2024 at 11:23 PM, Patrick PREMARTIN said:

    Hi.

    In your project, do you think an other language could have been better or Delphi was a good choice ?

    What's missing from the docs or the web in general that could have helped us go faster or more efficiently?

    I am 49 years old and have been using Delphi since 1999. I don't know any other programming languages—or rather, I should say that I have been deeply entrenched in Delphi's programming paradigm.

    I used to primarily develop client-server (C/S) projects, spending nearly 20 years writing code of this kind. Over time, I grew to dislike it. Fortunately, in recent years, I’ve had the opportunity to work more with hardware-related tasks, which means I no longer have to develop database or UI-related code. This change has made me very happy, and I really enjoy writing code that interacts with hardware.

    Since I develop products related to drones, I have to handle camera data streams and figure out how to transmit images to the ground. In recent years, the industry has increasingly relied on AI, so I’ve also added AI-related features to my work. It took me nearly two years to implement all these functionalities. In the end, I found that the programs I wrote in Delphi performed just as well as those written in native Android Java, and sometimes even better. When compared to C++ programs on Linux, Delphi's performance is slightly weaker, but I believe this gap comes from the operating system itself rather than being an issue with Delphi.

    My next step will be to try porting my current projects to Linux, even though I’ve never used Delphi to develop Linux applications before.

    • Like 2

  5. Developing mobile applications using Delphi is definitely feasible, but the resources available for reference are quite limited. If your project is focused on basic features like UI and database operations, it should work well. However, I recently completed an app related to video processing, which also integrates TensorFlow Lite for AI recognition and several trackers from OpenCV. The main features include:

    1. Hardware encoding with FFmpeg
    2. Hardware decoding with FFmpeg
    3. Streaming and receiving camera data
    4. Integration of a streaming server
    5. Embedding the KCF tracking algorithm
    6. Embedding OpenCV's built-in Nano tracker
    7. Embedding OpenCV's built-in ViT tracker
    8. Integration of the TensorFlow Lite inference framework

    These features took me over a year to complete.

    Next, I plan to integrate the RKNN inference framework from Rockchip and migrate the entire project to Linux.

    In conclusion, developing mobile applications with Delphi can be quite painful and challenging, requiring strong determination and patience.


  6. On 5/11/2024 at 4:05 AM, Dave Nottage said:

    I sincerely doubt that is the only way, however since you refuse to give a more complete example (not in a screenshot, and something that is sufficient to reproduce the issue), it's difficult to find an answer.

     

    Good luck

    finally, i solved the problem

     

    there is a file which is named AndroidManifest.template.xml

     

    i modified this code

    ...
    
        <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
    
    ...
    

    to 

    ...
    
        <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="30" />
    
    ...

     

    re-build and run , it does work now on D12


  7. i have known the reason.

     

    the isssue comes from the java sdk version, the high version (D11.2 to D12 used) doesn't support the current TFLite GPU delegate

     

    i copy the D11 PAClient to D12 and got an error message:

     

    [PAClient Error] Error: E7688 java.lang.UnsupportedClassVersionError: com/embarcadero/dexer/Main has been compiled

    by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

     

    At the time of Delphi release, it was bundled with the java sdk version

     

    the only way is i have to upgrade the TFLite GPU delegate ( libtensorflowlite_gpu_jni. so ) to high version, maybe it can be supported. 

     

    thank you for your all help


  8. 2 hours ago, Dave Nottage said:

    Your example is a bit light on details - how are all these defined?

     

    InterpreterOptionsAddDelegate

    InterpreterOptions

    GpuDelegate

    InterpreterCreate
    Model

     

    Regardless, have you used a logcat viewer to look for related messages (error, or otherwise)?

     

    i can't get detail error message, beacuase it calls .so library file

     

    p5.thumb.png.843ffbd06b643bdf2bce812d211b1633.png

     

    only return a nil object

     

    but it doesn't happen on D11

     

     

     

     


  9. I am using the inference library provided by Tensorflow Lite, and calling it in Delphi to implement AI inference

     

    Tensorflow Lite can support GPU inference well on mobile phones, greatly improving the inference speed
     

    CPU inference speed:

     

    p1.thumb.png.341245b3c30401dcc67ef00d99bceaa0.png

     

    GPU inference speed:

     

    p2.thumb.png.fb57001a634a2d2a29568a5852c543fb.png

     

     

    I call the libtensorflowlite_gpu_jni.so of Tensorflow Lite

      LibHandle := System.SysUtils.LoadLibrary(PWideChar('libtensorflowlite_gpu_jni.so')); 
    
      InterpreterOptionsAddDelegate := GetProcAddress(LibHandle, 'TfLiteInterpreterOptionsAddDelegate');

     

    And add a GPU delegate during program initialization

      InterpreterOptionsAddDelegate(InterpreterOptions, GpuDelegate);
    
      Interpreter := InterpreterCreate(Model, InterpreterOptions);

     

    The problem occurs here, before I used D11, the Interpreter can return an object pointer

     

    But after upgrading to D12, it will return a nil, unable to call the GPU, I also tried D11.2 and D11.3

     

    It's the same, all return a nil, only D11 can return an object pointer, and smoothly call the GPU on the phone

     

    I thought it might be caused by the upgrade of the Java SDK or NDK version, but after importing the Java SDK and NDK library used by D11, the problem still cannot be solved

     

    I am unfamiliar with Java, and in Delphi's SDK Manager, there seem to be only 3 SDK configurations, namely sdk, ndk, and jdk

     

    I don't know what these 3 SDKs represent, and I vaguely feel that the versions of these 3 libraries are not correct, causing my problem

     

    But I also tried to replace all 3 SDKs with the ones used by D11, and it still doesn't work
     

    During testing, I found a detail, I use the following code to call Toast

     

    unit Android.Toast;
    
    interface
    
    {$IFDEF ANDROID}
    
    uses
      FMX.Platform.Android,
      Androidapi.Helpers,
      Androidapi.JNIBridge,
      Androidapi.JNI.JavaTypes,
      Androidapi.JNI.GraphicsContentViewText;
    {$ENDIF}
    {$IFDEF ANDROID}
    
    type
      TToastLength = (LongToast, ShortToast);
    
      JToast = interface;
    
      JToastClass = interface(JObjectClass)
        ['{69E2D233-B9D3-4F3E-B882-474C8E1D50E9}']
        { Property methods }
        function _GetLENGTH_LONG: Integer; cdecl;
        function _GetLENGTH_SHORT: Integer; cdecl;
        { Methods }
        function init(context: JContext): JToast; cdecl; overload;
        function makeText(context: JContext; text: JCharSequence; duration: Integer)
          : JToast; cdecl;
        { Properties }
        property LENGTH_LONG: Integer read _GetLENGTH_LONG;
        property LENGTH_SHORT: Integer read _GetLENGTH_SHORT;
      end;
    
      [JavaSignature('android/widget/Toast')]
      JToast = interface(JObject)
        ['{FD81CC32-BFBC-4838-8893-9DD01DE47B00}']
        { Methods }
        procedure cancel; cdecl;
        function getDuration: Integer; cdecl;
        function getGravity: Integer; cdecl;
        function getHorizontalMargin: Single; cdecl;
        function getVerticalMargin: Single; cdecl;
        function getView: JView; cdecl;
        function getXOffset: Integer; cdecl;
        function getYOffset: Integer; cdecl;
        procedure setDuration(value: Integer); cdecl;
        procedure setGravity(gravity, xOffset, yOffset: Integer); cdecl;
        procedure setMargin(horizontalMargin, verticalMargin: Single); cdecl;
        procedure setText(s: JCharSequence); cdecl;
        procedure setView(view: JView); cdecl;
        procedure show; cdecl;
      end;
    
      TJToast = class(TJavaGenericImport<JToastClass, JToast>)
      end;
    var
      PToast:JToast;
    
    procedure Toast(const Msg: string; duration: TToastLength = ShortToast);
    
    {$ENDIF}
    
    implementation
    
    {$IFDEF ANDROID}
    
    uses
      FMX.Helpers.Android;
    
    
    procedure Toast(const Msg: string; duration: TToastLength);
    var
      ToastLength: Integer;
    begin
      if duration = ShortToast then
        ToastLength := TJToast.JavaClass.LENGTH_SHORT
      else
        ToastLength := TJToast.JavaClass.LENGTH_LONG;
      CallInUiThread(
        procedure
        begin
          //TJToast.JavaClass.makeText(SharedActivityContext, StrToJCharSequence(Msg),
            //ToastLength).show
          if not Assigned(PToast) then
            PToast:=TJToast.JavaClass.makeText(SharedActivityContext, StrToJCharSequence(Msg),
            ToastLength)
          else
          begin
            PToast.setDuration(ToastLength);
            PToast.setText(StrToJCharSequence(Msg));
          end;
          PToast.show;
        end);
    end;
    {$ENDIF}
    
    end.

     

    Using this Toast in D11, there is no icon displayed in the Toast prompt, but GPU can be called normally

     

    p3.thumb.png.123739a06cea7a772543d9efe275e017.png

     

     

    However, in D11.2, D11.3, and D12, when calling, an icon will automatically appear in the Toast prompt, but the GPU cannot be called
     

    p4.thumb.png.3f34dcdda50ab5e4a15b44926aba1c31.png

     

     

    From this phenomenon, it is inferred that the SDK version with the icon should be a higher version, that is, the higher version of the SDK cannot call the GPU

     

    So, how can I make D12 use a lower version of the SDK now (i believe the no icon version should be worked)?

    (I have tried specifying a lower version of the SDK in the SDK Manager, but the Toast still displays an icon and the GPU cannot be called)
     

     

     


  10. i worte a python script , it can be run on PyCharm very well

     

    but can not be run on P4D, always get an error:

     

    OSError: [WinError 182] The operating system cannot run  %1。 Error loading "C:\ProgramData\Miniconda3\envs\YoloV8\lib\site-packages\torch\lib\nvfuser_codegen.dll" or one of its dependencies.

     

    i found the nvfuser_codegen.dll and checked it all dependencies does exits, howevery if missing dependencies why i can run on PyCharm?

     

    image.thumb.png.6adb13de0a682f76075a52fb74968b45.png

     

    I have tried all the methods I can try, but they are all failed.

     

    anyone can help me ?

     


  11. 20 hours ago, pyscripter said:

    iOS is supported.

    For Android look at the Embarcadero fork.

    quick view the forked Android project, seems very complex, must use Delphi4Python ?

     

    and the iOS reference, i couldn't find anything about how to deploy  the Python on iOS, 

     

    just found some P4D FMX demos at https://github.com/pyscripter/python4delphi/tree/master/Demos/FMX

     

    these demos can be run on iOS ? thank you


  12. 12 hours ago, pyscripter said:

    Running python in threads does not increase python code speed due to the GIL.  Only one thread executes at any point in time.  Torch can do its own mutli-threading so again there is no need to use threads.    The main reason for using python threads is to avoid blocking the UI.

     

    Yes, Torch is much better than onnx, i have tested.

     

    yesterday, i droped the thread mode and create a new project without thread mode

     

    but still got this error:

     

    erro1.thumb.png.95fa8b93877102ecffd6971183b38a8b.png

     

    very strange, if i run the onnx script first and then run the torch script , then will get this error ,

     

    but if i run the torch script first and then run the onnx script , all are ok

     

    i think it should be an old version of CUDA dlls is called if the onnx script runs first and torch does not support this version

     

    but the onnxruntime supports the high version which the torch is used, that's why if i run the torch script first everything is ok. 

     


  13. On 10/31/2022 at 7:24 PM, shineworld said:

    Sincerely, I've used an embedded version of Python with minimal packages installed, and the required files are few.

    In Embarcadero GitHub repositories you can find a distro ready to be used.

    No anaconda, conda, or virtual environment.

    Just point to python dll with P4D and the joke is made.

     

    You can also avoid calling a pure py script ad use Embarcadero P4D-Data-Sciences,

    PythonEnvironments and Lightweight-Python-Wrappers and remain always on the Delphi project

     

    For markers detection, you can always extract the math and logic of FindContours HougCircles. etc from OpenCV sources,

    as suggested by the name they are open but you have to use something like to NumPy.

     

    I don't like re-invent the wheel when it is already done so I've discarded the idea to re-write all math in pure pascal code,

    although the related math (find counters, HougCircles, etc) is very simple, but very well implemented in OpenCV.    

     

    What they have done in embarcadero with P4D and related tools is very important and allows them not to reinvent hot water by going direct to the use of tools born for scientific purposes.

     

     

     

    dear shineworld, If you don't involve a lot of deep learning capabilities, i recommend the MITV Lab Packages, all are native compilation , does not need Python

     

    https://mitov.com/products/visionlab#overview


  14. 15 hours ago, pyscripter said:

    Why are you making things complicated?  Follow the KISS rule.   Using threads in this way requires deep knowledge of the Python API and the complexities of GIL.

     

    If do have to use threads, please study Demo  11  and the related posts in this forum Showing results for 'Py_Begin_Allow_Threads'. - Delphi-PRAXiS [en] (delphipraxis.net)  

     

    I don't want it to be that complicated either, but Python's performance is too low

     

    if i don't use thread to run , the speed and GPU useage % as below:

     

    p1.thumb.png.102de2694a4b0f1a54ab69d28e771f69.png

     

    if i lanuch 2 threads :

     

    p2.thumb.png.dbb996a39a96854daeb4e534ba13b74e.png

     

    if i lanuch 3 threads:

     

    p3.thumb.png.4103e9178d0a044f5fb4657071abc972.png

     

    single fps will be reduced but Avg fps will be raised if i use 3 threads

     

    so this is only way i can figure out to up the speed. 😞

     

    acutally, i have finished the thread mode program running in the past months

     

    but recently, i changed the AI engine from ONNX to TORCH, after installed pytorch

     

    everything becomes unsteady, but if i switch the pythone envirnoment to old path

     

    everything comes back , very steady.  i feel the issue comes from CUDA apis and CUDA envirnoment

     

    but i still can not find it out, so come here for help .  😞

     

     

     

     


  15. 9 hours ago, pyscripter said:

    PythonHome needs to be set even for registered conda distributions
     

    See TPythonVersion.AssignTo(PythonEngine: TPersistent); in PythonVersions.pas about this is done.

     

    Note also that for conda distributions to work properly,
    you need to add Format('%s;%0:s\Library\bin;', [Version.InstallPath]
    to your Windows path if it is not there already.

    i found this issue comes from the P4D thread mode

     

    i am not sure if it is P4D BUG because now i can run the script in P4D Demo01 after i PIP INSTALL PYSQLITE3,

    but still can not be run in my project, will raise an error:

     

    erro1.thumb.png.f0229dfa625ef4a7c86d6cedb2df9b13.png

     

    could not find cudnn_adv_infer64_8.dll or one of its dependent file

     

    the cudnn_adv_infer64_8.dll and all of its dependent files are existing 

     

    erro2.thumb.png.0b39052e7035dde8f262b2f27f72eb18.png

    as i said,  i set 

     

    TPythonThread.Py_Begin_Allow_Threads;

     

    in my code, and all running are in thread mode, i don't know if the Python path is lost in thread mode


  16. 7 hours ago, pyscripter said:

    Set AutoLoad to False and call LoadDLL at Runtime (e.g. in your FormCreate).

    Yes, i did , but does not work , so i post the question on here

     

    does the P4D not support LOADDLL and UNLOADDLL dynamic call ? 

     

    for example:

     

    i launch the exe and call the LoadDLL function at first time

     

    after run one script i need  reset a new DLL path and call LoadDLL again, 

     

    how to do like this? 


  17. 9 hours ago, pyscripter said:

    Is there another sqlite dll in your path?

    actually , i don't know why the torch uses the SQLite, however , i searched the DLL files, they are all there and all of them are 64bit

     

    error3.thumb.png.cbb9a03ff5170dc459b93cdcf21a35cb.png

     

    and this error message ( Not a valid win32 application ) is only appear on P4D Demo01, but in my project, there is another error message

     

    error4.thumb.png.0da1649ec713da7afafc69702a6cccee.png

     

    the error message is :  OSError: [WinError 127] The specified program could not be found

     

    same script i could run it in Python envirnoment, but can not be run in P4D , BTW, my project uses P4D thread mode ( TPythonThread.Py_Begin_Allow_Threads; )

     

    and then i test the script in P4D Demo01, got an another error message: Not a valid win32 application 😞

     

     

×