Commit e2b60e97 authored by Kieran Hymas's avatar Kieran Hymas

Rolled back cv2 implementation

parent 032543f9
#Imports
from videostream import *
import tkinter as tk
from tkinter import *
......@@ -12,6 +11,7 @@ class Application(Frame):
self.icons = [tk.PhotoImage(file="./assets/icons/snapshot.png"), \
tk.PhotoImage(file="./assets/icons/record.png") \
]
self.update()
self.initApp()
def __version__(self):
......@@ -28,7 +28,7 @@ class Application(Frame):
self.master.config(menu=menubar)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New session", command=lambda arg=0 : self.initVideoFeed(arg))
filemenu.add_command(label="New session", command=self.onNew)
filemenu.add_command(label="Exit Pycroscope", command=self.onExit)
menubar.add_cascade(label="File", menu=filemenu)
......@@ -55,7 +55,7 @@ class Application(Frame):
toolbar = Toplevel(self.master, bd=1, relief=RAISED)
toolbar.geometry("+" + str(self.master.winfo_screenwidth()) + "+" + str(self.master.winfo_screenheight() // 3))
#load icons
#load icons
pair1 = Frame(toolbar)
snapshotButton = Button(pair1, relief=FLAT, image=self.icons[0], command=self.onSnapshot)
snapshotButton.pack(side=LEFT, padx=1, pady=1)
......@@ -88,14 +88,6 @@ class Application(Frame):
toolbar.protocol("WM_DELETE_WINDOW", lambda arg=toolbar: self.onClosing(arg))
def initVideoFeed(self, video_src):
try:
self.vid = VideoStream(video_src)
self.canvas = tk.Canvas(self.master, width=self.vid.width, height=self.vid.height)
self.canvas.pack()
except ValueError:
return
#Menubar options
#File
def onNew(self):
......
#Imports
import cv2
import imutils
#Classes
class VideoStream():
def __init__(self, video_src=0):
self.vid = cv2.VideoCapture(video_src)
if not self.vid.isOpened():
print('[-] Error: Couldn\'t open video stream at source: ', video_src)
raise ValueError()
self.width = self.vid.get(cv2.CAP_PROP_FRAME_WIDTH)
self.height = self.vid.get(cv2.CAP_PROP_FRAME_HEIGHT)
def __del__(self):
if self.vid.isOpened():
self.vid.release()
def get_frame(self):
if self.vid.isOpened():
ret, frame = self.vid.read()
if ret:
return (ret, cv2.cvtColor(frame, cv2.COLOR_BGR2RBG))
else:
return (ret, None)
else:
return (ret, None)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment