This commit is contained in:
Shoofle 2024-07-28 17:38:49 -04:00
parent 2bafb798da
commit a70949804b
4 changed files with 16 additions and 84 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
videos/*.mp4
videos/*.mkv

View File

@ -6,7 +6,6 @@ name = "pypi"
[packages]
opencv-python = "*"
python-ffmpeg = "*"
pygame = "*"
[dev-packages]

66
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "2305ff39baaa996b4a0786e3cdb5b5347719224bc165747aa332f21bdddea711"
"sha256": "96b4a3ab781c5962dc20f7beaae76ca7d30cf6dd4e193b0b04e985235aabc5cb"
},
"pipfile-spec": 6,
"requires": {
@ -89,70 +89,6 @@
"markers": "python_version >= '3.8'",
"version": "==11.1.0"
},
"pygame": {
"hashes": [
"sha256:098029d01a46ea4e30620dfb7c28a577070b456c8fc96350dde05f85c0bf51b5",
"sha256:1551852a2cd5b4139a752888f6cbeeb4a96fc0fe6e6f3f8b9d9784eb8fceab13",
"sha256:1c429824b1f881a7a5ce3b5c2014d3d182aa45a22cea33c8347a3971a5446907",
"sha256:249dbf2d51d9f0266009a380ccf0532e1a57614a1528bb2f89a802b01d61f93e",
"sha256:2ed2539bb6bd211fc570b1169dc4a64a74ec5cd95741e62a0ab46bd18fe08e0d",
"sha256:315e7b3c1c573984f549ac5da9778ac4709b3b4e3a4061050d94eab63fa4fe31",
"sha256:3dc242dc15d067d10f25c5b12a1da48ca9436d8e2d72353eaf757e83612fba2f",
"sha256:3f809560c99bd1fb4716610eca0cd36412528f03da1a63841a347b71d0c604ee",
"sha256:4928f3acf5a9ce5fbab384c21f1245304535ffd5fb167ae92a6b4d3cdb55a3b6",
"sha256:4a63daee99d050f47d6ec7fa7dbd1c6597b8f082cdd58b6918d382d2bc31262d",
"sha256:4f637636a44712e94e5601ec69160a080214626471983dfb0b5b68aa0c61563d",
"sha256:4faab2df9926c4d31215986536b112f0d76f711cf02f395805f1ff5df8fd55fc",
"sha256:4fad1ab33443ecd4f958dbbb67fc09fcdc7a37e26c34054e3296fb7e26ad641e",
"sha256:5ef92ed93c354eabff4b85e457d4d6980115004ec7ff52a19fd38b929c3b80fb",
"sha256:6050f3e95f1f16602153d616b52619c6a2041cee7040eb529f65689e9633fc3e",
"sha256:6897ab87f9193510a774a3483e00debfe166f340ca159f544ef99807e2a44ec4",
"sha256:6a284664978a1989c1e31a0888b2f70cfbcbafdfa3bb310e750b0d3366416225",
"sha256:6acf7949ed764487d51123f4f3606e8f76b0df167fef12ef73ef423c35fdea39",
"sha256:6f908762941fd99e1f66d1211d26383184f6045c45673443138b214bf48a89aa",
"sha256:71eebb9803cb350298de188fb7cdd3ebf13299f78d59a71c7e81efc649aae348",
"sha256:722d33ae676aa8533c1f955eded966411298831346b8d51a77dad22e46ba3e35",
"sha256:79abcbf6d12fce51a955a0652ccd50b6d0a355baa27799535eaf21efb43433dd",
"sha256:7d65fb222eea1294cfc8206d9e5754d476a1673eb2783c03c4f70e0455320274",
"sha256:829623cee298b3dbaa1dd9f52c3051ae82f04cad7708c8c67cb9a1a4b8fd3c0b",
"sha256:89be55b7e9e22e0eea08af9d6cfb97aed5da780f0b3a035803437d481a16d972",
"sha256:8cb51533ee3204e8160600b0de34eaad70eb913a182c94a7777b6051e8fc52f1",
"sha256:904aaf29710c6b03a7e1a65b198f5467ed6525e8e60bdcc5e90ff8584c1d54ea",
"sha256:92cf12a9722f6f0bdc5520d8925a8f085cff9c054a2ea462fc409cba3781be27",
"sha256:99902f4a2f6a338057200d99b5120a600c27a9f629ca012a9b0087c045508d08",
"sha256:9bc1795f2e36302882546faacd5a0191463c4f4ae2b90e7c334a7733aa4190d2",
"sha256:a0194652db7874bdde7dfc69d659ca954544c012e04ae527151325bfb970f423",
"sha256:a6636f452fdaddf604a060849feb84c056930b6a3c036214f607741f16aac942",
"sha256:a858bbdeac5ec473ec9e726c55fb8fbdc2f4aad7c55110e899883738071c7c9b",
"sha256:ac906478ae489bb837bf6d2ae1eb9261d658aa2c34fa5b283027a04149bda81a",
"sha256:ace471b3849d68968e5427fc01166ef5afaf552a5c442fc2c28d3b7226786f55",
"sha256:afbb8d97aed93dfb116fe105603dacb68f8dab05b978a40a9e4ab1b6c1f683fd",
"sha256:b5ac288655e8a31a303cc286e79cc57979ed2ba19c3a14042d4b6391c1d3bed2",
"sha256:b832200bd8b6fc485e087bf3ef7ec1a21437258536413a5386088f5dcd3a9870",
"sha256:b834711ebc8b9d0c2a5f9bfae4403dd277b2c61bcb689e1aa630d01a1ebcf40a",
"sha256:b86771801a7fc10d9a62218f27f1d5c13341c3a27394aa25578443a9cd199830",
"sha256:c0cb7bdf3ee0233a3ac02ef777c01dfe315e6d4670f1312c83b91c1ef124359a",
"sha256:c71da36997dc7b9b4ee973fa3a5d4a6cfb2149161b5b1c08b712d2f13a63ccfe",
"sha256:d11f3646b53819892f4a731e80b8589a9140343d0d4b86b826802191b241228c",
"sha256:d3ed0547368733b854c0d9981c982a3cdfabfa01b477d095c57bf47f2199da44",
"sha256:d666667b7826b0a7921b8ce0a282ba5281dfa106976c1a3b24e32a0af65ad3b1",
"sha256:e432156b6f346f4cc6cab03ce9657600093390f4c9b10bf458716b25beebfe33",
"sha256:e44bde0840cc21a91c9d368846ac538d106cf0668be1a6030f48df139609d1e8",
"sha256:e5707aa9d029752495b3eddc1edff62e0e390a02f699b0f1ce77fe0b8c70ea4f",
"sha256:e909186d4d512add39b662904f0f79b73028fbfc4fbfdaf6f9412aed4e500e9c",
"sha256:e92294fcc85c4955fe5bc6a0404e4cc870808005dc8f359e881544e3cc214108",
"sha256:eae3ee62cc172e268121d5bd9dc406a67094d33517de3a91de3323d6ae23eb02",
"sha256:f6a58b0a5a8740a3c2cf6fc5366888bd4514561253437f093c12a9ab4fb3ecae",
"sha256:f6e5e6c010b1bf429388acf4d41d7ab2f7ad8fbf241d0db822102d35c9a2eb84",
"sha256:f82df23598a281c8c342d3c90be213c8fe762a26c15815511f60d0aac6e03a70",
"sha256:fcd28f96f0fffd28e71a98773843074597e10d7f55a098e2e5bcb2bef1bdcbf5",
"sha256:fd8848a37a7cee37854c7efb8d451334477c9f8ce7ac339c079e724dc1334a76",
"sha256:fea019713d0c89dfd5909225aa933010100035d1cd30e6c936e8b6f00529fb80"
],
"index": "pypi",
"markers": "python_version >= '3.6'",
"version": "==2.6.0"
},
"python-ffmpeg": {
"hashes": [
"sha256:19ac80af5a064a2f53c245af1a909b2d7648ea045500d96d3bcd507b88d43dc7",

View File

@ -3,31 +3,29 @@ import cv2
def five_minute_segment_from(the_time):
return the_time.replace(second=(the_time.second // 5)*5, microsecond=0)
#minute = the_time.replace(second=0, microsecond=0)
#return minute.replace(minute=(minute.minute // 5)*5)
return the_time.replace(minute=(the_time.minute // 1)*1, second=0, microsecond=0)
def video_address_for(time_stamp):
return 'videos/' + str(time_stamp) + '.mp4'
return 'videos/' + str(time_stamp) + '.mkv'
queue = [(False, None)] * 100 #queue of recent frames
last_time_stamp = five_minute_segment_from(datetime.now())
# define a video capture object
# live webcam feed
camera = cv2.VideoCapture(0)
camera.set(cv2.CAP_PROP_FPS, 20.0)
camera.set(cv2.CAP_PROP_FPS, 30.0)
if not camera.isOpened():
print("Cannot open camera")
exit()
queue = [(False, None)] * 100
last_time_stamp = five_minute_segment_from(datetime.now())
# video writer
fourcc = cv2.VideoWriter_fourcc(*'H264')
out = cv2.VideoWriter(video_address_for(last_time_stamp), fourcc, camera.get(cv2.CAP_PROP_FPS), (int(camera.get(3)),int(camera.get(4))))
# video feed from previously captured video
old_time = cv2.VideoCapture(video_address_for(last_time_stamp))
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter("videos/" + str(last_time_stamp) + ".mp4", fourcc, camera.get(cv2.CAP_PROP_FPS), (int(camera.get(3)),int(camera.get(4))))
idx = 0
idx = 0
offset = 0
longterm = False
while(True):
@ -40,13 +38,11 @@ while(True):
)
if old_time.isOpened():
old_time.release()
old_time = cv2.VideoCapture(video_address_for(five_minute_segment_from(datetime.now() - timedelta(seconds=30))))
old_time = cv2.VideoCapture(video_address_for(five_minute_segment_from(datetime.now() - timedelta(minutes=10))))
last_time_stamp = five_minute_segment_from(datetime.now())
# Capture the video frame
# by frame
ret, frame = camera.read()
ret, frame = camera.read()
frame = cv2.flip(frame, 1)
#recod the frame