0

我想使用cv::saliency::MotionSaliencyBinWangApr2014模块。我的代码是这样的:

import cv2

salCV = cv2.saliency.MotionSaliencyBinWangApr2014_create()

frame = cv2.imread(imgfile)
grayFrame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
retval, saliencyMap =   salCV.computeSaliency(grayFrame)

但是我在pycharm中遇到这样的错误:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

在终端中像这样:

Segmentation fault (core dumped)

怎么了?我应该如何使用模块 cv::saliency::MotionSaliency?谢谢!

4

1 回答 1

-1

这是由于该类使用错误(我没有初始化)。如何使用显着性模块可以参考https://www.pyimagesearch.com/2018/07/16/opencv-saliency-detection/

import cv2

# initialize the detector
saliency = cv2.saliency.MotionSaliencyBinWangApr2014_create()
saliency.setImagesize(frame.shape[1], frame.shape[0])
saliency.init()

# call the detector
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
(success, saliencyMap) = saliency.computeSaliency(gray)
saliencyMap = (saliencyMap * 255).astype("uint8")
于 2019-05-27T02:22:56.243 回答