title: Upload image from opencv to s3 bucket
body: <p>I am trying to upload image to s3 after detecting a face using opencv. The jpg file gets uploaded to s3 but I am not able to open the image.</p>
  
  <p>I am able to upload correctly by first saving the image to local disk and then uploading it to s3 but I want to directly do it after detecting the face. Any idea how it can be done?</p>
  
  <pre><code># import the necessary packages
  
  # capture frames from the camera
  
  for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
      # grab the raw NumPy array representing the image, then initialize the timestamp
      # and occupied/unoccupied text
      image = frame.array
  
      gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  
      faces = face_cascade.detectMultiScale(
          gray,
          scaleFactor=1.1,
          minNeighbors=5,
          minSize=(30, 30),
          flags=cv2.CASCADE_SCALE_IMAGE
      )
  
      # Draw a rectangle around the faces
      for (x, y, w, h) in faces:
          cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
  
      # cv2.imwrite('newobama.png', image)
  
      if len(faces):
          imageName = str(time.strftime("%Y_%m_%d_%H_%M")) + '.jpg'
          #This is not working
          s3.put_object(Bucket="surveillance-cam", Key = imageName, Body = bytes(image), ContentType= 'image/jpeg')   
  
      # show the frame
      cv2.imshow("Frame", image)
      key = cv2.waitKey(1) &amp; 0xFF
  
      # clear the stream in preparation for the next frame
      rawCapture.truncate(0)
  
      # if the `q` key was pressed, break from the loop
      if key == ord("q"):
          break
  </code></pre>