![]() ![]() ![]() Let's integrate your OpenCV program into Streamlit. ![]() Integrate Streamlit into Your OpenCV Project There are other components also apart from these. St.sidebar.title(), st.sidebar.checkbox(), st.sidebar.slider() In order to place components in the sidepanel, you can do as follows: The default is a simple linear layout where you can place components on the webpage in a sequential manner.įor example, st.title(), st.checkbox(), st.slider() places the components on the main page in the order they're called. If you see the code, it's very straightforward. ![]() Local URL: Network URL: Ĭlick on the links in the output to open the Streamlit app in your browser. You can now view your Streamlit app in your browser. You should get a similar output as follows. To start a streamlit app, simply run the command streamlit run with the filename - for example: streamlit run demo-app.py Open an editor and copy-paste this to demo-app.py import streamlit as st st.title( "OpenCV Demo App" ) st.subheader( "This app allows you to play with Image filters!" ) st.text( "We use OpenCV and Streamlit for this demo" ) if st.checkbox( "Main Checkbox" ): st.text( "Check Box Active" ) slider_value = st.slider( "Slider", min_value = 0.5, max_value = 3.5 ) st.text( f "Slider value is " ) st.sidebar.text( "text on side panel" ) st.sidebar.checkbox( "Side Panel Checkbox" ) Show me the code.” So, let's see some code. They have some caching and optimizations, but this simple design makes it easy to build interactive webpages using Streamlit. The way Streamlit works is that it reruns the Python script every time a user interacts with the components. This makes it super easy to code up something real quick. Streamlit offers some common UI components out of the box that you can place on your webpage. cv2.waitKey(0) is to wait till the user presses any key, after which the program is exited. Finally, the image is displayed using cv2.imshow(). This program reads the image from the filepath using cv2.imread() then, it passes the image to these functions that do the processing. However, feel free to jump to the OpenCV documentation to know more details about them. I'm not explaining in-depth about them and the various parameters they accept since this tutorial is more focused on integrating OpenCV with Streamlit. These functions make use of the OpenCV functions to do the actual processing - for e.g.: cv2.GaussianBlur, etc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |