Coder Social home page Coder Social logo

synnkfps / tampinha-reader-opencv2 Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 284 KB

little project to make coca cola caps codes easier to read (free coke)

License: GNU General Public License v3.0

Python 100.00%
coca-cola coke np npy numpy open opencv opencv2 python reader

tampinha-reader-opencv2's Introduction

Tampinha Reader ๐Ÿพ

Little project to make coca cola caps (tampinhas) codes easier to read (free coke)

๐Ÿ˜Ž How to use?

  1. take a photo of your cap code, it must fill the requirements on the inputs folder documentation
  2. put the photo on the inputs folder
  3. go to the main file, and edit the image variable with the name of your image (cv2.imread("name of the image.jpg"))
  4. run the file

Program Documentation

This program consists of two files: main.py and stroker.py. Each file has its own functionality and set of variables. Below, you'll find an overview of how both files work, their variables, and what each setting does.

main.py

This file contains the main pipeline for image processing and thresholding. It utilizes the OpenCV library to perform various operations on the input image.

Variables

  • INPUT_NAME: Name of the input image file (e.g., '2.jpg')
  • OUTPUT_NAME: Name of the output image file (e.g., '2.png')
  • WRITE: Boolean flag to enable/disable writing the output image to a file
  • SHOW: Boolean flag to enable/disable displaying the thresholded image
  • SCALE: Scaling factor for resizing the image
  • settings: Dictionary containing various settings for image processing, such as zoom level, exposure, block size, adaptive thresholding, and adaptive method

zoom_image Function

  • zoom_image(img, zoom=1): Zooms the input image by a specified factor. It uses the cv2.getRotationMatrix2D and cv2.warpAffine functions to achieve the zoom effect.

render Function

This function represents the rendering pipeline, which processes the input image and displays the thresholded image.

Window Properties

  • The window named 'Thresholded Image' is created with the cv2.namedWindow function.
  • The window size is set using cv2.resizeWindow.
  • The window property is set to cv2.WINDOW_NORMAL to allow resizing.

Trackbars and Callbacks

  • Trackbars are created using the cv2.createTrackbar function.
  • The lambda trick is used to update the corresponding settings dictionary and trigger the render function.
  • Trackbars are provided for adjusting the exposure, block size, adaptive thresholding, adaptive method, and zoom level.

Window Closing

  • The cv2.waitKey function waits for a key press.
  • The cv2.destroyAllWindows function is used to close all created windows.

stroker.py

This file contains the main pipeline for stroke detection and visualization. It utilizes the OpenCV library for image processing.

Variables

  • INPUT: Name of the input image file (e.g., '2.png')
  • settings: Dictionary containing various settings for stroke detection, such as step size, rectangle width and height, and options for displaying and filling unset areas.
  • colors: Dictionary containing color values (BGR) for empty areas.

render Function

This function represents the rendering pipeline for stroke detection. It loads the input image, performs necessary preprocessing, and detects strokes using rectangle calculations.

Window Properties

  • The window named 'image' is created with the cv2.namedWindow function.
  • The window property is set to cv2.WINDOW_NORMAL to allow resizing.

Trackbars and Callbacks

  • Trackbars are created using the cv2.createTrackbar function.
  • The lambda trick is used to update the corresponding settings dictionary and trigger the render function.
  • Trackbars are provided for adjusting the step size, rectangle width and height.

Grid Trackbars

  • Another window named 'grid' is created to control grid-related settings.
  • Trackbars are provided for showing/filling empty areas, and adjusting color values for empty areas.

Window Closing

  • The cv2.waitKey function waits for a key press.
  • The cv2.destroyAllWindows function is used to close all created windows.

tampinha-reader-opencv2's People

Contributors

synnkfps avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

tampinha-reader-opencv2's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.