camera.py 547 Bytes
import boto3
import numpy as np
import cv2
import time



def uploadCameraFrame():
	cap = cv2.VideoCapture('test4.mp4')
	index = 0

	bucket = "s3fromkvs"
	file_name ="temp.npy"
	s3 = boto3.client('s3')
	print("uploadCameraFrame started")
	start = time.time()
	while True:
		ret, frame = cap.read()
		#frame=frame.reshape(480, 640, 3)
		obj = np.array(frame).tobytes()
		s3.put_object(Body=obj, Bucket=bucket, Key='image/temp2.binary')
		print(str(frame.shape) + str(index) +"th frame")
		index += 1
		#print((time.time() - start))
	cap.release()