Jump to content

BennieC

Members
  • Content Count

    30
  • Joined

  • Last visited

Everything posted by BennieC

  1. BennieC

    Error Message after Update to 11.2

    I have the same problem but still have a problem after removing the file. Compiler now can't find the AndroidManifest.xml in the location. How do I restore this.
  2. BennieC

    bitmap to jpeg compression

    Hi, I have been trying to compress bitmaps to jpegs into a database to save space. However, I cannot get the codec to perform the compression. My code looks as follows var NewBitmap: TBitmap; CodecParams : TBitmapCodecSaveParams; MS1 : TMemoryStream; Surf: TBitmapSurface; JpgQuality : TBitmapCodecSaveParams; code snippet JpgQuality.Quality := 100; MS1.Position := 0; Surf := TBitmapSurface.create; try Surf.assign(NewBitmap); // use the codec to save Surface to stream if not TBitmapCodecManager.SaveToStream( MS1, Surf, // '.jpg', JpgQuality) then // THIS DOES NOT WORK '.jpg') then // THIS DOES WORK BUT NO COMPRESSION (FORMAT MAY NOT EVEN BE JPEG) raise EBitmapSavingFailed.Create( 'Error saving Bitmap to jpg'); finally Surf.Free; end;
  3. BennieC

    Listview Programming

    Good day I am trying to build an application which requires me to display multiple images in groups with selectable sizes. The images consist of a bitmap and a text field. My idea is to put the image groups in a TListview (Which I hope can display horizontally) and then add these listview groups into a TFlowlayout to manage the screen layout. However, I simply do not get it right to create a TListview item programmatically to display the image. I have tried to create a TListItemImage as well as simply adding a TListViewItem but neither worked in that I could see anything on the screen. I am including my test code (Note it pulls images from a folder for testing). The commented out sections will probably indicate some of the experiments that I tried. I will probably also struggle to add the TListviews to the TFlowlayout. Some advice will be much appreciated. The idea is that the application will run on both Android mobile as well as desktops. prjFlowLO.dpr prjFlowLO.dproj uFlowLOMain.fmx uFlowLOMain.pas
  4. BennieC

    Listview Programming

    I have now used frames and a vertscrollbox and indeed it works well. (Even struggled through the French way of doing it) I would like to use a flow layout and have inserted that into the scrollbox. This seems to work better than me calculating object position as I would have to do in the scrollbox. I do however have a problem with the flowlayout when anchored to the right of the scrollbox and have posted a separate question on that.
  5. BennieC

    TFlowLayout in TVertScrollbox

    I want to use the flowlayout (In a vertscrollbox) where the width can be varied when application changes size. The number of items will overflow to the bottom, hence the scrollbox. When using a flowlayout on its own (anchored to the right of the form), stretching the width results in a proper re-layout. However if it is in a scroll box (anchored to the right) it seems to miscalculate the width and allows objects to overflow to the right, but only when I anchor the flowlayout to the right of the scrollbox. If it is not anchored to the scrollbox it works correctly but of course does not stretch with the form. Does anyone have any ideas?
  6. BennieC

    Listview Programming

    Indeed, the list items will be created during run time. We have no dataset.
  7. Hi, I have a Delphi application that calls OpenCV via Python4Delphi. It returns a tuple of floating point values in Python. However when I return the tuple to Delphi I get a string variable. Is there a way to force the conversion to maintain the floating point values. I managed to parse the string list in Delphi into a floating point array but the application should be in real time so this is an unnecessary step. In Python In Delphi Regards
  8. BennieC

    Returning lists from Python to Delphi

    @pyscripter I have used your structure but still Delphi insist on giving me strings instead of floating point values. Can I somehow force the variant conversion to take this as a float? I have tried to assign the variant to single variable but have no luck. Regards I have tried assigning the variant to a single but get no joy. What does work is if I convert it to a single. var ConfValue:variant := aRectItm.GetItem(classCnt); ConfSingle := strtofloat(ConfValue);
  9. BennieC

    Returning lists from Python to Delphi

    @pyscripter I have used your structure but still Delphi insist on giving me strings instead of floating point values. Can I somehow force the variant conversion to take this as a float? I have tried to assign the variant to single variable but have no luck. Regards
  10. BennieC

    Returning lists from Python to Delphi

    @pyscripter Thank you. Indeed the layerOutputs is a variant and I am using VarPyth. However, using your syntax I seem to have made progress. Could you please explain the syntax as I am not familiar with that. Also, how do I declare a variable in a loop using the inline var statement? Kind regards
  11. BennieC

    Returning lists from Python to Delphi

    @SwiftExpat Thanks for the response. Regarding the bottleneck , the processing is requires the parsing of 507 + 2028 (and possibly an additional 8000) items, each consisting of 41 values (Yolo output) This has to happen in less than 10ms in order to stay within real time, or as close to that as possible. Regarding the code - my current attempt looks as follows (It does get the correct values out but takes about 500ms) aRectItmStr := aRectList.GetItem(rectCnt); // Get a rect , should have 41 values // It looks like this is a single string // Remove unnecessary spaces, linefeeds and brackets // Some records have long spaces while containstext(aRectItmStr, ' ') do aRectItmStr := StringReplace(aRectItmStr, ' ', ' ', [rfReplaceAll]); // Repeat until only single spaces exist aRectItmStr := StringReplace(aRectItmStr, '[', '', [rfReplaceAll]); aRectItmStr := StringReplace(aRectItmStr, ']', '', [rfReplaceAll]); aRectItmStr := StringReplace(aRectItmStr, #$A, '', [rfReplaceAll]); // #=numerical code, $=Hexdecimal aListArray := aRectItmStr.Split([' ', '''']); for i := 0 to MIN(length(aListArray), 41)-1 do aRectItmVals := strtofloatdef(aListArray, 0.0); I know this is probably inefficient but it would help a lot if i can just read the items as a n array of float values. Kind regards
  12. BennieC

    Returning lists from Python to Delphi

    Thank you for this - it does seem to be the right way to go as my current string parsing is far too slow. However I have no idea how to use either of the two options. In the Buffer protocol, how do I return my result which seems to be a list of arrays. at present the return value is just the tuple which in Python looks like this: Name: layerOutputs Type: tuple Value: (array([[0.09, 0.03, 0.34...0.]]. dtype=float32), array([[0.06, 0.05, 0.67...0.]]. dtype=float32)) Currently this is just returned as a value with name layerOutputs, but Delphi sees this as a character string In the MemShare solution - how do I determine the memory position in Python and how do I determine the memory structure to use the binary representation. Are there any resources you can point me to as I am at a complete loss/
  13. I am struggling with getting my results into Delphi. I have used direct access to the Python function as shown in the screencopy and in fact receive the correct results in Delphi using Code insight as shown. But I have no success in actually accessing this tuple from Delphi There are three items in the tuple (which is declared as a variant), the first containing a list of arrays, the second an array and the third a list of values. How do I individually access these values in Delphi - some sample code will help as I can't find anything in the demos and my knowledge of variants is quite inadequate. Kind regards
  14. BennieC

    Converting tuples into Delphi objects

    Apologies I solved the problem - just me being stupid. I misunderstood the GetItem method. All seems to be working now.
  15. BennieC

    Converting tuples into Delphi objects

    Thank you very much. The problem is that there are different arrays in the tuple and unless I can separate them I don't know how to convert the variants into Delphi variables. The lengths are not always as short as the sample and can indeed be very long. I was hoping to use something like aTmpvariant1 := myPlatTuple[0] aTmpvariant2 := myPlatTuple[1] etc, and then be able to individually decode these like aDelphiVal1 := aTmpvariant1[0], etc. but that does not work.
  16. Hi, I have a Delphi application and am calling some Python functions from it. The function in Python returns a set of lists. How do I write Delphi code to receive these lists. Return statement in Python: return lboxes, lidxs, lconfidences In Delphi I have used single value returns but now need to receive three distinct lists.. Any suggestions or assistance
  17. BennieC

    Returning lists from Python to Delphi

    I am still struggling with getting my results into Delphi. I have used direct access to the Python function as shown in the screencopy and in fact receive the correct results in Delphi using Code insight as shown. But I have no success in actually accessing this tuple from Delphi There are three items in the tuple, the first containing a list of arrays, the second an array and the third a list of values. How do I individually access these values - some sample code will help as I can't find anything in the demos and my knowledge of variants still seem to be inadequate. Kind regards
  18. BennieC

    Returning lists from Python to Delphi

    I have found the offending code in PythonEngine - function PyObjectAsVariant In line 5390 there is an ExtractDate(Result) line. Following thorugh it goes to the ExtractDate function with an unassigned value for date, but expecting to decode obj which is nil at this point - hence the error. This is nil because Getvar in GetVarAsVariant returned a nil for obj. Now clearly my Python object has a value as it returns it as strings in the VarPyIterate function. Can this help to explain my problem? Regards
  19. BennieC

    Returning lists from Python to Delphi

    Thank you I gathered that, but when I use my first attempt: GetVarAsVariant it fails with ACCESS VIOLATION I still struggle to see how Delphi can convert a python variant to the required format. Must I first declare the structure in Delphi? What if I don't know the structure? I have attached my test program in which I am trying to understand the principles - maybe you can understand my problem better in this. In the long run I will have to deal with quite complex tuples from my Yolo ML project (Which currently runs in C#) but I need to understand the principles first. Regards prjP4D_P5_VarPyth.zip
  20. BennieC

    Returning lists from Python to Delphi

    Thanks a lot - I am progressing. I now have a next problem in getting a list Python Code import P4D_P5_Python as md from myPyMod import np_array myboxes = [] myboxes = md.CreateArray() THIS JUST CREATES AN ARRAY OF RECTANGLES [t, l, w, h] Delphi Code PythonEngine1.ExecStrings(mePyInit.Lines); // This creates and runs the Python code FIRST ATTEMPT // Sien Demo 17 myV := PythonModule1.GetVarAsVariant('myboxes'); THIS FAILS WITH ACCESS VIOLATION SECOND ATTEMPT // From P4D tutorial 2 for var V in VarPyIterate(MainModule.myboxes) do THIS WORKS BUT VALUES V ARE STRINGS begin // If arrays are rectangles assert( varispythonlist(V)); Vlength := length(V); Listbox1.Items.Add('len(V) = ' + inttostr(Vlength)); Listbox1.items.add(V); end; ANy suggestions on where I am going wrong
  21. BennieC

    Returning lists from Python to Delphi

    Thank you. Of course my problem is that Delphi does not support tuples. How can I create variables in Delphi to return results into.
  22. Hi, I am rerunning projects that ran before and now have all sorts of SynEdit problems First SynEdit was not found so I re-installed Python4Delphi. Now SynHighlighterMulti is not found. Any assistance to get going again will be appreciated. Regards Bennie
  23. BennieC

    SynEdit changed with Delphi upgrade ?

    Thanks, got it all sorted
  24. Hi, we are doing some image processing and will use OpenCV for it. Doing this from Python is very useful as it disconnects us from the OpenCV libraries which we can now directly use. However, most processing is done with bitmaps. I have used the Demo29 and that works but it has the following limitations from our perspective. It requires image in a TGraphic form which we don't get from a frame grabber and I find no documentation to describe either the structure of or how to convert a bitmap to it. Internally we can convert the Byte stream with cv.imdecode into a opencv image and can convert our result image back to PILLOW Returning the image however does not work unless the image is converted back to a PILLOW format from where demo29 code can display it. I think part of my problem is that I don't have enough information regarding the PILLOW format or the TGraphic format. Also I don't find information about functions such as PyEval_CallObjectWithKeywords and ExtractPythonObjectFrom as the statement in demo29 returns a nil if I return any other format than PILLOW from Python. Any assistance will be appreciated and if anyone can point me to support documentation describing how to use bitmaps in Python and also how to understand the many Python methods. I ahve been mostly a Delphi programmer. An example of how we do it is as follows but this seems unnecessary and also requires input in TGraphic form, not TBitmap. def LoadPicData(data): # Convert data (image converted into Python Bytes) into a ocv image stream = BytesIO(data) ocv_img = cv.imdecode(np.asarray(bytearray(stream.read()), dtype=np.uint8), cv.IMREAD_COLOR) pil_src = Image.open(stream) # cv.imshow('ocv', ocv_img) ocv_img = cv.cvtColor(ocv_img, cv.COLOR_BGR2GRAY) # cv.imshow('gray', ocv_img) # Convert this image to pil image color_converted = cv.cvtColor(ocv_img, cv.COLOR_BGR2RGB) pil_img = Image.fromarray(color_converted) # convert ocv to PIL image pil_img.format = pil_src.format # ImageShow.show(pil_img, 'PIL') return pil_img Some assistance will be much appreciated.
  25. BennieC

    Transferring TBitmap to Python and back

    Just a quick question - where is the TVideoCapture defined - I can find no reference but the code works well!
×