DelphiPythonPython GUIWindows

How To Make An Ultra-Fast Computer Vision Windows App

blogbanner3-49

Are you looking for a powerful computer vision library and build a nice GUI for them? Try Mahotas library for Python. For the GUI part, you can run it seamlessly with Python4Delphi (P4D). P4D is a free and simple tool that allows you to run Python scripts as well as create new Python modules and types in Delphi.

Mahotas is a fast computer vision algorithms library (all implemented in C++ for speed) that operates over NumPy arrays. Mahotas supports Python 2.7 and 3.4+.

Currently, Mahotas has over 100 functions for image processing and computer vision and it keeps growing.

Here are some notable algorithms provided by Mahotas:

  • Watershed
  • Convex points calculations.
  • Hit & miss, thinning.
  • Zernike & Haralick, LBP, and TAS features.
  • Speeded-Up Robust Features (SURF), a form of local features.
  • Thresholding.
  • Convolution.
  • Sobel edge detection.
  • Spline interpolation
  • SLIC superpixels.

This post will guide you on how to run the Mahotas library to solve computer vision problems and use Python for Delphi to display it in the Delphi Windows GUI app.

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

How To Make An Ultra-Fast Computer Vision Windows App - demo

Demo

Let’s do a sanity test by running this simple example (using an example image that is shipped with Mahotas) by calling watershed using above threshold regions as a seed (we use Otsu to define threshold):

The result in our Python4Delphi VCL:

How To Make An Ultra-Fast Computer Vision Windows App - results in action
How To Make An Ultra-Fast Computer Vision Windows App - an array of results

For the next example, we try a very simple example of using mahotas.distance (which computes a distance map):

How To Make An Ultra-Fast Computer Vision Windows App - second example

For the final example, we will invoke thresholding functions, to automatically reduce and change colors in the image. For this example, I load external samples (not included in Mahotas image samples).

You can load your own images by writing their path and filenames like the usual way, or you can also edit the __init__.py file here: “C:UsersUsernameAppDataLocalProgramsPythonPython38Libsite-packagesmahotasdemos”. I load my own image which is defined by ‘cat’: ‘cat.jpg’ in the __init__.py file.

We use the Ridler-Calvard threshold in the following code example (visit the reference here):

How To Make An Ultra-Fast Computer Vision Windows App - recognizing cats

 

Congratulations, now you have learned how to run the Mahotas library to solve computer vision problems and use Python for Delphi to display it in the Delphi Windows GUI app! Now you can make various modifications to your images or learn more computer vision operations using Mahotas library and Python4Delphi.

Check out the Mahotas computer vision library for Python and use it in your projects: https://pypi.org/project/mahotas/ and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi

close
Related posts
DelphiLearn PythonPythonPython GUIRAD Studio

Why You Should Know About SQLite For Your Windows Apps

Learn PythonPythonPython GUIVideos

How To Make Matplotlib Charts To Visualize Data

DelphiPythonPython GUIWindows

What You Need To Create A Secure Python Password Generator

DelphiPythonPython GUIWindows

How To Make A GUI For Learning Python Using Turtle Library

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish