michal2229 / quadrilaterals-rectifier

Python2 (OpenCV, NumPy) application to find largest quadrilateral shape in image, transform it into rectangle and crop.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

readme

This is a script I wrote which finds quadrilateral surface on image, transforms this image to make this surface rectangular and then crops it to this surface only.

It works well in many cases, i.e. for extracting presentation slides from photos (clearly visible, bright trapezoids on dark background),
it performs worse if there is a lot of other shapes of similar luminosity as main object - it needs improvements in this department.

Samples included.

most important functions used

  • cv2.findContours()
  • cv2.findHomography()
  • cv2.warpPerspective()

usage

  • place images in input dir, open terminal, write make, execute, check output dir
  • use by command:
python find_rect_and_transform.py <input files> <output dir>

requirements

  • Python 2
  • OpenCV 2
  • NumPy

About

Python2 (OpenCV, NumPy) application to find largest quadrilateral shape in image, transform it into rectangle and crop.


Languages

Language:Python 96.0%Language:Makefile 4.0%