pycharm运行时出现错误解决方法

1、“unindent does not match any outer indentation level”

表示没有缩进,要缩进,复制黏贴代码的话要重新敲、缩进一遍

2、pycharm在TensorFlow环境下运行程序时提示如下信息,这是一个警告,没有什么问题,可以忽略,也可以加代码解决。

I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

解决方法:忽视、屏蔽警告,在代码开头输入如下指令就可以解决

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

3、运行OpenCV框架时,cv2和cv3有几个不同

在边缘检测时,即使用函数cv2.findContours()时,cv2是返回两个参数,cv3是返回三个参数。不然cv2会报错。错误实例:

binary,contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE) #binary为二值化图像,contours为图像轮廓信息,hierarcgy为图像层数

运行时报错为:

Traceback (most recent call last):

File "D:/pysdy/OpenCV/cv.py", line 6, in <module>

binary,contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE) #binary为二值化图像,contours为图像轮廓信息,hierarcgy为图像层数

ValueError: not enough values to unpack (expected 3, got 2)

准确代码如下;

contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)

猜你喜欢

转载自blog.csdn.net/xiewenrui1996/article/details/86571611