我正在尝试使用Haar级联分类器进行对象检测。我已经复制了Haar级联算法的代码,但是它不起作用。 未知的网址类型:“ // drive.google.com/drive/folders/11XfAPOgFv7qJbdUdPpHKy8pt6aItGvyg” 即使此链接有效。
导入urllib.request,urllib.error,urllib.parse 导入cv2
导入操作系统
def store_raw_images():
neg_images_link ='//drive.google.com/drive/folders/11XfAPOgFv7qJbdUdPpHKy8pt6aItGvyg'
neg_image_urls = urllib.request.urlopen(neg_images_link).read()。decode()
pic_num = 1
if not os.path.exists('neg'):
os.makedirs('neg')
for i in neg_image_urls.split('\n'):
try:
print(i)
urllib.request.urlretrieve(i,"neg/"+str(pic_num)+".jpg")
img = cv2.imread("neg/"+str(pic_num)+".jpg",cv2.IMREAD_GRAYSCALE)
# should be larger than samples / pos pic (so we can place our image on it)
resized_image = cv2.resize(img,(100,100))
cv2.imwrite("neg/"+str(pic_num)+".jpg",resized_image)
pic_num += 1
except Exception as e:
print(str(e))
store_raw_images()
我期望输出为负片图像,以创建用于对象检测的数据集模块。