Jump to content

tomye

Members
  • Content Count

    40
  • Joined

  • Last visited

Everything posted by tomye

  1. tomye

    A question for thread reference

    actually, i have tried this, i convert an image to a byte array and send it to Python but i did not convert the byte array to Numpy array, that's why i can not get a good speed. at first, i thought can i send a POINT type to Python? if can then i can get a very fast speed, but failed 😞 BTW, what is the meaning of an overhead of cv2.imdecode ?
  2. tomye

    A question for thread reference

    thank you , i have done a test your way is almost 3 times faster than DEMO29, very good!
  3. tomye

    A question for thread reference

    Hi, shineworld would you like to write a simple demo for this transfer? ( transfer an image from delphi to python within 1ms) i have tried a several times but all failed 😞 thank you
  4. so cool ! your CNC machine is 5 Axis ?
  5. if your requirements is only simple opencv detection recommend the Mitov Lab Series, very strong, all native Delphi codes. includes video decoder / encoder , machine vision etc. https://mitov.com/products/visionlab
  6. it should be OK, my project needs cv2, onnxruntime etc. i just copy c:\programdata\anaconda3\lib\site-packages\cv2 ; c:\programdata\anaconda3\lib\site-packages\onnxruntime to {my project} \Libs\ and set the PyEngine.DLLPath to {my project}\Libs, that will be worked fine and the distribution as well
  7. tomye

    A question for thread reference

    Does it work? i found the error, comes from the wrong class inherited , it must inherited from TPythonThread not TThread it can be run now, but it can't improve efficiency , the speed is almost samed as single process i referred some posts , seems must use multiprocessing in Python to create new single process not threads it becomes very complicated because the P4D only supports one Python Engine process instance i have tried write a multi-process codes in Python scripts , but it will launch new Delphi application instance at same time so , your codes can be worked?
  8. tomye

    A question for thread reference

    i am glade to help you, for resolve the CPU execution efficiency issue in Python, i am trying use Delphi threads to run i think call 10 threads to process the detection scripts in Python , is it possible? but i found the PyEngine can not be worked in thread mode? the codes as below: TThreadDetect = class(TThread) public DT: TDetectedObjs; BMP: TBitmap; Img: TImage; protected procedure Execute; override; constructor Create(ABMP: TBitmap; AImg: TImage); destructor Destroy; override; end; procedure TThreadDetect.Execute; var v: Variant; begin inherited; DT.sTime:=GetTickCount; DT.Init(true); v := MainModule.ProcessImage(ImageToPyBytes(BMP)); // dead in here , no any response DT.FillObjsData(v,0,0); DT.DrawObjects(BMP.Canvas,1280); DT.eTime:=GetTickCount; DT.Elapsed:=DT.eTime-DT.sTime; //η”»εΈ§ηŽ‡ε’Œι€ŸεΊ¦δΏ‘ζ― DT.DrawSpeedInfo(BMP.Canvas,'NA',1280); FitDrawEx(Img,BMP); Img.Invalidate; end; do you know what i missed or wrong coding?
  9. tomye

    A question for thread reference

    I have a tip maybe can help , i don't know if it does work for you i found Complex types such as objects , numpy array etc. will spend more time to transfer i just use the simplest type. STRING, there are no other P4D components in my project, only one PyEngine i don't know whether it is right or not, but it does work and the speed is OK var v: Variant; v := MainModule.ProcessImage(ImageToPyBytes(BMP)); the BMP is a TBitmap object, it's a video frame, the V returns a object type which i defined in Python, but here i access it as STRING type, very simple and fast IDs : = v.IDs; Names := v.Names; ... i think maybe you can encode the frame data to STRING in Python and send it back to Delphi i have tested the FPS, almost fall down < 2 fps , it is acceptable for me. but my problem is the Python script execution efficiency is too poor, that's why Python people always said YOU MUST RUN NEURAL NETWORK PROGRAMS ON GPU 😞
  10. tomye

    A question for thread reference

    thanks for your help is there any way to improve CPU's usage rate in Python? for example , now i run the script in Python, the CPU is only used 40% can i add some codes or other ways let the CPU's usage rate up to 90%+ ? using multi-threading maybe is a solution, but it is too complicated because one second has 25 frames, i can detect these 25 frames at same time if using multi-threading but after processed there are too many things need to do , difficult to control to be steady
  11. tomye

    Python DLL Init question

    my environment is win7 , python version is 3.8 (x64) and D11 the installation of P4D was quite well but run the first DEMO (demo1), nothing happened and i tried to add a code on engine beforeload PythonEngine1.SetPythonHome(PythonEngine1.DllPath); it works, someone knows why the P4D cannot load the python automatically? or the OS must be win10 above?
  12. tomye

    Python DLL Init question

    thank you , i will check
  13. tomye

    Data exchange between Delphi and SciKit Learn

    does P4D support real Object transfer? for example we define a class in Python, it includes some data types of list , array, bytes stream etc. and it could be returned to Delphi then we can use the Object in Delphi with all data which are under the object.
  14. tomye

    Transferring TBitmap to Python and back

    it does work, thank you guy BTW, my idea for my project is , i use FFMpeg engine on DELPHI to open any formatted video media , includes every frames of these video and send the frame (it's an image actually) to PYTHON, the python codes will run the neural network algorithm and calculate the result and then these results will be sent back to DELPHI (results are arrays data ) , then i can draw the result on bitmap and show it to users. in the passed of months, i even don't know the P4D, so i spent a lot of time to do other ways , all failed until find this forum. seems just spending a couple of times it might be successful, but i don't know how to return arrays to DELPHI at now, do you have any samples? i defined these arrays in Python like this: does the P4D support it sending to DELPHI ? best regards
  15. tomye

    Transferring TBitmap to Python and back

    don't know much about your project, but i have same problem with you, my thinking is DELPHI just send an image to Python, after the running, Python sending back not an Image just an array data if it works well then it will resolve a big problem of mine, because i am doing a machine vision, using neural network, as we know the DELPHI is so weak on this kind of field, it's not DELPHI's problem as Python is too hot now, everything are around of Python actually, i feel the Python grammar is not good for me, it's too unprecise, i can't fit it. however, i met a strange exception, i am testing it on DEMO29 too, but got an error after the fist pressing of the button why i said it was strange because when i click the "Execute" button again, everything was OK do you have this problem?
Γ—