差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| miniskill [2022/02/06 12:57] – satoshi | miniskill [2022/02/06 14:29] (現在) – [SCORER Edge SDKからAWS S3への接続を設定する] satoshi | ||
|---|---|---|---|
| 行 68: | 行 68: | ||
| pip install boto3 | pip install boto3 | ||
| </ | </ | ||
| - | これにて準備完了です。次に下記のPythonスクリプトを実行すると指定の日付間、指定のカメラストリームのデータが受信可能になります。 | + | これにて準備完了です。次に下記のPythonスクリプトを実行すると指定の日付間、指定のカメラストリームのデータが受信可能になります。\\ |
| + | スクリプトのある階層に「movielist」フォルダを作成すれば動作します。\\ | ||
| + | <sxh Python; titile: | ||
| + | from boto3 import Session | ||
| + | import boto3 | ||
| + | import datetime | ||
| + | from dateutil.relativedelta import relativedelta | ||
| + | import tarfile | ||
| + | from tarfile import TarInfo | ||
| + | import gzip | ||
| + | import json | ||
| + | import os | ||
| + | import cv2 | ||
| + | |||
| + | S3Bucket | ||
| + | S3KeyPrefix = ' | ||
| + | device_list=[' | ||
| + | sday = datetime.date(2022, | ||
| + | eday = datetime.date(2022, | ||
| + | stime = datetime.time(7, | ||
| + | etime = datetime.time(20, | ||
| + | |||
| + | timearr=[] | ||
| + | tmptime = datetime.datetime.combine(datetime.date.today(), | ||
| + | edatetime = datetime.datetime.combine(datetime.date.today(), | ||
| + | while tmptime< | ||
| + | timearr.append(tmptime) | ||
| + | tmptime = tmptime + datetime.timedelta(hours=1) | ||
| + | print(timearr) | ||
| + | |||
| + | daynum = (eday-sday).days+1 | ||
| + | |||
| + | date1=sday | ||
| + | date_list = [] | ||
| + | for i in range(daynum): | ||
| + | date_list.append(date1.strftime(' | ||
| + | date1 = date1 + relativedelta(days=1) | ||
| + | print(' | ||
| + | print(date_list) | ||
| + | |||
| + | s3client = boto3.client(' | ||
| + | |||
| + | |||
| + | beginning_of_the_last_month = sday | ||
| + | end_of_the_last_month = eday | ||
| + | daynum = (end_of_the_last_month-beginning_of_the_last_month).days+1 | ||
| + | |||
| + | print(" | ||
| + | print(beginning_of_the_last_month) | ||
| + | print(" | ||
| + | print(end_of_the_last_month) | ||
| + | date1=beginning_of_the_last_month | ||
| + | date_list = [] | ||
| + | |||
| + | for i in range(daynum): | ||
| + | print(date1) | ||
| + | date_list.append(date1.strftime(' | ||
| + | date1 = date1 + relativedelta(days=1) | ||
| + | |||
| + | |||
| + | for device in device_list: | ||
| + | for date2 in date_list: | ||
| + | |||
| + | loopPrefix = S3KeyPrefix+device+"/" | ||
| + | |||
| + | paginator = s3client.get_paginator(' | ||
| + | # フィルタリング設定 | ||
| + | operation_parameters = { | ||
| + | ' | ||
| + | ' | ||
| + | } | ||
| + | |||
| + | page_iterator = paginator.paginate(**operation_parameters) | ||
| + | dirpath = " | ||
| + | os.makedirs(dirpath, | ||
| + | for page in page_iterator: | ||
| + | if ' | ||
| + | for o in page[' | ||
| + | key = o.get(' | ||
| + | filepath=key.split('/' | ||
| + | ttime = datetime.time(filepath[15: | ||
| + | if os.path.exists(dirpath+filepath[5]): | ||
| + | continue | ||
| + | if ttime > stime and ttime < etime: | ||
| + | print(device+"/" | ||
| + | s3client.download_file(Bucket=S3Bucket, | ||
| + | </ | ||
| + | |||
| + | ===== SCORER APIによる一括解析 ===== | ||
| + | (執筆中) | ||