Skip to content

Commit

Permalink
Merge pull request #1 from LeonardoZanotti/logger
Browse files Browse the repository at this point in the history
logger  done
  • Loading branch information
LeonardoZanotti authored Aug 22, 2022
2 parents 343c931 + 88a0ccc commit 38f9c77
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Binary file modified __pycache__/camera.cpython-37.pyc
Binary file not shown.
17 changes: 12 additions & 5 deletions camera.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import cv2 as cv
import logging

logger = logging.getLogger('ftpuploader')
logging.basicConfig(level=logging.INFO, format='%(asctime)s :: %(levelname)s :: %(message)s')

class Camera:

def __init__(self):
self.camera = cv.VideoCapture(0)
self.camera.open('https://192.168.0.7:8080/video') # IP Webcam app on PlayStore
if not self.camera.isOpened:
raise ValueError("Camera not found!")
try:
self.camera = cv.VideoCapture(0)
self.camera.open('https://192.168.0.7:8080/video') # IP Webcam app on PlayStore
if not self.camera.isOpened:
raise ValueError("Camera not found!")
except Exception as e:
logger.error(f"An exception occurred: {e}")
exit(400)

self.width = self.camera.get(cv.CAP_PROP_FRAME_WIDTH)
self.height = self.camera.get(cv.CAP_PROP_FRAME_HEIGHT)
Expand All @@ -25,4 +32,4 @@ def get_frame(self):
else:
return (ret, None)
else:
return None
return None
4 changes: 4 additions & 0 deletions ftplog.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2022-08-22 18:04:46,432 ERROR An exception occurred: Camera not found!
2022-08-22 18:05:19,816 INFO dale
2022-08-22 18:05:19,816 ERROR dale
2022-08-22 18:05:19,817 ERROR An exception occurred: Camera not found!

0 comments on commit 38f9c77

Please sign in to comment.