示例#1
0
	def get_contours(self,image,threshold):
		storage=cv.cvCreateMemStorage(0)

		image=self.clone_image(image)

		num_contours,contours=cv.cvFindContours(image,storage,cv.sizeof_CvContour,cv.CV_RETR_LIST,cv.CV_CHAIN_APPROX_NONE,cv.cvPoint(0,0))

		contour_points=[[]]*num_contours
		for contour_index,contour in enumerate(contours.hrange()):
			for point in contour:
				contour_points[contour_index].append((point.x,point.y))

		cv.cvReleaseImage(image)
		cv.cvReleaseMemStorage(storage)

		return contour_points
示例#2
0
	def __del__(self):
		#Only attempt to access self.storage if it exists as a field of this class
		if hasattr(self,'storage'):
			#Only release the field if memory has been allocated here
			if None!=self.storage:
				cv.cvReleaseMemStorage(self.storage)