Ask Your Question

shady's profile - activity

2016-08-06 06:09:56 -0600 asked a question Aborted (core dumped)

Run on Python 2.7 and OpenCV with Ubuntu12.04.

Error; terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 140) > this->size() (which is 7) Aborted (core dumped)

Thnx

import urllib
import cv2
import numpy as np
import os

def store_raw_images():
    neg_image_link = 'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n02708433'
    neg_image_urls = urllib.urlopen(neg_image_link).read().decode()

    if not os.path.exists('neg'):
        os.makedirs('neg')
    pic_num = 1

    for i in neg_image_urls.split('\n'):
        try:
            print(i)
            urllib.urlretrieve(i,"neg/"+str(pic_num)+'.jpg')
            img = cv2.imread("neg/"+str(pic_num)+'.jpg', cv2.IMREAD_GRAYSCALE)
            resized_image = cv2.resize(img)
            cv2.imwrite("neg/"+str(pic_num)+'.jpg',resized_image)
            pic_num += 1

        except Exception as e:
            print(str(e))


store_raw_images()
2016-08-06 05:57:20 -0600 received badge  Editor (source)
2016-08-05 23:45:24 -0600 asked a question Aborted (core dumped)

Run on Python 2.7 and OpenCV with Ubuntu12.04. Thnx

enter code here The actual code is:

import urllib import cv2 import numpy as np import os def store_raw_images(): neg_image_link = 'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n02708433' neg_image_urls = urllib.urlopen(neg_image_link).read().decode()

if not os.path.exists('neg'):
    os.makedirs('neg')
pic_num = 1

for i in neg_image_urls.split('\n'):
    try:
        print(i)
        urllib.urlretrieve(i,"neg/"+str(pic_num)+'.jpg')
        img = cv2.imread("neg/"+str(pic_num)+'.jpg', cv2.IMREAD_GRAYSCALE)
        resized_image = cv2.resize(img)
        cv2.imwrite("neg/"+str(pic_num)+'.jpg',resized_image)
        pic_num += 1
    except Exception as e:
        print(str(e))

store_raw_images()

Error:

terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 140) > this->size() (which is 7) Aborted (core dumped)