I Use This!
Activity Not Available
Analyzed about 1 year ago. based on code collected about 1 year ago.

Project Summary

This is a wrapper that combines the original CVtypes from Gary Bishop and the latest library ctypes_opencv from Minh-Tri Pham into one. This library should work with notations used in both libraries with the exception that in CVtypes we don't need to access pointers(yay!) ie: image.width instead of image[0].width. Other advantages are

Complete interface to OpenCV's CXCORE, CV, HighGUI components. Pythonic interface. OpenCV's objects are safely deleted when not used. No need to invoke cvRelease...(). Pure Python package. Neither C/C++ compiler nor OpenCV's source code is needed. Support for both versions 1.0 and 1.1pre1 of OpenCV. Cross platform, running on any OS that OpenCV can be installed, including: Windows, Linux, and Mac OS X.

ExamplePython code for demonstrating K-Means Clustering

from cvtypes import *

if __name__ == "__main__":

color_tab = [CV_RGB(255,0,0),CV_RGB(0,255,0),CV_RGB(100,100,255), CV_RGB(255,0,255),CV_RGB(255,255,0)]
img = cvCreateImage(cvSize(500, 500), 8, 3)
rng = cvRNG(-1)
cvNamedWindow( "clusters", 1 )

while True:
cluster_count = cvRandInt(rng)%(MAX_CLUSTERS-1) + 2
sample_count = cvRandInt(rng)%999 + 1
points = cvCreateMat(sample_count, 1, CV_32FC2)
clusters = cvCreateMat(sample_count, 1, CV_32SC1)

# generate random sample from multigaussian distribution
for k in range(cluster_count):
first = k*sample_count/cluster_count
last = (k+1)*sample_count/cluster_count if k != cluster_count else sample_count
if first < last:
cvRandArr(rng, cvGetRows(points, None, first, last), CV_RAND_NORMAL,
cvScalar(cvRandInt(rng)%img.width,cvRandInt(rng)%img.height), cvScalar(img.width*0.1,img.height*0.1))
cvRandShuffle( points, rng )

# K Means Clustering
cvKMeans2(points, cluster_count, clusters, cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 10, 1.0))

cvZero( img )
for i in range(sample_count):
pt = points[i,0]
cvCircle(img, cvPoint(cvRound(pt[0]), cvRound(pt[1])), 2, color_tab[clusters[i,0]], CV_FILLED, CV_AA, 0)

cvShowImage( "clusters", img )

if '%c' % (cvWaitKey(0) & 255) in ['\x1b','q','Q']: # 'ESC'


ctypes opencv python

In a Nutshell, cvtypes...

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    you can subscribe to e-mail newsletters to receive update from the Open Hub blog
  • ...
    use of OSS increased in 65% of companies in 2016
  • ...
    data presented on the Open Hub is available through our API



30 Day Summary

Apr 9 2016 — May 9 2016

12 Month Summary

May 9 2015 — May 9 2016


Be the first to rate this project
Click to add your rating
Review this Project!