Skip to content

Instantly share code, notes, and snippets.

View dynamicguy's full-sized avatar
🎯
Focusing

Nurul Ferdous dynamicguy

🎯
Focusing
View GitHub Profile
@dynamicguy
dynamicguy / install-opencv-2.4.11-in-ubuntu.sh
Last active April 3, 2024 20:20
install opencv-2.4.11 in ubuntu
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
@dynamicguy
dynamicguy / lock_mac_dock
Created July 23, 2014 15:11
lock mac dock
defaults write com.apple.Dock contents-immutable -bool yes
defaults write com.apple.Dock size-immutable -bool yes
defaults write com.apple.Dock position-immutable -bool yes
@dynamicguy
dynamicguy / text_cleaner.py
Created April 10, 2023 11:07
remove standard noise from text
def text_cleaner(text):
rules = [
{r'>\s+': u'>'}, # remove spaces after a tag opens or closes
{r'\s+': u' '}, # replace consecutive spaces
{r'\s*<br\s*/?>\s*': u'\n'}, # newline after a <br>
{r'</(div)\s*>\s*': u'\n'}, # newline after </p> and </div> and <h1/>...
{r'</(p|h\d)\s*>\s*': u'\n\n'}, # newline after </p> and </div> and <h1/>...
{r'<head>.*<\s*(/head|body)[^>]*>': u''}, # remove <head> to </head>
{r'<a\s+href="([^"]+)"[^>]*>.*</a>': r'\1'}, # show links instead of texts
{r'[ \t]*<[^<]*?/?>': u''}, # remove remaining tags
@dynamicguy
dynamicguy / s3batch.rb
Last active April 6, 2023 18:17
batch update s3 objects metadata with proper mime-type
#!/usr/bin/env ruby
require 'aws-sdk-s3'
require 'rack'
class BucketListObjectsWrapper
attr_reader :bucket
def initialize(bucket)
@bucket = bucket
@dynamicguy
dynamicguy / ocr.ipynb
Created May 26, 2022 04:57 — forked from hxy9243/ocr.ipynb
Excel OCR example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dynamicguy
dynamicguy / mysql-workbench-export-laravel-5-migrations.py
Created July 10, 2019 09:17
mysql-workbench-export-laravel-5-migrations
# -*- coding: utf-8 -*-
# MySQL Workbench module
# A MySQL Workbench plugin which exports a Model to Laravel 5 Migrations
# Written in MySQL Workbench 6.3.6
# Support for MySQL Workbench 8.0 added
import cStringIO
import glob
import grt
# Basic
sudo apt-get -y update
sudo apt-get -qq install -y build-essential
# OpenCV
sudo apt-get -qq install -y libopencv-dev
sudo apt-get -qq install -y libtesseract-dev
# General dependencies
sudo apt-get -qq install -y libatlas-base-dev libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get -qq install -y --no-install-recommends libboost-all-dev
# Remaining dependencies, 14.04
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
get_info() function reads the image using openCV and performs thresholding, dilation, noise removal, and
contouring to finally retrieve bounding boxes from the contour.
Below are some of the additional available functions from openCV for preprocessing:
Median filter: median filter blurs out noises by taking the medium from a set of pixels
cv2.medianBlur()