我正在尝试使用OpenCV 4.0.0和Python 3.6编写使用GeneralizedHoughBallard类的基本示例。我在这里https://github.com/opencv/opencv/blob/4.0.0/samples/gpu/generalized_hough.cpp找到了C++的示例,但没有找到Python的示例。
当我尝试创建GeneralizedHoughBallard类的新实例时:
import cv2
alg = cv2.createGeneralizedHoughBallard()
我收到错误:“AttributeError:模块'cv2.cv2'没有属性'createGeneralizedHoughBallard”。
我在OpenCV源代码(https://github.com/opencv/opencv/blob/4.0.0/modules/imgproc/include/opencv2/imgproc.hpp)中看到,createGeneralizedHoughBallard是用CV_EXPORTS声明的,因此我想应该可以在Python中使用它。我尝试使用在同一文件(improc.hpp)中声明的另一个类似函数,例如:cv2.createCLAHE()并可以正常工作。
可能是什么问题呢?
最佳答案
显然,它只是GeneralizedHoughBallard
import cv2
print([x for x in dir(cv2) if 'Hough' in x])
print([x for x in dir(cv2) if x.startswith('create')])
['GeneralizedHough',
'GeneralizedHoughBallard',
'GeneralizedHoughGuil',
'HoughCircles',
'HoughLines',
'HoughLinesP',
'HoughLinesPointSet']
['createAffineTransformer',
'createAlignMTB',
'createBackgroundSubtractorKNN',
'createBackgroundSubtractorMOG2',
'createButton',
'createCLAHE',
'createCalibrateDebevec',
'createCalibrateRobertson',
'createChiHistogramCostExtractor',
'createEMDHistogramCostExtractor',
'createEMDL1HistogramCostExtractor',
'createHanningWindow',
'createHausdorffDistanceExtractor',
'createLineSegmentDetector',
'createMergeDebevec',
'createMergeMertens',
'createMergeRobertson',
'createNormHistogramCostExtractor',
'createShapeContextDistanceExtractor',
'createThinPlateSplineShapeTransformer',
'createTonemap',
'createTonemapDrago',
'createTonemapDurand',
'createTonemapMantiuk',
'createTonemapReinhard',
'createTrackbar']
关于python-3.x - 无法在Python中使用OpenCV GeneralizedHoughTransform类,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55490923/