title: How to convert picamera video frame to openCV object
body: <p>I'm trying to record a video with the python raspberry camera module and 
  then convert each frame to a openCV frame with no success:</p>
  
  <pre><code>import time
  import picamera
  import cv2
  import numpy as np
  
  class BroadcastOutput(object):
      def __init__(self, camera):
          return
  
  
      def write(self, b):
  
          #create numpy array from b
          data = np.fromstring(b, dtype=np.uint8)
  
          #doesn't work with reshape either
          #data = np.fromstring(b, dtype=np.uint8).reshape(320, 280, 3)
  
          #enconde as image
          image = cv2.imdecode(data, 1)
  
          #test if is valid cv2 object -&gt; fails
          cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
  
  
      def flush(self):
          print('Waiting for background conversion process to exit')
  
      #camera setup and start
      with picamera.PiCamera() as camera:
          camera.resolution = (320, 280)
          camera.framerate = 24
          time.sleep(2) # camera warm-up time
  
          print('Initializing broadcast thread')
          output = BroadcastOutput(camera)
          print('Starting recording')
          camera.start_recording(output, 'bgr')
  
          try:
              while True:
                  camera.wait_recording(1)
  
          except KeyboardInterrupt:
              pass
          finally:
              print('Stopping recording')
              camera.stop_recording()
  </code></pre>
  
  <p>When i print my numpy array it has content, the image object after decode however is always none.</p>
  
  <p>So my question: How do i correctly use the provided data in b as an cv2 frame? 
  I'm still new to image processing...
  Thanks for any help in advance!</p>