Jump to content

shineworld

Members
  • Content Count

    282
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by shineworld


  1. Some type like this? 

    PS: IsEqualIntegerDynArray placed in method just to test.

    procedure TGCodeEditor.SetGCodeLinePoints(Value: TIntegerDynArray);
    
      function IsEqualIntegerDynArray(const A, B: TIntegerDynArray): Boolean;
      begin
        if Length(A) <> Length(B) then Exit(False);
        Result := CompareMem(@A[0], @B[0], Sizeof(Integer) * Length(A));
      end;
    
    begin
      if not IsEqualIntegerDynArray(FGCodeLinePoints, Value) then
      begin
        FGCodeLinePoints := Value;
        Invalidate;
      end;
    end;

     


  2. That is what I've used....

    procedure TGCodeEditor.SetGCodeLinePoints(Value: TIntegerDynArray);
    var
      F: Boolean;
      L: Integer;
    begin
      F := False;
      L := Length(Value);
      if (Length(FGCodeLinePoints) > 0) and (Length(FGCodeLinePoints) = L) then
        F := CompareMem(@FGCodeLinePoints[0], @Value[0], Sizeof(Integer) * L);
      FGCodeLinePoints := Value;
      if not F then
        Invalidate;
    end;

     


  3. DelphiVCL implements a good subset of VCL objects and related methods/properties/events.
    You can find full Embarcadero VCL documentation on the net: https://docwiki.embarcadero.com/
     

    To know what objects methods/properties/events are implemented and available in DelphiVCL python unit 
    there are two ways (that I know):

    1] Look at sources of P4D in github.
    2] Inspect imported module and every class you want to use:

    Example to inspect VCL objects and Form object:

    P:\>python
    Python 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> import delphivcl as vcl
    >>> dir(vcl)
    ['Abort', 'Action', 'ActionList', 'ActivityIndicator', 'Application', 'BaseBindScopeComponent', 'BaseLinkingBindSource', 
    'BaseObjectBindSource', 'BasicAction', 'BasicBindComponent', 'Bevel', 'BindComponentDelegate', 'BindingsList', 'BitBtn', 
    'Bitmap', 'BoundLabel', 'Button', 'Canvas', 'CheckBox', 'Collection', 'ColorBox', 'ComboBox', 'Component', 'ContainedAction', 
    'ContainedActionList', 'ContainedBindComponent', 'Control', 'ControlBar', 'CreateComponent', 'CustomAction', 'CustomActionList', 
    'CustomActivityIndicator', 'CustomBindingsList', 'CustomControl', 'CustomDrawGrid', 'CustomEdit', 'CustomForm', 'CustomGrid', 
    'CustomLinkControlToField', 'CustomLinkListControlToField', 'CustomLinkPropertyToField', 'CustomMemo', 'CustomNumberBox', 
    'CustomPrototypeBindSource', 'CustomStyleServices', 'CustomTabControl', 'CustomToggleSwitch', 'DateTimePicker', 'DelphiDefaultContainer', 
    'DelphiDefaultIterator', 'DelphiMethod', 'DrawGrid', 'Edit', 'FileOpenDialog', 'Form', 'FreeConsole', 'Graphic', 'GroupBox', 
    'Header', 'IDABORT', 'IDCANCEL', 'IDCLOSE', 'IDCONTINUE', 'IDHELP', 'IDIGNORE', 'IDNO', 'IDOK', 'IDRETRY', 'IDTRYAGAIN', 'IDYES', 
    'Icon', 'Image', 'Label', 'LabeledEdit', 'LinkControlDelegate', 'LinkControlToField', 'LinkControlToFieldDelegate', 
    'LinkListControlToField', 'LinkPropertyToField', 'LinkPropertyToFieldDelegate', 'ListBox', 'MB_ABORTRETRYIGNORE', 'MB_APPLMODAL', 
    'MB_DEFBUTTON1', 'MB_DEFBUTTON2', 'MB_DEFBUTTON3', 'MB_DEFBUTTON4', 'MB_HELP', 'MB_ICONASTERISK', 'MB_ICONERROR', 'MB_ICONEXCLAMATION', 
    'MB_ICONHAND', 'MB_ICONINFORMATION', 'MB_ICONQUESTION', 'MB_ICONSTOP', 'MB_ICONWARNING', 'MB_NOFOCUS', 'MB_OK', 'MB_OKCANCEL', 
    'MB_RETRYCANCEL', 'MB_SYSTEMMODAL', 'MB_TASKMODAL', 'MB_YESNO', 'MB_YESNOCANCEL', 'MainMenu', 'MediaPlayer', 'Memo', 'Menu', 'MenuItem', 
    'Metafile', 'Monitor', 'Notebook', 'NumberBox', 'Object', 'OpenDialog', 'Page', 'PageControl', 'PaintBox', 'Panel', 'PascalInterface', 
    'PascalRecord', 'Persistent', 'Picture', 'Point', 'PopupMenu', 'PrototypeBindSource', 'RadioButton', 'RadioGroup', 'Rect', 'Screen', 
    'ScrollBar', 'Shape', 'ShowMessage', 'Size', 'SpeedButton', 'SpinButton', 'SpinEdit', 'Splitter', 'StaticText', 'StringGrid', 'Strings', 
    'StyleInfo', 'StyleManager', 'StyleServices', 'TabControl', 'TabSheet', 'Timer', 'ToggleSwitch', 'ToolBar', 'ToolButton', 'TrackBar', 
    'VarParameter', 'WinControl', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'bkAbort', 'bkAll', 'bkCancel', 
    'bkClose', 'bkCustom', 'bkHelp', 'bkIgnore', 'bkNo', 'bkOK', 'bkRetry', 'bkYes', 'caFree', 'caHide', 'caMinimize', 'caNone', 'cl3DDkShadow',
     'cl3DLight', 'clActiveBorder', 'clActiveCaption', 'clAppWorkSpace', 'clAqua', 'clBackground', 'clBlack', 'clBlue', 'clBtnFace', 
     'clBtnHighlight', 'clBtnShadow', 'clBtnText', 'clCaptionText', 'clCream', 'clDefault', 'clDkGray', 'clFuchsia', 'clGradientActiveCaption', 
     'clGradientInactiveCaption', 'clGray', 'clGrayText', 'clGreen', 'clHighlight', 'clHighlightText', 'clHotLight', 'clInactiveBorder', 
     'clInactiveCaption', 'clInactiveCaptionText', 'clInfoBk', 'clInfoText', 'clLime', 'clLtGray', 'clMaroon', 'clMedGray', 'clMenu', 'clMenuBar', 
     'clMenuHighlight', 'clMenuText', 'clMoneyGreen', 'clNavy', 'clNone', 'clOlive', 'clPurple', 'clRed', 'clScrollBar', 'clSilver', 'clSkyBlue',
     'clTeal', 'clWhite', 'clWindow', 'clWindowFrame', 'clWindowText', 'clYellow', 'fsBorder', 'fsSurface', 'gdFixed', 'gdFocused', 'gdSelected',
     'mdNearest', 'mdNull', 'mdPrimary', 'mrAbort', 'mrAll', 'mrCancel', 'mrIgnore', 'mrNo', 'mrNoToAll', 'mrNone', 'mrOk', 'mrRetry', 'mrYes', 
     'mrYesToAll', 'ssAlt', 'ssCtrl', 'ssDouble', 'ssLeft', 'ssMiddle', 'ssRight', 'ssShift']
    
    >>> form = vcl.Form(None)
    >>> dir(form)
    ['Action', 'Active', 'ActiveControl', 'ActiveMDIChild', 'ActiveOleControl', 'AfterConstruction', 'Align', 'AlignDisabled', 'AlignWithMargins',
     'AlphaBlend', 'AlphaBlendValue', 'Anchors', 'ArrangeIcons', 'Assign', 'AutoScroll', 'AutoSize', 'BeforeDestruction', 'BeginDrag', 'BeginInvoke',
     'BiDiMode', 'BindMethodsToEvents', 'BorderIcons', 'BorderStyle', 'BorderWidth', 'BoundsRect', 'BringToFront', 'Broadcast', 'Brush', 'CPP_ABI_1',
     'CPP_ABI_2', 'CPP_ABI_3', 'CanFocus', 'Canvas', 'Caption', 'Cascade', 'CheckNonMainThreadUsage', 'ClassInfo', 'ClassName', 'ClassNameIs', 
     'ClassParent', 'ClassType', 'CleanupInstance', 'ClientHandle', 'ClientHeight', 'ClientOrigin', 'ClientRect', 'ClientToParent', 'ClientToScreen',
     'ClientWidth', 'Close', 'CloseQuery', 'Color', 'ComObject', 'ComponentCount', 'ComponentIndex', 'ComponentState', 'ComponentStyle', 'Components',
     'Constraints', 'ContainsControl', 'ControlAtPos', 'ControlCount', 'ControlState', 'ControlStyle', 'Controls', 'Create', 'CreateNew', 'CreateParented',
     'CreateParentedControl', 'Ctl3D', 'CurrentPPI', 'Cursor', 'CustomHint', 'CustomTitleBar', 'DefaultHandler', 'DefaultMonitor', 'DefocusControl',
     'DesignInfo', 'Designer', 'Destroy', 'DestroyComponents', 'Destroying', 'DisableAlign', 'DisableAutoRange', 'Dispatch', 'DisposeOf', 'Dock',
     'DockClientCount', 'DockDrop', 'DockManager', 'DockOrientation', 'DockSite', 'DoubleBuffered', 'DragDrop', 'DragKind', 'DragMode', 'Dragging',
     'DrawTextBiDiModeFlags', 'DrawTextBiDiModeFlagsReadingOnly', 'DropTarget', 'EnableAlign', 'EnableAutoRange', 'Enabled', 'EndDrag', 
     'EndFunctionInvoke', 'EndInvoke', 'Equals', 'ExecuteAction', 'ExplicitHeight', 'ExplicitLeft', 'ExplicitTop', 'ExplicitWidth', 'FieldAddress',
     'FindChildControl', 'FindComponent', 'FlipChildren', 'Floating', 'FloatingDockSiteClass', 'FocusControl', 'Focused', 'Font', 'FormState',
     'FormStyle', 'Free', 'FreeInstance', 'FreeNotification', 'FreeOnRelease', 'GetChildren', 'GetControlsAlignment', 'GetEnumerator', 'GetFormImage', 
     'GetHashCode', 'GetInterface', 'GetInterfaceEntry', 'GetInterfaceTable', 'GetNamePath', 'GetParentComponent', 'GetStyleName', 'GetSystemMetrics', 
     'GetTabControlList', 'GetTabOrderList', 'GetTextBuf', 'GetTextLen', 'GlassFrame', 'Handle', 'HandleAllocated', 'HandleNeeded', 'HasParent', 'Height',
     'HelpContext', 'HelpFile', 'HelpKeyword', 'HelpType', 'Hide', 'Hint', 'HorzScrollBar', 'HostDockSite', 'Icon', 'InheritsFrom', 'InitInstance', 
     'InitiateAction', 'InsertComponent', 'InsertControl', 'InstanceSize', 'Invalidate', 'IsCustomStyleActive', 'IsDrawingLocked', 'IsImplementorOf',
     'IsLightStyleColor', 'IsRightToLeft', 'IsShortCut', 'KeyPreview', 'LRDockWidth', 'Left', 'LoadProps', 'LockDrawing', 'MDIChildCount',
     'MakeFullyVisible', 'ManualDock', 'ManualFloat', 'Margins', 'Menu', 'MethodAddress', 'MethodName', 'ModalResult', 'Monitor', 'MouseInClient', 
     'MouseWheelHandler', 'Name', 'NewInstance', 'Next', 'ObjectMenuItem', 'Observers', 'OleFormObject', 'OnActivate', 'OnAfterMonitorDpiChanged', 
     'OnAlignInsertBefore', 'OnAlignPosition', 'OnBeforeMonitorDpiChanged', 'OnCanResize', 'OnClick', 'OnClose', 'OnCloseQuery', 'OnConstrainedResize',
     'OnContextPopup', 'OnCreate', 'OnDblClick', 'OnDeactivate', 'OnDestroy', 'OnDockDrop', 'OnDockOver', 'OnDragDrop', 'OnDragOver', 'OnEndDock',
     'OnGesture', 'OnGetSiteInfo', 'OnHelp', 'OnHide', 'OnKeyDown', 'OnKeyPress', 'OnKeyUp', 'OnMouseActivate', 'OnMouseDown', 'OnMouseEnter',
     'OnMouseLeave', 'OnMouseMove', 'OnMouseUp', 'OnMouseWheel', 'OnMouseWheelDown', 'OnMouseWheelUp', 'OnPaint', 'OnResize', 'OnShortCut', 'OnShow', 
     'OnStartDock', 'OnUnDock', 'Owner', 'Padding', 'PaintTo', 'Parent', 'ParentBiDiMode', 'ParentCustomHint', 'ParentDoubleBuffered', 'ParentFont',
     'ParentToClient', 'ParentWindow', 'Perform', 'PixelsPerInch', 'PopupMenu', 'PopupMode', 'PopupParent', 'Position', 'PreProcessMessage', 'Previous',
     'Print', 'PrintScale', 'QualifiedClassName', 'Realign', 'RecreateAsPopup', 'RedrawDisabled', 'ReferenceInterface', 'Refresh', 'Release', 
     'RemoveComponent', 'RemoveControl', 'RemoveFreeNotification', 'Repaint', 'ReplaceDockedControl', 'SafeCallException', 'ScaleBy', 'ScaleFactor',
     'ScaleForCurrentDPI', 'ScaleForPPI', 'ScaleRectSize', 'ScaleValue', 'Scaled', 'ScreenSnap', 'ScreenToClient', 'ScrollBy', 'ScrollInView',
     'SendCancelMode', 'SendToBack', 'SetBounds', 'SetDesignVisible', 'SetFocus', 'SetFocusedControl', 'SetParentComponent', 'SetProps', 'SetSubComponent',
     'SetTextBuf', 'Show', 'ShowHint', 'ShowModal', 'Showing', 'SnapBuffer', 'StyleElements', 'StyleName', 'TBDockHeight', 'TabOrder', 'TabStop', 'Tag',
     'TaskbarHandler', 'Tile', 'TileMode', 'TipMode', 'ToList', 'ToString', 'ToTuple', 'Top', 'Touch', 'TransparentColor', 'TransparentColorValue',
     'UndockHeight', 'UndockWidth', 'UnitName', 'UnitScope', 'UnlockDrawing', 'Update', 'UpdateAction', 'UpdateControlState', 'UpdateDesignerCaption',
     'UseDockManager', 'UseRightToLeftAlignment', 'UseRightToLeftReading', 'UseRightToLeftScrollBar', 'VCLComObject', 'VertScrollBar', 'Visible',
     'VisibleDockClientCount', 'WantChildKey', 'Width', 'WindowMenu', 'WindowProc', 'WindowState', '__bound__', '__dir__', '__owned__', 'set_PopupParent']
    >>>

     


  4. 3 hours ago, Rollo62 said:

    @shineworld

    Do you know any more recent repository where the sources were maintained ?

     

    Sincerely I don't know where to find a more updated code.

    I use it for years and for what I need works fine so never tried more updated versions.


  5. In my projects, I use dxgettext with PoEdit pro, which creates an internal net DBase of translated terms,

    so any old translation, made by me or my colleagues can be fastly re-used.
    It also permits auto-translations using Microsoft Translation tools, Deepl (if you have a pro account), etc.

    image.thumb.png.999cc7920a3e1b67c23acc275a4cfca9.png

    It has also a free version so end-customers can translate the programs to their native language with total autonomy,

    because gettext translations are in extern .mo files (but can also be embedded in the EXE if you want).


  6. Thanks for the suggestion I will go and look at it.

    There is another aspect behind the scenes about the choice to use Python.
    In the whole office the only one who uses and knows Delphi and object pascal is me, while my colleagues have been using Python for support projects for a long time already, so creating a framework that is based on Python + extra extensions made ad hoc with Delphi allows me to relieve myself from future work on the Vision compartment to devote myself to something else.

    This is the reason why, when I can, I prefer to create tools that others use and not take a complete, specific project all the way through.

     

    My mathematical background, compared to that of some of the team members, is basic, and they in python will surely be able to solve more elegantly and efficiently cases where my limitations will only get in the way.


  7. 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.

     

     


  8. Yes, I've used OpenCV features to detect markers but my CNC Vision framework is born and designed to do more other.

    I'm already working on a system which use TensorFlow for more complex image objects detection where Delphi will do things hard to do natively in python.


  9. This, I believe, is due to the fact that the IDE developers, in order to keep the huge amount of threads, timers, etc. needed by the development environment more responsive, have forced the Windows timeCAPS down from the default values (about 50ms) to the lowest possible values, so as to achieve greater accuracy in the timers.

    Some time ago I wasted a lot of hours on this myself.
    I used to run a program from IDE and it was faster than when IDE was not active in memory. As long as it was active, any program would run better, even if not launched from it.

    From here I realized that the IDE was changing something in the operating system.
    I tried to make a program that read timeCAPS with IDE active (they are system and not process) and with IDE active it gave me 1ms, without IDE active 50ms 🙂

    In my applications I force too, obtaining the same times (precision) of timeGetTime and GetTickCount or precision in TThread.Sleep when I run WITH IDE in run o without IDE:

    uses
    	MMSystem;
    
    ; use this option to disable the force of timer precision
    {$DEFINE USES_TIME_BEGIN_END_PERIOD}
    
    var
    {$IFDEF USES_TIME_BEGIN_END_PERIOD}
      TimeCaps: TTimeCaps;
      NeedToChangeTimerPrecsion: Boolean;
    {$ENDIF}
      ... other global values
    
    
    procedure PrecisionTimersStart:
    begin
    {$IFDEF USES_TIME_BEGIN_END_PERIOD}
        // starts high precision timer
        if timeGetDevCaps(@TimeCaps, SizeOf(TTimeCaps)) = TIMERR_NOERROR then
          NeedToChangeTimerPrecsion := timeBeginPeriod(TimeCaps.wPeriodMin) = TIMERR_NOERROR;
    {$ENDIF}
    end;
    
    procedure PrecisionTimersEnd:
    begin
    {$IFDEF USES_TIME_BEGIN_END_PERIOD}
        // stops high precision timer
        if NeedToChangeTimerPrecsion then
          timeEndPeriod(TimeCaps.wPeriodMin);
    {$ENDIF}
    end;
    


    Just call PrecisionTimersStart at program START, eg in dpk code, and call PrecisionTimersStop when the program ends.


  10. I could easily be proven wrong; I haven't looked into this very deeply, but from what I make of the 32- and 64-bit versions of the applications, it seems to me that the 64-bit version gains a few percent in performance.
    The projects are complex and use a lot of memory and graphics, including 3D, but running both exe's, the 64-bit one gives me a better time log.

    Debugging in 64-bit, however, is more difficult because of constant IDE crashes (10.4.1 at the moment).

     


  11. My 10 cents...

    I have currently abandoned the idea of using FreePascal with x86/x64 Linux environments

    pending how Delphi's native support for Linux will evolve.


    Since I have the professional version, which does not support Linux, I am waiting to see in the next versions

    what will happen on ARM support, and whether to migrate to the fuller version and update my entire dev system (at moment is 10.4.1).

    For embedded, ARM-based Linux systems, Freepascal + Lazarus is currently a solution that I use occasionally, and although

    it is very limited compared to Delphi it keeps me in a fairly well-known language/library.

    LCL is not comparable to VCL but for small things in the hostile world of ARM, it may be okay for the time being.
     


  12. IMO: I've tried to run, after some changes because two languages are not fully compatible, a Delphi program to Lazarus, for Windows (my idea is to move some apps to Linux).
    The performances of Lazarus compiled code are lower than Delphi compiled.

    I've tried to move GLScene so 3D UI with bad results when compared, but working.

    I've never tried then to move it to Linux using FreePascal.


  13. So the question is ?
    Do you want to run the script using only python + delphivcl and send image to its TImage,

    or run the script inner a Delphi application, which "share" a TImage object exposed as custom python module so the script place image elaboration

    result on that ?
     


  14. We need to know the structure of all.
     

    1] A Delphi program which call a Python Script?
    2] The python script that captures/elaborates image in an infinite loop?
    3] The python script that sends back the elaborated image?

    It is hard to reply to your question without knowing your project structure.


  15. OpenCV's video source backends (CAP_MSMF and CAP_DSHOW) are rather limited and chaotic in CAP properties.
    Often CAP_MSMF raises internal exceptions, although recommended over CAP_DSHOW.
    For example, there is no way, unless you get your hands on the code, to directly access the webcam driver supported properties list and range/defaults, which the backend retrieves internally anyway.

    If you use Python solely to capture a video stream better to act directly with the Windows DirectShow or similar new interfaces.

    There are examples of how to do this in github.


  16. I still have a lot of 32-bit applications and often found myself with memory problems because of the 2GB maximum limitation per project.

    By keeping the application 32-bit you can add another GB to the available ram via FASTMM4 using {$SetPEFlags $20}.

    Example:
     

    program myprogram;
    
    uses
        {$IFDEF CPUX86}
          {$SetPEFlags $20}
        {$ENDIF}
        FastMM4 in 'sources\memory-managers\FastMM4-4.992\FastMM4.pas',
        FastMM4Messages in 'sources\memory-managers\FastMM4-4.992\FastMM4Messages.pas',
        ...projects files

    I'm using wonderful FastMM4 from pleriche:
    https://github.com/pleriche/FastMM4

     

    Intervention in the code is as simple as checking whether there are actual benefits to the application.
    In my case SynEdit without {$SetPEFlags $20} and FastMM can load 1.5 million lines but with the patch can reach 4 million lines. 


    That application gain per-processes extra memory when executed on a 64-bit windows OS.

    https://stackoverflow.com/questions/1849344/how-can-i-enable-my-32-bit-delphi-application-to-use-4gb-of-memory-on-64-bit-win
     


  17. On 10/6/2021 at 10:04 AM, Lars Fosdal said:

    I want ARM/Linux support for Raspberry PI.

    I would like to have a Delphi version to work with ARM/Linux overall on Raspberry PI and clones.

    In industry, a lot of embedded ARM-based SOMs are developed with C++ or Python (QT on under the hood), overall for UI parts, but Delphi power could change the trends. 
    I've tried FreePascal + Lazarus but is very messy...

    • Like 3
×