Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
@christianroman
christianroman / test.py
Created May 30, 2013
Bypass Captcha using 10 lines of code with Python, OpenCV & Tesseract OCR engine
View test.py
import cv2.cv as cv
import tesseract
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE)
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY)
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
tesseract.SetCvImage(gray,api)
print api.GetUTF8Text()
View UIImage+ImageEffects.m
//
// UIImage+ImageEffects.m
// AnimationExamples
//
// Created by Timothy Patrick Johnson on 7/3/13.
// Copyright (c) 2013 Meister. All rights reserved.
//
#import "UIImage+ImageEffects.h"
@christianroman
christianroman / training.sh
Last active Oct 26, 2021
Tesseract OCR training new font
View training.sh
#! /bin/bash
# build the environment
mkdir tessenv; cd tessenv
TROOT=`pwd`
mkdir $TROOT/stockfonts; mkdir $TROOT/build; mkdir $TROOT/build/eng
echo "Environment built"
# Get the stock english fonts from Google (old, but they work)
cd $TROOT/stockfonts
GET http://tesseract-ocr.googlecode.com/files/boxtiff-2.01.eng.tar.gz > boxtiff-2.01.eng.tar.gz
@christianroman
christianroman / server.py
Last active Jun 12, 2021
Rompiendo Captcha de CURP usando Python, OpenCV, Tesseract OCR y Tornado
View server.py
import tornado.ioloop
import tornado.web
import urllib2 as urllib
from PIL import Image
from cStringIO import StringIO
import numpy as np
import tesserwrap
import cv2
class MainHandler(tornado.web.RequestHandler):
@christianroman
christianroman / OCR.java
Created May 15, 2012
Captcha OCR + Tessaract Complex
View OCR.java
public class OCR {
private static final String INPUT = "C:/captcha/ex.png";
private static final String OUTPUT = "C:/captcha/captcha-out.png";
private static final String TESSERACT_BIN = "C:/Program Files/Tesseract-OCR/tesseract.exe";
private static final String TESSERACT_OUTPUT = "C:/captcha/out.txt";
private static final int WHITE = 0x00FFFFFF, BLACK = 0x00000000;
public static void main(String... args) throws Exception {
BufferedImage image = ImageIO.read(new FileInputStream(INPUT));
int average = 0;
View apple-pay-mexico.sh
#!/bin/bash
#  Country code
CC="MX"
URL="https://smp-device-content.apple.com/static/region/v2/config.json"
HOME_PAGE="https://www.apple.com/mx/apple-pay"
FOUND=false
function check {
RET=$(curl -s $URL | jq .SupportedRegions.$CC)
@christianroman
christianroman / gist:6516864
Last active Feb 10, 2020
Install PostgreSQL 9.3.1 + PostGIS + PGRouting on CentOS 6.4
View gist:6516864
rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum install postgresql93 postgresql93-server postgresql93-contrib postgresql93-devel postgis2_93 postgis2_93-utils
#Configure PostgreSQL
chkconfig postgresql-9.3 on
service postgresql-9.3 initdb
service postgresql-9.3 start
# Create PostGIS template
@christianroman
christianroman / OCR.java
Created May 15, 2012
Captcha OCR + Tesseract
View OCR.java
public class OCR {
private static final String INPUT = "C:/captcha/ex.png";
private static final String OUTPUT = "C:/captcha/captcha-out.png";
private static final String TESSERACT_BIN = "C:/Program Files/Tesseract-OCR/tesseract.exe";
private static final String TESSERACT_OUTPUT = "C:/captcha/out.txt";
private static final int WHITE = 0x00FFFFFF, BLACK = 0x00000000;
public static void main(String... args) throws Exception {
BufferedImage image = ImageIO.read(new FileInputStream(INPUT));
int average = 0;
@christianroman
christianroman / blur.rb
Created Oct 11, 2013
Blurring images in Rails with Paperclip custom processor
View blur.rb
module Paperclip
class Blur < Processor
def initialize file, options = {}, attachment = nil
super
@format = File.extname(@file.path)
@basename = File.basename(@file.path, @format)
end
View NSString+Concatenation.h
#import <Foundation/Foundation.h>
@interface NSString (Concatenation)
- (NSString *):(NSString *)a;
- (NSString *):(NSString *)a :(NSString *)b;
- (NSString *):(NSString *)a :(NSString *)b :(NSString *)c;
- (NSString *):(NSString *)a :(NSString *)b :(NSString *)c :(NSString *)d;
- (NSString *)concat:(NSString *)strings, ...;