Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. from __future__ import print_function
  2. from imutils.video import VideoStream
  3. import logging
  4. import numpy as np
  5. import argparse
  6. import imutils
  7. import time
  8. import cv2
  9. cap = cv2.VideoCapture('abcTest.mp4')
  10. cap1 = cv2.VideoCapture('abcTest.mp4')
  11. # Define the codec and create VideoWriter object
  12. fourcc = cv2.VideoWriter_fourcc(*'MP4V')
  13. #out = cv2.VideoWriter('outputssImutils.mp4',fourcc, 20.0, (640,480))
  14. writer = None
  15. (h, w) = (None, None)
  16. zeros = None
  17. while(cap.isOpened()):
  18. ret, frame = cap.read()
  19. ret1, frame1 = cap1.read()
  20. if ret == False:
  21. break
  22. frame = imutils.resize(frame, width=300)
  23. frame1 = imutils.resize(frame1, width=300)
  24. (h, w) = frame.shape[:2]
  25. if writer is None:
  26. # store the image dimensions, initialzie the video writer,
  27. # and construct the zeros array
  28. writer = cv2.VideoWriter('acvsas.mp4', fourcc, 20,
  29. (w * 2, h), True)
  30. zeros = np.zeros((h, w), dtype="uint8")
  31. output = np.zeros((h , w*2, 3), dtype="uint8")
  32. output[0:h, 0:w] = frame
  33. output[0:h, w:w * 2] = frame1
  34. writer.write(output)
  35. # show the frames
  36. cv2.imshow("Frame", frame)
  37. cv2.imshow("Output", output)
  38. key = cv2.waitKey(1) & 0xFF
  39. # if the `q` key was pressed, break from the loop
  40. if key == ord("q"):
  41. break
  42.  
  43. # Release everything if job is finished
  44. cap.release()
  45. cap1.release()
  46. writer.release()
  47. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement