Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Learn To Build A Python GUI For Solving Complex Tasks With Powerful OpenCV Library In A Delphi Windows App

Are you looking for a powerful machine learning library? Try OpenCV library for Python. You can run it with Python for Delphi (P4D). P4D is a free and simple with which you can run Python scripts as well as create new Python modules and types in Delphi. Delphi itself offers various third party libraries for interfacing with OpenCV. If you have an existing Python application and you need OpenCV you could use the Python OpenCV library or you could send the data to Delphi and use Delphi-OpenCV there. Alternately, you could do all of your work with OpenCV in Pythin and then display it in the Delphi Windows GUI app. You can use Python4Delphi a number of different ways such as: Use Delphi and C++Builder and Python4Delphi to run Python scripts in  Python GUI apps for Windows. First, run Demo1 project for executing Python script in Python for Delphi. Then load script in text field and press Execute button to see the result. Go to GitHub to download Demo1 source. [crayon-6762fa85a19e4215896173/] OpenCV is an open-source library for computer vision and machine learning that supports various programming languages including Python. With this library, you can do a lot of difficult operations, such as image processing, video analysis, feature detection, machine learning, computational photography, object detection.

K-Nearest Neighbour

In this example, we will consider solving the problem of finding nearest neighbors using OpenCV library. First, let’s randomly create 20 red points (family 0) and 20 green points (family 1). Then add 5 blue points. Using function train(), we will train the neural network. Function findNearest() returns k nearest neighbours (in our example k=3) for each blue point. It also calculates the distance to each found neighbor and determines the family of points from which more neighbors are found. [crayon-6762fa85a19f0039872225/]

Perspective Transformation of an Image

To perform perspective transformation with an image use warpPerspective() function. The parameters of this function are the original image, the transformation matrix, and the size of the output image. Use getPerspectiveTransform() function to get the transformation matrix. You need to pass four points of the input image and the corresponding four points of the output image to this function. It is important, that three of the four points should not be on the same straight line. [crayon-6762fa85a19f3439329386/] You have read the quick overview of OpenCV library. Go here, download this library and use the full power of computer vision and machine learning in your applications. Check out Python4Delphi and easily build Python GUIs for Windows using Delphi.
Exit mobile version