Search the Community
Showing results for tags 'tbitmap'.
Found 2 results
-
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.
-
I'm having difficulty saving a JPEG file in Firemonkey. Here's the code: procedure SaveImage(bmp:TBitmap; filename:string); var vOpt:TBitmapCodecSaveParams; begin vOpt.Quality:=20; //Quality setting ignored? :( bmp.SaveToFile(filename,@vOpt); end; On Windows everything seems OK, however when the program is compiled for MacOS the resulting JPEG file is not at the Quality specified. The image quality setting seems to be ignored. How do I set the JPEG output quality on MacOS? (Delphi Tokyo 10.2.3)