Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger done #1

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!