需要下载opencv File-Settings中按如下窗口点击加号,然后输入要下载的opencv-contrib-python,再点击右下角的install package等待下载完成,之后再运行代码就不会报错了