improved camera
This commit is contained in:
parent
a91681dbdc
commit
6925c218b1
@ -18,5 +18,7 @@
|
||||
- https://www.tutorialspoint.com/flask
|
||||
|
||||
### Qr Code reading
|
||||
- https://circuitdigest.com/microcontroller-projects/qr-code-scanner-using-raspberry-pi-and-opencv
|
||||
|
||||
- https://circuitdigest.com/microcontroller-projects/qr-code-scanner-using-raspberry-pi-and-opencv
|
||||
### Camera stream to flask webpage
|
||||
- https://github.com/itsachrafmansari/flask_camera_stream
|
@ -37,7 +37,7 @@ while True:
|
||||
barcodeData))
|
||||
csv.flush()
|
||||
found.add(barcodeData)
|
||||
cv2.imshow("Barcode Reader", frame)
|
||||
# cv2.imshow("Barcode Reader", frame)
|
||||
key = cv2.waitKey(1) & 0xFF
|
||||
|
||||
# if the `s` key is pressed, break from the loop
|
||||
|
@ -1,10 +1,23 @@
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, Response
|
||||
import cv2
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def stream(camera_index):
|
||||
cam = cv2.VideoCapture(camera_index)
|
||||
while True:
|
||||
_, frame = cam.read()
|
||||
ret, jpg = cv2.imencode('.jpg', frame)
|
||||
jpg2bytes = jpg.tobytes()
|
||||
yield b'--frame\r\nContent-Type: image/jpeg\r\n\r\n' + jpg2bytes + b'\r\n\r\n'
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template(index.html)
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/stream_feed')
|
||||
def stream_fedd():
|
||||
return Response(stream(0), mimetype='multipart/x-mixed-replace; boundary=frame')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=5000, host='0.0.0.0')
|
||||
|
@ -1 +0,0 @@
|
||||
<img src="{{ url_for('static', filename='dinosaur_face.png') }}" alt="Dinosaur Face" style="width:100%">
|
17
website/templates/index.html
Normal file
17
website/templates/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>🔴 Streaming...</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='style.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="title">Camera Feed</div>
|
||||
<div id="camera">
|
||||
<img id="camera_feed" src="/stream_feed">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user