Ask Your Question

Eric H's profile - activity

2017-03-07 20:51:57 -0600 commented answer Load Single Channel Numpy Array Image with detectMultiScale

Thanks. My most obvious error was also calling cvtColor on a numpy array (112, 112), which is already single channel gray-scale image.

PS I'm trying to solve the address number street view problem. I want to get digit bboxes from an image. Do you any resources for a better approach at solving the problem. Maybe create a cascade classifier for any digit, then run resized cropped images of those individual digits through a classifier that's been trained on digits 0-9?

2017-03-07 20:47:57 -0600 received badge  Supporter (source)
2017-03-07 20:47:53 -0600 received badge  Scholar (source)
2017-03-07 09:54:18 -0600 commented question Load Single Channel Numpy Array Image with detectMultiScale

Thanks @StevenPuttemans not sure whether I would get a response here - I posted them at once. I definitely appreciate all of the suggestions.

2017-03-06 22:48:20 -0600 asked a question Load Single Channel Numpy Array Image with detectMultiScale

I have sequences of digits originally from Mnist data set that I've manipulated with OpenCV. They are saved in a pickle file. They are 1 channel images with shape (112, 112).

I want to run these through an OpenCV Cascade Classifier, similar to docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html, but instead with these github.com/ankitdhall/Google-Street-View-House-Numbers-Digit-Localization.

Here is my attempt:

data = p.load_file('data/train_sequences00.pickle')
zero = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade0/cascade.xml')
one = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade1/cascade.xml')
two = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade2/cascade.xml')
three = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade3/cascade.xml')
four = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade4/cascade.xml')
five = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade5/cascade.xml')
six = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade6/cascade.xml')
seven = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade7/cascade.xml')
eight = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade8/cascade.xml')
nine = cv2.CascadeClassifier('data/Google-Street-View-House-Numbers-Digit-Localization/cascades/cascade9/cascade.xml')
gray = np.array(data['sequences'][0]).astype(np.float32)
gray = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
#gray = cv2.cvtColor(img, cv2.CV_RGB2GRAY)

zeros = zero.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
ones = one.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
twos = two.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
threes = three.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
fours = four.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
fives = five.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
sixes = size.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
sevens = seven.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
eights = eight.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
nines = nine.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)

Unfortunately this just results in the following error:

Traceback (most recent call last):
  File "digit_cascade.py", line 22, in <module>
    zeros = zero.detectMultiScale(gray, 1.3, 5, scaleFactor=0.6)
SystemError: error return without exception set

Is anyone familiar with how to load raw numpy arrays into OpenCV detectMultiscale?

Here are some uncertainties I have:

  • The OpenCV docs docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html#cascadeclassifier-detectmultiscale have two different signatures for detectMultiscale. What is the purpose of the first, with the arguments for rejectLevels and levelWeights?
  • My images are 112x112. Each digit within this image would be around 11x11 pixels. The cascade sizes are 20x30. What parameter should I/ do I need to set in order for the cascades to work properly?

(this is a repost from SO).