Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-backend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김유현
2020-11-14 20:10:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e504a48cad4671735b92d6dadecf5ba25af4f7ce
e504a48c
1 parent
9806a46d
code refactory
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
api/videorecord.py
api/videorecord.py
View file @
e504a48
...
...
@@ -3,11 +3,11 @@ import os
#import botocore
import
time
import
datetime
#from django.core import serializers
#from api.models import Video, Record
#from api.serializers import VideoSerializer, RecordSerializer
'''
from django.core import serializers
from api.models import Video, Record
from api.serializers import VideoSerializer, RecordSerializer
from boto3.session import Session
from src.settings import AWS_REGION, S3_ACCESS_URL, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_STORAGE_BUCKET_NAME
'''
...
...
@@ -19,6 +19,7 @@ def record() :
path
=
'/home/pi/recorded'
# save path
state
=
True
#'''
# rpi setting
GPIO
.
setmode
(
GPIO
.
BCM
)
PIR_PIN
=
7
GPIO
.
setup
(
PIR_PIN
,
GPIO
.
IN
)
...
...
@@ -27,18 +28,20 @@ def record() :
try
:
while
state
:
#target = Record.objects.get(id = 1)
#serializer = RecordSerializer(target, many = False)
#state = serializer.data['recording']
'''
target = Record.objects.get(id = 1)
serializer = RecordSerializer(target, many = False)
state = serializer.data['recording']
'''
if
GPIO
.
input
(
PIR_PIN
):
# motion detected
# take a video
camera
.
resolution
=
[
320
,
240
]
camera
.
resolution
=
[
320
,
240
]
camera
.
start_preview
()
now
=
datetime
.
datetime
.
now
()
vid_name
=
now
.
strftime
(
'
%
Y
%
m
%
d-
%
H
%
M
%
S'
)
vid_path
=
path
+
'/'
+
vid_name
+
'.h264'
thumbnail_path
=
path
+
'/'
+
vid_name
+
'.jpg'
camera
.
start_recording
(
output
=
vid_path
)
camera
.
start_recording
(
output
=
vid_path
)
time
.
sleep
(
1
)
camera
.
capture
(
thumbnail_path
)
time
.
sleep
(
5
)
...
...
Please
register
or
login
to post a comment