我熟悉Python,但是尝试在Google驱动器/可乐中使用它。我似乎无法使用下面的代码加载图像(该文件与代码/笔记本位于同一文件夹中)。有什么想法吗?
import cv2
file1 = 'image1.JPG'
image = cv2.imread(file1)
if(image):
print("File present")
else:
print("File not present")
答案 0 :(得分:0)
检查图像是否确实存在,一种方法是使用内置的IPython库
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
由于运行numpy数组的模棱两可,我在上面用一个有效的图像运行了您的代码,并得到了一个错误:
import cv2
file1 = 'file1.JPG'
image = cv2.imread(file1)
print(type(image))
if image.any():
print("File present")
else:
print("File not present")
# Returns "File present"
考虑这些建议,并使用绝对有效的url链接稍稍更改代码即可获得所需的输出:
public ref class LibTidy
{
public:
System::String^ __clrcall Test(System::String^ input);
};