Skip to content

Commit

Permalink
save shutter and iso data
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpdev committed Apr 16, 2021
1 parent 45c5db0 commit 53ef4e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion birbcam/birbwatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __loop(self, camera, rawCapture, mask):
if didTakeFullPicture[0]:
thumbfile = f"{self.config.saveTo}/thumb/{didTakeFullPicture[1]}"
cv2.imwrite(thumbfile, now)
self.pictureLogger.log_picture(didTakeFullPicture[2], thumbfile, classifyResults)
self.pictureLogger.log_picture(didTakeFullPicture[2], thumbfile, classifyResults, self.shutterFlipper.label, self.isoFlipper.label)
else:
# logging.info(f"[birbvision] ignore: {classifyResults[0].label} @ {classifyResults[0].confidence:.2f}")
self.fullPictureTaker.reset_time()
Expand Down
14 changes: 9 additions & 5 deletions birbcam/picturelogger/picturelogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
class PictureLogger:
def __init__(self, file_source):
self._loggedPictures = []
self.__read_picture_history(file_source)
#self.__read_picture_history(file_source)

self._log_file = open(file_source, mode="a", encoding="utf-8")

def __del__(self):
self._log_file.close()

def log_picture(self, fullPath, thumbPath, classification):
def log_picture(self, fullPath, thumbPath, classification, shutter, iso):
entry = {
"full": fullPath,
"thumb": thumbPath,
"evaluation": [dictify_classification(c) for c in classification],
"time": time()
"time": time(),
"shutter": shutter,
"iso": iso
}

self.__append_to_file(entry)
Expand All @@ -34,15 +36,17 @@ def __append_to_file(self, entry):

def __serialize_entry(self, entry):
c = self.__serialize_classification(entry["evaluation"])
return f"{entry['time']}|{entry['full']}|{entry['thumb']}|{c}"
return f"{entry['time']}|{entry['full']}|{entry['thumb']}|{c}|{entry['shutter']}|{entry['iso']}"

def __deserialize_entry(self, string):
split = string.split("|")
return {
"time": split[0],
"full": split[1],
"thumb": split[2],
"evaluation": self.__deserialize_classification(split[3])
"evaluation": self.__deserialize_classification(split[3]),
"shutter": split[4],
"iso": split[5]
}

def __serialize_classification(self, results):
Expand Down

0 comments on commit 53ef4e2

Please sign in to comment.