-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.py
More file actions
91 lines (78 loc) · 4.21 KB
/
stream.py
File metadata and controls
91 lines (78 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import numpy as np
import cv2
import streamlit as st
from PIL import Image
import imutils
import scipy.spatial as sp
from imutils import contours
from imutils import perspective
from scipy.spatial import distance as dist
from realtime import *
from static import *
from annotated_text import annotated_text
st.title("Real Time Object Measurement")
annotated_text(("open","CV","#269e98"),("with","python","#d16c06"),)
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}', unsafe_allow_html=True)
options = st.sidebar.radio("Choose",('Real','Static'))
if options == 'Real':
st.subheader("This app allows you to measure objects in real time with your webcam!")
st.text("We use OpenCV and Streamlit for this demo")
with st.sidebar:
with st.expander("INSTRUCTIONS TO USE IP WEBCAM"):
st.write("1.Download the IP Webcam App from PlayStore on your Mobile")
st.write("2.Open the App")
st.write("3.Scroll down and click on Start Server. Your Mobile's Camera will be turned on")
st.write("4.Notedown the IP Address displayed")
with st.expander("WHAT IS AN ARUCO MARKER?"):
st.write("""
An aruco marker is a fiducial marker that is placed on the object or scene being imaged.
It is a binary square with black background and boundaries and a white generated pattern within it that uniquely identifies it.
The black boundary helps making their detection easier. They can be generated in a variety of sizes.
The idea is that you print these markers and put them in the real world.
You can photograph the real world and detect these markers uniquely.
""")
st.warning("Real time measurement won't workout without arUco marker")
st.info('Please do find the instructions and link to download the arUco marker below ')
with st.expander("INSTRUCTIONS TO USE ARUCO"):
st.write("1.Download the aruco marker PDF")
st.write("2.Print the PDF")
st.write("3.Place object to be measured beside arUco marker")
st.write("4.Enter IP address")
st.write("5.Point webcam such that arUco marker and object are in the same frame")
st.write("6.Enjoy the real-time accuracy !!")
st.sidebar.subheader("Download ArucoMarker")
with open("ar6.pdf", "rb") as pdf_file:
PDFbyte = pdf_file.read()
st.sidebar.download_button(label="Aruco_Marker",
data=PDFbyte,
file_name="Aruco_marker.pdf",
mime='application/octet-stream')
st.markdown('##')
try:
live()
except:
pass
elif options == 'Static':
st.subheader("This app also allows you to measure static objects !")
with st.sidebar:
with st.expander("INSTRUCTIONS TO USE"):
st.info("""While takingapicture make sure to place your reference object on the left most part of your picture.
Your reference object can be anything of your choice,provided you know the width of the said object.""")
st.image("static_img1.jpg",caption='Coin in this particular case')
st.warning('Width of the reference object is in INCHES ')
satisfied=st.checkbox('Are you satisfied with the results?')
if satisfied:
st.snow()
st.write('Thanks :)')
try:
static()
except:
pass
st.write('<style>.css-1yjuwjr{font-size:22px;}', unsafe_allow_html=True)
st.write('<style>.st-af{font-size:1.2rem;}', unsafe_allow_html=True)
st.write('<style>.st-cw{height:1.6rem;}', unsafe_allow_html=True)
st.write('<style>.st-d2{width:1.6rem;}', unsafe_allow_html=True)
st.write('<style>.st-d6{height:8px;}', unsafe_allow_html=True)
st.write('<style>.st-d7{width:8px;}', unsafe_allow_html=True)
st.write('<style>code{font-size:1.1em;}', unsafe_allow_html=True)
st.write('<style>p{font-size:1.2rem;}', unsafe_allow_html=True)