Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How do I convert urllib parameters to urllib3?

$
0
0
Hi everyone, This code makes the URLs of the images contained in the link, be resized and saved in a folder. The code is not mine, but I intend to use it as the basis for my project. [Link](https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/) Here's the code: import urllib.request import cv2 import numpy as np import os def store_raw_images(): neg_images_link = '//image-net.org/api/text/imagenet.synset.geturls?wnid=n00523513' 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() Whenever I run the code, appears this message: > import urllib.request ImportError: No module named request I have currently installed urllib3 module and I would like to know how to run this code converting urllib parameters to urllib3. I would like your help to solve this case.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>