Skip to content

inspiredlabs/python-reduced-test-cases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reduced test cases for Python prototyping

Working fallback snippets for OpenCV development

Jan 2019, thanks to Edwin Diaz for his digestable, reproducable style, Frederick Ngoiya, Rayan Slim, and fellow intj Harrison Kinsley.

How to use this repo

Pick through feature requirements and test or append your reduced testcases. If you're introducing new requirements, then it's advisable to write snippets that match a wholly transferable implementation.

The code here should excersize restraint. Comment only to aid comprehension rather than feature requests or conflation.

Installation

Spyder, NumPy & OpenCV

  • The suite relys on the CLI and for debugging, it's essential to read the relevant documentation as versions often contain breaking changes, see: Gotchas.

  • Download Anaconda, and run the installer

  • Open terminal in your PWD install OpenCV pip install opencv-contrib-python

  • Install Conda conda install -c https://conda.binstar.org/menpo opencv

  • Check Python version: python3 -V

  • Check OpenCV version python,

    • >>> import cv2
    • >>> cv2.__version__
  • Use Spyder through Anaconda in Spotlight (cmd + space), you'll find it from the GUI.

Pillow, Python Image Library (fork)

For fast access to data stored in pixel formats, Pillow assists in batch processing in preperation for HAAR cascades: pip install pillow

MatPlotLib (for Python 3.7.1)

An object-oriented API for plotting NumPy data (from detected features and UI).

  • Install MatPlotLib:
    • python -mpip install -U pip
    • python -mpip install -U matplotlib
    • pip install --upgrade setuptools

Misc

Shortcuts

Terminal shortcuts to *.py files can be written with your PWD && pseudoexecutable as follows: # cd /Users/~/python-opencv-facial-recognition-by-frederick-ngoiya && python haar_cap.py && killAll python

Gotchas

There are a lot of things to be mindful of when starting OpenCV. Notable, instances include:

Nesting cv2.waitKey(0), cv2.destroyAllWindows() or cap.release() inside a loop will not exit properly. If the CLI hangs, you'll need to killAll python. It's advisable to apend this to new scripts.

For modern platforms you need to do a little more just to return 8Bit integer. Therefor something easy like escaping a script now becomes: cv2.waitKey(0) & 0xFF with the corresponding byte match of 0xFF. This results in longer expressions throughout your code.

Notable, instances include: integer division is now float division: // not /.

'module' object has no attribute:"ORB" so we have to use ORB_create, which is specific to build numbers.

The docs are comprehensive, but often buggy. Note the default value None in argument in img3 = cv.drawMatches(img1,kp1,img2,kp2,matches[:10], None, flags=2) from the corresponding OpenCV tutorial. The code remains explicit, but is missing the outImg argument answered on SO in May 2017.

You will need argument specifics such as int(odd) for cv2.GaussianBlur(img, kernel, stdev).

NumPy arrays, by default are np.int64. Images must be made up of the right data type, most applications require 8bit colour depth. Specify this in cv2.cvtColor() with dtype = np.uint8 – and, for 256 times more the pixel information, dtype = np.uint16 although, normalising these dimensions might not be worth the overhead.

SIFT in the documentation is referenced as cv2.SIFT(), but this is now: sift = cv2.xfeatures2d.SURF_create() works. Although you'll need to Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'.

The Intel licence prohibits free commercial application of evaluation files such as HAAR.xml

About

Working feature requirements and fallback snippets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages