OpenCV Workshop Python distribution of keywords
From Hackerspace Brussels
List of the 50 most represented OpenCV members of the Python package in the documentation examples.
- ShowImage 43
- NamedWindow 30
- Scalar 29
- RGB 28
- CV_RGB 28
- CreateImage 27
- Sub 26
- Round 25
- WaitKey 24
- __name__ 19
- Zero 19
- Line 17
- CV_AA 17
- Load 15
- CloneImage 15
- Set 14
- LoadImage 14
- Copy 14
- ScalarAll 12
- RealScalar 12
- GetSize 12
- CreateMat 12
- CreateTrackbar 11
- Convert 11
- GetSubRect 10
- DestroyWindow 10
- Scale 9
- Circle 9
- Threshold 8
- DFT 8
- Min 6
- CreateMemStorage 6
- ConvertScale 6
- Add 6
- RandInt 5
- RandArr 5
- IPL_DEPTH_64F 5
- CV_RAND_NORMAL 5
- CV_FILLED 5
- CV_32FC 5
- CV_32F 5
- 32FC 5
- Subdiv2DRotateEdge 4
- SetIdentity 4
- QueryFrame 4
- Pow 4
- Or 4
- Erode 4
- Dilate 4
- CvtColor 4
This is done via
import os.path import re import cv cv_vars = vars(cv) # some patterns could be ignore, e.g. __ found in __name__ cv_vars_counters = dict() examples_path = '/usr/share/doc/opencv-doc/examples/python/python/' examples = os.listdir(examples_path) for example in examples: if example.endswith('.py'): f = open(examples_path+example,'r') content = str(f.readlines()) for var in cv_vars.keys(): # this could be limited to built-in functions instead val = cv_vars_counters.setdefault(var,0) occurrences = len(re.findall(var,content)) cv_vars_counters[var] = val + occurrences f.close() for key, value in sorted(cv_vars_counters.iteritems(), key=lambda (k,v): (v,k)): print "%s: %s" % (key, value) #The output can be processed to be shared on a wiki page, e.g. # python atoms_distribution.py | tail -50 | tac | sed "s|\(.*\): \(.*\)|* [http://opencv.willowgarage.com/documentation/python/search.html?q=\1 \1] \2|"
See OpenCV Workshop.