Skip to main content

Polygon Analysis

Our aim is to build a module which is enough to analyze a polygon and return some fruitful information like an angle, slope, sides, corner coordinates etc. So we build py2pyAnalysis. Two line of code is sufficient to tear down a polygon of upto 15 sides. For overview of the module, consider this page is sufficient, if you are intrested in the working behind the program then visit py2py


Documents

Let's take a look at it,

 polygon_analysis ( file_name,
                     show_and_save_contour='yes',
                     show_and_save_analysis='yes',
                     show_sides='yes',
                     show_angles='yes',
                     show_slope='yes',
                     show_name='yes',
                     save_data_to_csv='yes',
                     font=cv2.FONT_HERSHEY_PLAIN
                     )
  • file_name : as clear from the name, it takes a file name, if the file is in the same directory then you can simply type name, else type the full path to the file.
  • show_and _save_contour : it allows you to see the various shapes that program detects in the image, it will also save the image file in a folder to Data/file_name_analysis/contour image. Everything that saves during the program related to this file will save in this particular folder only.
  • show_and_save_analysis : it allows you to see the numerical data on the image itself. the data includes Sides, Angles, and Slope. also, the name of an image will also be written there, The image will also save in the same directory as above.
  • Show_angles : This will show the angles on the image, changing it to NO will result to not showing angles on the image.
  • Show_slope : This will show the Slope on the image, changing it to NO will result to not showing Slope on the image.
  • font : you can change the Font if you want, Here is the list of some fonts
    cv2.FONT_HERSHEY_SIMPLEX
    cv2.FONT_HERSHEY_PLAIN,
    cv2.FONT_HERSHEY_DUPLEX
    cv2.FONT_HERSHEY_COMPLEX
    cv2.FONT_HERSHEY_TRIPLEX
    cv2.FONT_HERSHEY_COMPLEX_SMALL
    cv2.FONT_HERSHEY_SCRIPT_SIMPLEX
    cv2.FONT_HERSHEY_SCRIPT_COMPLEX

This program returns

return (len(sides),sides,distance,slope,angles,Name) 
  • len(sides): : Number of sides in a detected Polygon.
  • Sides : Tit returns the coordinates of the shape. Side[0] is the first [x,y] set. Similarly side[0][0] & side[0][1] will give you first x and y point respectivelly.
  • Distances : It returns the distance between two points in pixels.
  • Slope : It returns back the slope values corresponds to each side.
  • Angle : It returns back an array of angles.
  • Name : It returns back the name of the shape.

If anytime you forgot the which come after which then just type

import py2pyAnalysis as py
py.help()

and it will bring you the code below

#https://pypi.org/project/py2pyAnalysis/
#https://github.com/Pushkar-Singh-14/Polygon-Analysis
#http://py2py.com/polygon-analysis-overview-and-explanation/

Number_of_sides,Coordinates,Distance_in_pixels,Slopes,Angles,Names= py.polygon_analysis ( file_name,
                     show_and_save_contour='yes',
                     show_and_save_analysis='yes',
                     show_sides='yes',
                     show_angles='yes',
                     show_slope='yes',
                     show_name='yes',
                     save_data_to_csv='yes',
                     font=cv2.FONT_HERSHEY_PLAIN
                     ) 

Metadata

Release files for py2pyAnalysis 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for py2pyAnalysis 0.0.7
File Interpreter ABI Platform
py2pyAnalysis-0.0.7-py3-none-any.whl Python 3 none any Details

Release files / py2pyAnalysis-0.0.7-py3-none-any.whl

Download URL py2pyAnalysis-0.0.7-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1cb9c928f2f4d6dfd881cf75ab4e5cfb8f81c1333532bc273413206bb7bf208
BLAKE2b-256 checksum
How to use checksums
a204dadf41c3ea7c775eb9d330dd020d35ce796fdc5c1963e062fefd8541f6b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page