added event-loop callback
This commit is contained in:
+14
-1
@@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from typing import Union, overload
|
from typing import Union, overload
|
||||||
from picamera2 import Picamera2
|
from picamera2 import Picamera2, MappedArray
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import json
|
import json
|
||||||
import cv2
|
import cv2
|
||||||
|
import time
|
||||||
|
|
||||||
#import numpy as np
|
#import numpy as np
|
||||||
#import argparse
|
#import argparse
|
||||||
#import sys
|
#import sys
|
||||||
@@ -73,6 +75,16 @@ def set_value(item: str, value):
|
|||||||
def get_value(item: str):
|
def get_value(item: str):
|
||||||
return picam2.camera_controls[item]
|
return picam2.camera_controls[item]
|
||||||
|
|
||||||
|
def process(request):
|
||||||
|
colour = (0, 255, 0)
|
||||||
|
origin = (0, 30)
|
||||||
|
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||||
|
scale = 1
|
||||||
|
thickness = 2
|
||||||
|
timestamp = time.strftime("%Y-%m-%d %X")
|
||||||
|
with MappedArray(request, "main") as m:
|
||||||
|
cv2.putText(m.array, timestamp, origin, font, scale, colour, thickness)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for item in items:
|
for item in items:
|
||||||
try:
|
try:
|
||||||
@@ -97,6 +109,7 @@ if __name__ == '__main__':
|
|||||||
pprint(f"Camera config: {picam2.camera_configuration()}")
|
pprint(f"Camera config: {picam2.camera_configuration()}")
|
||||||
|
|
||||||
# Start
|
# Start
|
||||||
|
picam2.pre_callback = process
|
||||||
picam2.start()
|
picam2.start()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user