# import the necessary packages # Dropbox and SMS functions from dbsecurecamera.tempimage import TempImage import argparse import warnings from datetime import datetime import dropbox import imutils import json import cv2 # construct the argument parser and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-c", "--conf", default='/home/pi/SecurityCamera/config/dropboxconf.json', help="path to the JSON configuration file") args = vars(ap.parse_args()) # filter warnings, load the configuration and initialize the Dropbox # client warnings.filterwarnings("ignore") conf = json.load(open(args["conf"])) client = None # check to see if the Dropbox should be used if conf["use_dropbox"]: # connect to dropbox and start the session authorization process client = dropbox.Dropbox(conf["dropbox_access_token"]) print("[SUCCESS] dropbox account linked") def dropBoxUpload(frame): timestamp = datetime.now() if conf["use_dropbox"]: ts = timestamp.strftime("%A%d%B%Y%I:%M:%S%p") # write the image to temporary file t = TempImage() cv2.imwrite(t.path, frame) # upload the image to Dropbox and cleanup the tempory image print("[UPLOAD] {}".format(ts)) path = "/{base_path}/{timestamp}.jpg".format(base_path=conf["dropbox_base_path"], timestamp=ts) client.files_upload(open(t.path, "rb").read(), path) t.cleanup() fileUrl = "http://dropbox.com/home/Apps/MyPiSecurityCamera" + path fileName = "{timestamp}.jpg".format(timestamp=ts) return (fileName, fileUrl)