Skip to content

Instantly share code, notes, and snippets.

@kduy
kduy / contour_center_scale.py
Last active November 22, 2017 11:44
get , scale and draw center of a contour
def get_cnt_center(img, c): # image img and contour c
M = cv2.moments(c)
# cX, cY of center
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
# draw the contour and center of the shape on the image
cv2.drawContours(img, [c], -1, (0, 255, 0), 2)
cv2.circle(img, (cX, cY), 7, (255, 255, 255), -1)
cv2.putText(img, "center", (cX - 20, cY - 20),

Install

sudo apt-get install nginx gunicorn

Project base

$BASE=/home/ubuntu/project/CracksDetection

export $BASE=/path/to/project/

Flask

File $BASE/sample.py

from flask import Flask
@kduy
kduy / Agnoster theme
Last active July 4, 2018 09:51 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)
Agnoster
https://medium.com/@genealabs/agnoster-theme-on-os-x-391d60effaf6
https://gist.github.com/renshuki/3cf3de6e7f00fa7e744a
@kduy
kduy / Sobel.matlab
Last active November 22, 2017 11:44
Image processing - Matlab
%Findout Gradient Magnitude of the images using Sobel mask
function [gx,gy,mag,phi] = Gradients(gray)
gray = double(gray);
horzmask = fspecial('sobel');
% vertmask = horzmask';
gx = imfilter(gray,horzmask,'replicate');
gy = imfilter(gray,horzmask','replicate');
phi = (atan2((gy),(gx)));
@kduy
kduy / 0_reuse_code.js
Created February 21, 2017 08:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kduy
kduy / Code Scheme - Intellij
Last active November 22, 2017 11:44
Code Scheme
<code_scheme name="my_project">
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" />
<GroovyCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" />
</GroovyCodeStyleSettings>
<JavaCodeStyleSettings>
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
for i in $(ls ./)
do
new_name="${i/replace_this/with_this}"
echo $new_name
$(mv "./$i" "./$new_name")
done
@kduy
kduy / model.py
Created August 21, 2016 15:32 — forked from ck196/model.py
from __future__ import division, print_function, absolute_import
import pickle
import numpy as np
from PIL import Image
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
@kduy
kduy / Vagrant Setup.md
Created June 7, 2016 08:47 — forked from dergachev/README.md
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM