小编Ale*_*son的帖子

在Python中训练OpenCV NormalBayesClassifier

我正在尝试使用NormalBayesClassifier对Foscam 9821W网络摄像头生成的图像进行分类.它们是1280x720,最初是彩色的,但我将它们转换为灰度分类.

我有一些Python代码(在http://pastebin.com/YxYWRMGs上)试图迭代一组火腿/垃圾邮件图像来训练分类器,但每当我调用train()时,OpenCV会尝试分配大量的内存并引发异常.

mock@behemoth:~/OpenFos/code/experiments$ ./cvbayes.py --ham=../training/ham --spam=../training/spam
Image is a <type 'numpy.ndarray'> (720, 1280)
...
*** trying to train with 8 images
responses is [2, 2, 2, 2, 2, 2, 1, 1]
OpenCV Error: Insufficient memory (Failed to allocate 6794772480020 bytes) in OutOfMemoryError, file /build/buildd/opencv-2.3.1/modules/core/src/alloc.cpp, line 52
Traceback (most recent call last):
  File "./cvbayes.py", line 124, in <module>
    classifier = cw.train()
  File "./cvbayes.py", line 113, in train
    classifier.train(matrixData,matrixResp)
cv2.error: /build/buildd/opencv-2.3.1/modules/core/src/alloc.cpp:52: error: (-4) Failed to allocate 6794772480020 bytes in …
Run Code Online (Sandbox Code Playgroud)

python opencv

1
推荐指数
1
解决办法
2019
查看次数

标签 统计

opencv ×1

python ×1