简体   繁体   English

使用 OpenCV 退出代码 -1073741819 (0xC0000005)

[英]Exit code -1073741819 (0xC0000005) with OpenCV

I am trying a really simple OpenCV example in Python, which completely fails to work for me:我正在尝试用 Python 编写一个非常简单的 OpenCV 示例,但它完全不适合我:

import cv2
import matplotlib.pyplot as plt

if __name__ == '__main__':
    img1 = plt.imread('../data/input/frame000013.png')
    img2 = plt.imread('../data/input/frame000014.png')
    img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
    sift = cv2.SIFT()
    print(sift)
    kp = sift.detect(img1_gray, None)
    print(kp)

If I try to run it with PyCharm, I get the following error:如果我尝试使用 PyCharm 运行它,则会收到以下错误:

Process finished with exit code -1073741819 (0xC0000005)

If I try to execute it through the terminal, it just does not seem to get past kp = sift.detect(img1_gray, None) line and does not really get to second print statement, without providing any error notification whatsoever.如果我尝试通过终端执行它,它似乎没有通过kp = sift.detect(img1_gray, None)行并且没有真正进入第二个print语句,而没有提供任何错误通知。

I use: Windows 10, Python 3.8, opencv-python & opencv-contrib-python 4.4.0.44.我使用:Windows 10、Python 3.8、 opencv-pythonopencv-contrib-python 4.4.0.44。

If you look at the documentation , it should be SIFT_create() .如果您查看文档,它应该是SIFT_create()

sift = cv2.SIFT_create()
print(sift)
kp = sift.detect(img1_gray, None)

But, why are you reading images with plt.imread ?但是,为什么要使用plt.imread读取图像?

The reason I'm asking, you are converting to the gray-scale using BGR2GRAY .我问的原因是,您正在使用BGR2GRAY转换为灰度。 But plt.imread returns image as RGB format.plt.imreadRGB格式返回图像。 Therefore, if you are going to use plt.imread :因此,如果您打算使用plt.imread

import cv2
import numpy as np
import matplotlib.pyplot as plt


def rgb2gray(rgb):
    return np.dot(rgb[..., :3], [0.2989, 0.5870, 0.1140]).astype(np.uint8)


if __name__ == '__main__':
    img1 = plt.imread('../data/input/frame000013.png')
    img2 = plt.imread('../data/input/frame000014.png')
    img1_gray = rgb2gray(img1)
    sift = cv2.SIFT_create()
    print(sift)
    kp = sift.detect(img1_gray, None)
    print(kp)

or if you choose cv2.imread :或者如果您选择cv2.imread

import cv2
import matplotlib.pyplot as plt

if __name__ == '__main__':
    img1 = cv2.imread('../data/input/frame000013.png')
    img2 = cv2.imread('../data/input/frame000014.png')
    img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
    sift = cv2.SIFT_create()
    print(sift)
    kp = sift.detect(img1_gray, None)
    print(kp)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenCV 退出代码 -1073741819 (0xC0000005) - OpenCV exit code -1073741819 (0xC0000005) Opencv相机崩溃,退出代码为-1073741819(0xC0000005) - Opencv Camera crashes with exit code -1073741819 (0xC0000005) 进程完成,退出代码 -1073741819 (0xC0000005) - Rpy2 - Process finished with exit code -1073741819 (0xC0000005) - Rpy2 进程在 Pycharm 中以退出代码 -1073741819 (0xC0000005) 完成 - Process finished with exit code -1073741819 (0xC0000005) in Pycharm 进程以退出代码 -1073741819 (0xC0000005) Pycharm 结束 - Process finished with exit code -1073741819 (0xC0000005) Pycharm 流程结束,退出代码为-1073741819(0xC0000005)(Cython,TeamSpeak3) - Process finished with exit code -1073741819 (0xC0000005) (Cython, TeamSpeak3) Python:进程已完成,退出代码为 -1073741819 (0xC0000005)。 如何调试? - Python: Process finished with exit code -1073741819 (0xC0000005). How to Debug? 'import quandl'生成'流程已完成退出代码-1073741819(0xC0000005)' - 'import quandl' produces 'Process finished with exit code -1073741819 (0xC0000005)' 进程在 PyCharm 中以退出代码 -1073741819 (0xC0000005) 结束,重新启动:空闲状态下的 Shell,并关闭控制台 - Process finished with exit code -1073741819 (0xC0000005) in PyCharm, RESTART: Shell in IDLE, and closes console 运行成功后,Django Web应用程序偶尔会退出代码-1073741819(0xC0000005) - Occasional Exit code -1073741819 (0xC0000005) with Django web app after a successful Run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM