10/17/2018

python float decimal expression (tip)

Tip!

print('{} - {:.4f}'.format(11, 0.12314213))

> 11 - 0.1231



Exclude files that you don't want to show in directory window in VS CODE (The tip for I don't want to see ._* files in vs code)

You can set exclude file pattern in exclude tab in settings.


go to preferences -> settings



find exclude menu and add pattern that you don't want to see.
press 'ok' button and it will work immediately.

Thank you.

10/13/2018

python, get index and value in for loop

Use 'enumerate'

for index, item in enumerate(values):
print(index, item)

Python opencv, get ROI Mat (cropping)

Please refer to this function..

def getROImat(inMat, x1, y1, x2, y2):
# Crop image
imCrop = inMat[int(y1):int(y2), int(x1):int(x2)]
return imCrop


10/10/2018

pbtxt file for coco v2 data (90 categories contents)

item {
  name: "/m/01g317"
  id: 1
  display_name: "person"
}
item {
  name: "/m/0199g"
  id: 2
  display_name: "bicycle"
}
item {
  name: "/m/0k4j"
  id: 3
  display_name: "car"
}
item {
  name: "/m/04_sv"
  id: 4
  display_name: "motorcycle"
}
item {
  name: "/m/05czz6l"
  id: 5
  display_name: "airplane"
}
item {
  name: "/m/01bjv"
  id: 6
  display_name: "bus"
}
item {
  name: "/m/07jdr"
  id: 7
  display_name: "train"
}
item {
  name: "/m/07r04"
  id: 8
  display_name: "truck"
}
item {
  name: "/m/019jd"
  id: 9
  display_name: "boat"
}
item {
  name: "/m/015qff"
  id: 10
  display_name: "traffic light"
}
item {
  name: "/m/01pns0"
  id: 11
  display_name: "fire hydrant"
}
item {
  name: "/m/02pv19"
  id: 13
  display_name: "stop sign"
}
item {
  name: "/m/015qbp"
  id: 14
  display_name: "parking meter"
}
item {
  name: "/m/0cvnqh"
  id: 15
  display_name: "bench"
}
item {
  name: "/m/015p6"
  id: 16
  display_name: "bird"
}
item {
  name: "/m/01yrx"
  id: 17
  display_name: "cat"
}
item {
  name: "/m/0bt9lr"
  id: 18
  display_name: "dog"
}
item {
  name: "/m/03k3r"
  id: 19
  display_name: "horse"
}
item {
  name: "/m/07bgp"
  id: 20
  display_name: "sheep"
}
item {
  name: "/m/01xq0k1"
  id: 21
  display_name: "cow"
}
item {
  name: "/m/0bwd_0j"
  id: 22
  display_name: "elephant"
}
item {
  name: "/m/01dws"
  id: 23
  display_name: "bear"
}
item {
  name: "/m/0898b"
  id: 24
  display_name: "zebra"
}
item {
  name: "/m/03bk1"
  id: 25
  display_name: "giraffe"
}
item {
  name: "/m/01940j"
  id: 27
  display_name: "backpack"
}
item {
  name: "/m/0hnnb"
  id: 28
  display_name: "umbrella"
}
item {
  name: "/m/080hkjn"
  id: 31
  display_name: "handbag"
}
item {
  name: "/m/01rkbr"
  id: 32
  display_name: "tie"
}
item {
  name: "/m/01s55n"
  id: 33
  display_name: "suitcase"
}
item {
  name: "/m/02wmf"
  id: 34
  display_name: "frisbee"
}
item {
  name: "/m/071p9"
  id: 35
  display_name: "skis"
}
item {
  name: "/m/06__v"
  id: 36
  display_name: "snowboard"
}
item {
  name: "/m/018xm"
  id: 37
  display_name: "sports ball"
}
item {
  name: "/m/02zt3"
  id: 38
  display_name: "kite"
}
item {
  name: "/m/03g8mr"
  id: 39
  display_name: "baseball bat"
}
item {
  name: "/m/03grzl"
  id: 40
  display_name: "baseball glove"
}
item {
  name: "/m/06_fw"
  id: 41
  display_name: "skateboard"
}
item {
  name: "/m/019w40"
  id: 42
  display_name: "surfboard"
}
item {
  name: "/m/0dv9c"
  id: 43
  display_name: "tennis racket"
}
item {
  name: "/m/04dr76w"
  id: 44
  display_name: "bottle"
}
item {
  name: "/m/09tvcd"
  id: 46
  display_name: "wine glass"
}
item {
  name: "/m/08gqpm"
  id: 47
  display_name: "cup"
}
item {
  name: "/m/0dt3t"
  id: 48
  display_name: "fork"
}
item {
  name: "/m/04ctx"
  id: 49
  display_name: "knife"
}
item {
  name: "/m/0cmx8"
  id: 50
  display_name: "spoon"
}
item {
  name: "/m/04kkgm"
  id: 51
  display_name: "bowl"
}
item {
  name: "/m/09qck"
  id: 52
  display_name: "banana"
}
item {
  name: "/m/014j1m"
  id: 53
  display_name: "apple"
}
item {
  name: "/m/0l515"
  id: 54
  display_name: "sandwich"
}
item {
  name: "/m/0cyhj_"
  id: 55
  display_name: "orange"
}
item {
  name: "/m/0hkxq"
  id: 56
  display_name: "broccoli"
}
item {
  name: "/m/0fj52s"
  id: 57
  display_name: "carrot"
}
item {
  name: "/m/01b9xk"
  id: 58
  display_name: "hot dog"
}
item {
  name: "/m/0663v"
  id: 59
  display_name: "pizza"
}
item {
  name: "/m/0jy4k"
  id: 60
  display_name: "donut"
}
item {
  name: "/m/0fszt"
  id: 61
  display_name: "cake"
}
item {
  name: "/m/01mzpv"
  id: 62
  display_name: "chair"
}
item {
  name: "/m/02crq1"
  id: 63
  display_name: "couch"
}
item {
  name: "/m/03fp41"
  id: 64
  display_name: "potted plant"
}
item {
  name: "/m/03ssj5"
  id: 65
  display_name: "bed"
}
item {
  name: "/m/04bcr3"
  id: 67
  display_name: "dining table"
}
item {
  name: "/m/09g1w"
  id: 70
  display_name: "toilet"
}
item {
  name: "/m/07c52"
  id: 72
  display_name: "tv"
}
item {
  name: "/m/01c648"
  id: 73
  display_name: "laptop"
}
item {
  name: "/m/020lf"
  id: 74
  display_name: "mouse"
}
item {
  name: "/m/0qjjc"
  id: 75
  display_name: "remote"
}
item {
  name: "/m/01m2v"
  id: 76
  display_name: "keyboard"
}
item {
  name: "/m/050k8"
  id: 77
  display_name: "cell phone"
}
item {
  name: "/m/0fx9l"
  id: 78
  display_name: "microwave"
}
item {
  name: "/m/029bxz"
  id: 79
  display_name: "oven"
}
item {
  name: "/m/01k6s3"
  id: 80
  display_name: "toaster"
}
item {
  name: "/m/0130jx"
  id: 81
  display_name: "sink"
}
item {
  name: "/m/040b_t"
  id: 82
  display_name: "refrigerator"
}
item {
  name: "/m/0bt_c3"
  id: 84
  display_name: "book"
}
item {
  name: "/m/01x3z"
  id: 85
  display_name: "clock"
}
item {
  name: "/m/02s195"
  id: 86
  display_name: "vase"
}
item {
  name: "/m/01lsmm"
  id: 87
  display_name: "scissors"
}
item {
  name: "/m/0kmg4"
  id: 88
  display_name: "teddy bear"
}
item {
  name: "/m/03wvsk"
  id: 89
  display_name: "hair drier"
}
item {
  name: "/m/012xff"
  id: 90
  display_name: "toothbrush"
}

10/09/2018

google object detection api - error : Value Error: First Step Cannot Be Zero


This error is because of
schedule{
 step:0
 learning_rate: 0.00019...
}

So just change whole optimizer block to latest models optimizer block.
(This code is in the config file!)

before
optimizer {
momentum_optimizer {
learning_rate {
manual_step_learning_rate {
initial_learning_rate: 0.000199999994948
schedule {
step: 0
learning_rate: 0.000199999994948
}
schedule {
step: 900000
learning_rate: 1.99999994948e-05
}
schedule {
step: 1200000
learning_rate: 1.99999999495e-06
}
}
}
momentum_optimizer_value: 0.899999976158
}
use_moving_average: false
}


modified (example)
optimizer {
momentum_optimizer {
learning_rate {
cosine_decay_learning_rate {
learning_rate_base: 0.0399999991059
total_steps: 25000
warmup_learning_rate: 0.0133330002427
warmup_steps: 2000
}
}
momentum_optimizer_value: 0.899999976158
}
use_moving_average: false
}

or make step 0-> step 100 or something else, (not zero)


refer to this article
https://github.com/tensorflow/models/issues/3794

10/03/2018

show all PYTHONPATH in command line (tip)



python -c "import sys; print(sys.path)"
or
echo $PYTHONPATH

has type str, but expected one of: bytes (tf.train.Example)

make str to bytes

for example
#String to bytes
my_str = "file name"
my_str_as_bytes = str.encode(my_str)
type(my_str_as_bytes) # ensure it is byte representation
#byte to string
my_decoded_str = my_str_as_bytes.decode()
type(my_decoded_str) # ensure it is string representation

Pandas simple tip

import pandas

read csv file without header
df = pandas.read_csv('./train.csv', header=None, index_col=False)
print(df)

                0     1     2     3     4      5
0    0101_003.png   770   946  2070  2973  table
1    0110_099.png   270  1653  2280  2580  table
2    0113_013.png   303   343  2273  2953  table
3    0140_007.png   664  1782  1814  2076  table
4    0146_281.png   704   432  1744  1552  table
5    0146_281.png   682  1740  1800  2440  table
6    0147_090.png   326   413  2106  1616  table
7    0147_090.png   760  1843  1643  2393  table
8    0147_125.png   310   338  2310   912  table
9    0147_125.png   754  1184  1798  1514  table
10   0147_256.png   590   366  1940  1520  table
..            ...   ...   ...   ...   ...    ...
410  9529_050.png   104  2234  2040  2512  table
411  9530_051.png    90   470  2394  1682  table
412  9531_070.png   166   368  2328  1088  table
413  9531_070.png   148  1100  2340  1788  table
414  9531_073.png    50   260  2336  2876  table
415  9532_146.png   563   490  2440  2853  table
416  9533_038.png  1278   454  2326  1358  table
417  9533_038.png  1270  1774  2328  2368  table

[418 rows x 6 columns]

several way to read first column
print(df[0].tolist())
print(df.values.tolist()[:][0])
print(df.iloc[:,0].values.tolist())

['0101_003.png', '0110_099.png', '0113_013.png', '0140_007.png', '0146_281.png', '0146_281.png', '0147_090.png', '0147_090.png', '0147_125.png', '0147_125.png', '0147_256.png', '0147_256.png', '0148_271.png', '0148_479.png', '0151_180.png', '0151_208.png', '0154_080.png', '0154_474.png', '0155_081.png', '0199_384.png', '0203_075.png', '0206_007.png', '0206_048.png',
...
'9522_041.png', '9522_055.png', '9522_055.png', '9525_037.png', '9525_043.png', '9525_043.png', '9525_043.png', '9526_017.png', '9526_028.png', '9526_028.png', '9526_028.png', '9527_018.png', '9527_024.png', '9527_024.png', '9528_043.png', '9528_043.png', '9528_061.png', '9528_061.png', '9528_061.png', '9529_050.png', '9529_050.png', '9529_050.png', '9530_051.png', '9531_070.png', '9531_070.png', '9531_073.png', '9532_146.png', '9533_038.png', '9533_038.png']

pandas for each row
for index, row in df.iterrows():
print(index, row[0], row[1])

0 0101_003.png 770
1 0110_099.png 270
2 0113_013.png 303
3 0140_007.png 664
4 0146_281.png 704
5 0146_281.png 682
6 0147_090.png 326
7 0147_090.png 760
8 0147_125.png 310
9 0147_125.png 754
10 0147_256.png 590
11 0147_256.png 368
...



10/02/2018

Jupyter notebook ip and port setting (tip)

ipython notebook --ip=0.0.0.0 --port=80
or
jupyter notebook --ip=0.0.0.0 --port=80


object_detection/protos/*.proto: No such file or directory

move to this directory :
cd models/research

and try it again
protoc object_detection/protos/*.proto --python_out=.
good luck!


9/24/2018

python webacm canny edge, laplacian and adaptive threshold test

source code is here


import numpy as np
import cv2

from matplotlib import pyplot as plt
cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    if frame is None:
        continue

    frame = cv2.resize(frame, (320,240))
    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    edges = cv2.Canny(gray.copy(),threshold1=50, threshold2=150,apertureSize = 3)


    #sobel
    laplacian = cv2.Laplacian(gray.copy(),cv2.CV_8U,13)
    #kernel = np.ones((3,3),np.uint8)
    #laplacian = cv2.dilate(laplacian,kernel,iterations = 1)

    im_th1 = cv2.adaptiveThreshold(gray.copy(), 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, \
                                   cv2.THRESH_BINARY, 5, 2)
    
    # Display the resulting frame
    #edges = cv2.Canny(gray.copy(),threshold1=50, threshold2=150,apertureSize = 3)
    tempImg = cv2.medianBlur(gray, 5)
    im_th1 = cv2.adaptiveThreshold(tempImg, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, \
                                cv2.THRESH_BINARY, 5, 2)

    blur = cv2.GaussianBlur(im_th1, (5, 5), 0)
    _, im_th2 = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
    
    
    numpy_horizontal = np.hstack((gray, edges, laplacian, im_th2))

    cv2.imshow('Numpy Horizontal', numpy_horizontal)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()


result



9/22/2018

QRcode & Barcode generation example source code by Python



#########################
#qr code creator example
#pip install pillow
#pip install qrcode
#https://pypi.org/project/qrcode/# 
import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('http://webapp.marearts.com')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save("qr.png")


#########################
#barcode creator example
#pip install python-barcode
#https://pypi.org/project/python-barcode/

import barcode
from barcode.writer import ImageWriter
EAN = barcode.get_barcode_class('ean13')
ean = EAN('5901234123457', writer=ImageWriter()) #13 digits number only
fullname = ean.save('barcode')

you can test this source code on here: http://www.marearts.com/webapp/qrcode/






9/18/2018

How to make Mat in opencv python

newMat_3ch = np.zeros((rows, cols, 3), dtype = "uint8") #3channel
newMat_1ch = np.zeros((rows, cols), dtype = "uint8") #1channel

Mat is just numpy array.

9/17/2018

python get file list in directory

from os import listdir
from os.path import isfile, join
mypath = "./customer_sample"
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
print(onlyfiles)

result
['._s1.pdf', 's2.pdf', '._s2.pdf', '._s7.pdf', 's8.pdf', '._s8.pdf', '._s9.pdf', 's10.pdf', '._s10.pdf', 's1_p0.jpg', 's9.pdf', '._s1_p0.jpg', '._s4.pdf', 's5.pdf', '._s5.pdf', 's6.pdf', '._s6.pdf', 's7.pdf', '._s3.pdf', 's4.pdf', 's2_p0.jpg', 's2_p1.jpg', 's3_p0.jpg', 's3.pdf', 's3_p1.jpg', 's3_p2.jpg', 's1.pdf', 's3_p3.jpg']

9/15/2018

python 1 line code for N random number (tip)

Make 1~100 random integer as 10 loops


import random
myr = [random.randrange(1, 100) for _ in range(10)]
print(myr)

result
[9, 67, 32, 55, 79, 47, 86, 62, 95, 30]

Thank you. ^^


8/20/2018

python numpy to CSV, numpy to pandas, pandas to CSV

Sample code for
- numpy to CSV
- numpy to pandas
- pandas to CSV



import numpy as np
import pandas as pd

f1_numpy = "./data/test1.csv"
f2_pandas = "./data/test2.csv"

#numpy to csv
np.savetxt(f1_numpy, np.array([10,20]))
print(f1_numpy)

#numpy to pandas and csv
pda = pd.DataFrame(np.array([10,20]), columns=['data'])
pda.to_csv(f2_pandas, index=False)

Thank you.

8/10/2018

opencv perspective test



This is perspective example source code.
Basically, perspective is multiple by H(homography) matrix.
Like this :
B = H*A
In here, B is perspective image, A is original image and H is homography matrix.
For this calculate, we can use opencv function this -> warpPerspective(..)
 easily.
And to find H, we also can use findHomography opencv function as well.

for more detail refer to this page:
http://study.marearts.com/2014/04/video-stabilizing-example-source-code.html
http://study.marearts.com/2011/10/sift-matching-c-source-code-using.html
http://study.marearts.com/2015/03/image-warping-using-opencv.html

and below source code:
code looks a little complicated, but just see getPerspectiveImg function carefully, other codes are just for making random and set value.

github url is here : https://github.com/MareArts/opencv_perspective_test

Thank you.

#include <stdio.h>
#include <opencv2/opencv.hpp> 
#include <string>

#ifdef _DEBUG  
#pragma comment(lib, "opencv_core331d.lib")   
#pragma comment(lib, "opencv_imgproc331d.lib")   //MAT processing  
#pragma comment(lib, "opencv_highgui331d.lib")  
#pragma comment(lib, "opencv_calib3d331d.lib") 
#pragma comment(lib, "opencv_imgcodecs331d.lib")
#else  
#pragma comment(lib, "opencv_core331.lib")  
#pragma comment(lib, "opencv_imgproc331.lib")  
#pragma comment(lib, "opencv_highgui331.lib")
#pragma comment(lib, "opencv_calib3d331.lib")
#pragma comment(lib, "opencv_imgcodecs331.lib")
#endif


//#pragma comment(lib, "opencv_objdetect246.lib")  
//#pragma comment(lib, "opencv_features2d246.lib")  


using namespace std;
using namespace cv;


bool setPt(float x1, float x2, float x3, float x4, float y1, float y2, float y3, float y4, vector< Point2f> &in)
{
 if (in.size() == 4)
 {
  in[0].x = x1;
  in[1].x = x2;
  in[2].x = x3;
  in[3].x = x4;

  in[0].y = y1;
  in[1].y = y2;
  in[2].y = y3;
  in[3].y = y4;
 }
 else {
  return false;
 }

 return true;
}


bool makeRandomPerspectivePoint(const vector< Point2f> &A, vector< Point2f> &B, Size imgSize)
{
 if (A.size() != 4 || B.size() != 4)
 {
  cout << "matrix vector error!" << endl;
  return false;
 }

 if (imgSize.width <= 0 || imgSize.height <= 0)
 {
  cout << "image size error!" << endl;
  return false;
 }

 const float maxRand = 0.4;
 int width = imgSize.width;
 int height = imgSize.height;
 int rndMarginX = width * maxRand;
 int rndMarginY = height * maxRand;

 int rx1 = rand() % rndMarginX;
 int ry1 = rand() % rndMarginY;
 int rM = rand() % 4;

 //minimum value
 if (rx1 == 0)
  rx1 = 1;
 if (ry1 == 0)
  ry1 = 1;

 //4 perspective mode
 if (rM == 0)
 {
  setPt(0, width, width, 0, 0 + ry1, 0, height, height - ry1, B);
 }
 else if (rM == 1)
 {
  setPt(0 + rx1, width - rx1, width, 0, 0, 0, height, height, B);
 }
 else if (rM == 2)
 {
  setPt(0, width, width, 0, 0, 0 + ry1, height - ry1, height, B);
 }
 else {
  setPt(0, width, width - rx1, 0 + rx1, 0, 0, height, height, B);
 }

 return true;
}

bool getPerspectiveImg(const Mat& inImg, Mat& outImg, const vector< Point2f> &A, const vector< Point2f> &B)
{
 if (A.size() != 4 || B.size() != 4)
 {
  cout << "matrix vector error!" << endl;
  return false;
 }

 //B = H*A
 Mat H = findHomography(A, B);
 //perspectiveImg = H * inImg
 warpPerspective(inImg, outImg, H, inImg.size());


 //return
 return true;
}



int main()
{
 
 string fn = "Flag_of_South_Korea.png";
 Mat testImg = imread(fn);
 srand(time(0));
 Size imgSize = testImg.size();
 vector< Point2f > opt(4);
 setPt(0, imgSize.width, imgSize.width, 0, 0, 0, imgSize.height, imgSize.height, opt);
 vector< Point2f > dpt(4);

 while (1)
 {

  if (makeRandomPerspectivePoint(opt, dpt, imgSize) == false)
   break;

  Mat outImg;
  if (getPerspectiveImg(testImg, outImg, opt, dpt)) {
   imshow("origin", testImg);
   imshow("perspective", outImg);
   waitKey(0);
  }
  else {
   cout << "matrix vector error!" << endl;
   break;
  }
 }

}

3D array numpy -> pandas ->csv -> pandas -> 3d array numpy

This article is example source code for
3D array numpy -> pandas -> csv -> pandas -> 3D array numpy

Let's see step by step


Step 1, make example data

import numpy as np
import pandas as pd


#make list
a = [[11, 12, 13, 14, 15], [15, 16, 17, 18, 19]]
b = [[21, 22, 23, 24, 25], [25, 26, 27, 28, 29]]
c = []
c.append(a)
c.append(b)
#make numpy
npa = np.array(c)
print('npa\n',npa)
print('npa shape\n',npa.shape) #2 by 2 by 5


result
npa
 [[[11 12 13 14 15]
  [15 16 17 18 19]]

 [[21 22 23 24 25]
  [25 26 27 28 29]]]
npa shape
 (2, 2, 5)


Step 2, numpy to pandas
#make numpy to panda
m,n,r = npa.shape
#numpy ->group indexing, reshape
out_arr = np.column_stack((np.repeat(np.arange(m),n),npa.reshape(m*n,-1)))
out_df = pd.DataFrame(out_arr, columns=['group','a','b','c','d','e'])
print('pnadas\n',out_df) #pandas

result

group   a   b   c   d   e
0      0  11  12  13  14  15
1      0  15  16  17  18  19
2      1  21  22  23  24  25
3      1  25  26  27  28  29


Step 3, save csv, load csv

#save to csv
out_df.to_csv('test3Dpandas.csv', index=False)
#load csv
df = pd.read_csv('test3Dpandas.csv')


Step 4, pandas to numpy

#pandas to numpy
npb = df.values
npb = npb[:,1:]
npb2 = npb.reshape(m,n,r)
print('numpy\n',npb2)

result

numpy
 [[[11 12 13 14 15]
  [15 16 17 18 19]]

 [[21 22 23 24 25]
  [25 26 27 28 29]]]







7/20/2018

get file list in the folder (example code)

example code


namespace fs = std::experimental::filesystem;

std::vector<std::string> list_files_in_dir(string dirPath)
{
 vector<string> r;
 
 for (auto & p : fs::directory_iterator(dirPath))
 {
  std::cout << p.path().string() << std::endl;
  r.push_back(p.path().string());
 }
 
 return r;
}

7/04/2018

get files list in a directory in ubuntu

refer to below code:

..
std::vector<std::string> list_files_in_dir(const char* dirPath)
        {
    DIR *dir;

    std::vector<std::string> files;

    struct dirent *ent;
    if ((dir = opendir (dirPath)) != NULL)
    {
        /* print all the files and directories within directory */
        while ((ent = readdir (dir)) != NULL)
        {
            if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0)
            {
                stringstream fullpath;
                fullpath << dirPath << "/" << ent->d_name;
                files.push_back(fullpath.str());
            }
        }
        closedir (dir);
    }
    else
    {
        /* could not open directory */
        perror ("");
        return files;
    }

    return files;
}
..

7/03/2018

opencv install on ubuntu

Simple and easy way

1. install opencv from the official site
sudo apt-get autoremove libopencv-dev python-opencv


2. download sh file
https://github.com/milq/milq/blob/master/scripts/bash/install-opencv.sh

3. run sh file
bash install-opencv.sh
4. test
cd build/bin
./example_cpp_edge ../../samples/data/fruits.jpg


That's all

Thank you.

more detail refer to here :https://milq.github.io/install-opencv-ubuntu-debian/

6/29/2018

Pycharm does not show plot

just use "plt.show()"


for example
...
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
plt.show()
...

Thank you.

6/26/2018

Install Hangul(Korean) on Utubu

type this on terminal

..
dpkg -l | grep ibus-hangul
or
sudo apt-get install ibus-hangul
..


Ubuntu CUDA install on Console

Uninstall previous version
..
sudo apt-get purge cuda
sudo apt-get purge libcudnn6
sudo apt-get purge libcudnn6-dev
..


Install cuda 9.0, cuDnn 7.0
..
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo apt-get update
sudo apt-get install cuda=9.0.176-1
sudo apt-get install libcudnn7-dev
sudo apt-get install libnccl-dev
..


Add below code the end of ./bashrc file
..
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
..

And reboot.


refer to here : https://yangcha.github.io/CUDA90/


Linux wifi driver on Mac device

just input this command


sudo apt-get update
sudo apt-get install firmware-b43-installer

Tip, uninstall virtualbox on ubuntu


find virtualbox s/w

$> dpkg -l | grep virtualbox

the name is depends on your installation name

uninstall virtualbox
$> sudo apt-get remove --purge virtualbox-5.2