Sheet Counter is a Streamlit application designed to count the number of sheets in a given video or image. The app uses computer vision techniques to detect and count horizontal lines, which represent sheets in the input media. There are two versions of the app available: one built using Streamlit and the other using Tkinter. The Streamlit app is more user-friendly and provides a better user experience, while the Tkinter app is more lightweight and can be used for quick testing. I developed the tkinter app first, and then I decided to build a more user-friendly version using Streamlit. 😅
Want a demo? Check out the Streamlit app or the demo video.
Want a detailed understanding of the code? Check out the Project Report.
The code first reads the input video frame by frame and increases contrast to make the horizontal lines more visible. The frame is then passed to the Canny Edge Detector to detect the edges, and then Probabilistic Hough Line Transform is used to get the lines representing the edges. The code then filters out the non-horizontal lines and then using the y coordinates of mid-points of the lines, DBSCAN performs clustering to group lines on similar y coordinates as distinct sheets. The number of clusters is then counted to get the number of sheets in the frame.
- Clone the repository into a folder:
git clone https://github.com/soumyadeepbose/sheet-counter.git
- Navigate to the project directory, and install the required dependencies:
pip install -r requirements.txt
- Now run the streamlit app:
streamlit run app.py
- Alternatively, you can run the app using the following command:
python main.py
- Select the video or image file you want to upload.
- Click the "Process Video" button to start the sheet counting process.
- Grab a quick coffee and wait for the results to appear.
- View the result and the frame with the most sheets detected.
- Click on the "Choose Video" button to select the video file you want to upload. Please note that you can't use the Tkinter app for image processing.
- Grab a quick coffee and wait a while.
- The sheet counter will be displayed in the right text area.
- The frame with the most sheets detected will be displayed as a new frame.