@SaraAbdullahs wrote:
import dash
import dash_core_components as dcc
import dash_html_components as html
from flask import Flask, Response
import cv2###external JavaScript files
external_scripts = [
‘https://buttons.github.io/buttons.js’,
{
‘src’: ‘https://code.jquery.com/jquery-3.3.1.min.js’,
‘integrity’: ‘sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=’,
‘crossorigin’: ‘anonymous’
},
]###external CSS stylesheets
external_stylesheets = [
‘https://codepen.io/chriddyp/pen/bWLwgP.css’,
{
‘href’: ‘https://use.fontawesome.com/releases/v5.0.6/css/all.css’,
‘rel’: ‘stylesheet’,
‘crossorigin’: ‘anonymous’
}
]class VideoCamera(object):
def init(self):
self.video = cv2.VideoCapture(0)def del(self):
self.video.release()def get_frame(self):
success, image = self.video.read()
ret, jpeg = cv2.imencode(’.jpg’, image)
return jpeg.tobytes()def gen(camera):
while True:
frame = camera.get_frame()
yield (b’–frame\r\n’
b’Content-Type: image/jpeg\r\n\r\n’ + frame + b’\r\n\r\n’)server = Flask(name)
app = dash.Dash(name, server=server,
external_scripts=external_scripts,
external_stylesheets=external_stylesheets)app.title = “EYE”
@server.route(’/video_feed’)
def video_feed():
return Response(gen(VideoCamera()),
mimetype=‘multipart/x-mixed-replace; boundary=frame’)app.layout = html.Div(
html.Div([
html.Div([
html.Aside(className=“main-sidebar col-12 col-md-3 col-lg-2 px-0”)
]),
html.Div(className=‘main-navbar’,children=[
html.Nav(className=‘navbar align-items-stretch navbar-light bg-white flex-md-nowrap border-bottom p-0’,children=[
html.A(className=‘navbar-brand w-100 mr-0’,
href=’#’,
style= {‘line-height: 25px;’},children=[
html.Div(className=‘d-table m-auto’,children=[
html.Img(id=‘main-logo’,
className=‘d-inline-block align-top mr-1’,
style= {‘max-width: 145px;’},
src=‘images/Logo.png’,
alt=‘Shards Dashboard’)
])]),
html.A(className=‘toggle-sidebar d-sm-inline d-md-none d-lg-none’,children=[
html.I(className=‘material-icons’)])])])
])
)if __ name__ == ‘__ main__’:
app.run_server(debug=True)
Posts: 1
Participants: 1