title: img is not a numpy array, neither a scalar
body: <p>I try combine haar cascade code with histogram code</p>
  
  <p>I try this code :</p>
  
  <pre><code>import cv2
  import numpy as np 
  from matplotlib import pyplot as plt
  
  #Cascade jeruk
  jeruk_cascade = cv2.CascadeClassifier('cascade.xml')
  
  camera = cv2.VideoCapture(1)
  
  base1 = cv2.imread('base1.png')
  base2 = cv2.imread('base2.png')
  base3 = cv2.imread('base3.png')
  
  #Set hist parameters
  hist_height = 64
  hist_width = 256
  nbins = 32
  bin_width = hist_width/nbins
  hrange = [0,180]
  srange = [0,256]
  ranges = hrange+srange                                  # ranges =   [0,180,0,256]
  
  #Create an empty image for the histogram
  h = np.zeros((hist_height,hist_width))
  
  while 1:
      grabbed, img = camera.read()
      cam = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
      if not grabbed:
        "Camera could not be started."
        break
  
      # add this
      # image, reject levels level weights.
      jeruks = jeruk_cascade.detectMultiScale(cam, 1.03, 5)
  
      # add this
      for (x,y,w,h) in jeruks:
  
      #    cv2.rectangle(img,(x,y),(x+w,y+h),(17,126,234),2)
      font = cv2.FONT_HERSHEY_SIMPLEX
          cv2.putText(img,'Jeruk',(x+w,y+h), font, 1, (17,126,234), 2, cv2.LINE_AA) #---write the text
  
          roi_gray = cam[y:y+h, x:x+w]
          roi_color = img[y:y+h, x:x+w]
  </code></pre>
  
  <p>I add this histogram code</p>
  
  <pre><code>    histcam = cv2.calcHist([cam], [0], None, [nbins], [0,256])
      cv2.normalize(histcam,histcam, hist_height, cv2.NORM_MINMAX)
      hist=np.int32(np.around(histcam))
  
      for x,y in enumerate(hist):
          cv2.rectangle(h,(x*bin_width,y),(x*bin_width + bin_width-1,hist_height), (255), -1)
  
      #Flip upside down
      h=np.flipud(h)
  
  #Show the histogram
      cv2.imshow('Color Histogram',h)
      h = np.zeros((hist_height,hist_width))
  
      cv2.imshow('img',img)
      k = cv2.waitKey(30) &amp; 0xff
      if k == 27:
          break
  
  camera.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>after I run all of them, I got this error :</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "/home/arizal/Documents/cascade jeruk/histogram/project1.py", line 52, in </p>
    
    <p>cv2.rectangle(h,(x<em>bin_width,y),(x</em>bin_width + bin_width-1,hist_height), (255), -1)</p>
    
    <p>TypeError: img is not a numpy array, neither a scalar</p>
  </blockquote>
  
  <p>the error in line 52 :</p>
  
  <pre><code>cv2.rectangle(h,(x*bin_width,y),(x*bin_width + bin_width-1,hist_height), (255), -1)
  </code></pre>
  
  <p>but if I remove cascade code, the histogram code can run without error with the same histogram code ? how to fix it ?</p>