问题描述
我第一次在Google Colab中尝试人脸识别
尽管我已经加载了所需的模块,但我无法将图像类型作为NumPy数组获取。
这是我的代码:
import matplotlib.pyplot as plt # To plot images and show @R_414_4045@ion on image
import numpy as np
from skimage.feature import hog # To perform HOG calculations
from skimage import data,exposure
import cv2 # To read images and perform certain operations on the image
# from google.colab.patches import cv2_imshow
img = cv2.imread("C:\\Users\\HP\\Desktop\\sachin-tendulkar.jpg",1)
print(type(img))
我得到的输出如下:
<class 'nonetype'>
该怎么办?请让我知道。
解决方法
如果您在Google Colab上工作,则无法访问本地计算机内存,因此"C:\\Users\\HP\\Desktop\\sachin-tendulkar.jpg"
将不可用于OpenCV,从而产生None
对象。
您是否尝试过将图像上传到Colab的本地内存?这应该工作完美。