11/09/2018

How to mount extra hdd permanently

> sudo -I blkid
/dev/sdb1: UUID="0687f976-6efe-4ac5-88dd-8fd863f8b8bf" TYPE="ext4" PARTUUID="1569f982-01"/dev/sda1: LABEL="cloudimg-rootfs" UUID="8ae3d910-2d2a-492d-8667-d0fa24e4d357" TYPE="ext4" PARTUUID="05ae307a-01"/dev/sdc1: UUID="e8abbf34-2cb2-471f-bac6-2a5caec81ad8" TYPE="ext4" PARTUUID="4c4db30a-01"




check uuid that you want to mount
>sudo nano /etc/fstab
Add this string end of file, but uuid must be your value, and ext4 also should be same with blkid information

UUID=e8abbf34-2cb2-471f-bac6-2a5caec81ad8 /media/datadisk ext4 defults,nofail    0       2

Thank you.



11/04/2018

OpenCV python, SuperPixel example source code. (usage of createSuperpixelSEEDS)

input image



output image

 
 


source code

import cv2 as cv
import numpy as np
import sys
import random


#read image
img = cv.imread('izone_oy.png')
converted_img = cv.cvtColor(img, cv.COLOR_BGR2HSV)

height,width,channels = converted_img.shape
num_iterations = 6
prior = 2
double_step = False
num_superpixels = 200
num_levels = 4
num_histogram_bins = 5

seeds = cv.ximgproc.createSuperpixelSEEDS(width, height, channels, num_superpixels, num_levels, prior, num_histogram_bins)
color_img = np.zeros((height,width,3), np.uint8)
color_img[:] = (0, 0, 255)
seeds.iterate(converted_img, num_iterations)

# retrieve the segmentation result
labels = seeds.getLabels()

# labels output: use the last x bits to determine the color
num_label_bits = 2
labels &= (1<<num_label_bits)-1
labels *= 1<<(16-num_label_bits)

mask = seeds.getLabelContourMask(False)

# stitch foreground & background together
mask_inv = cv.bitwise_not(mask)
result_bg = cv.bitwise_and(img, img, mask=mask_inv)
result_fg = cv.bitwise_and(color_img, color_img, mask=mask)
result = cv.add(result_bg, result_fg)

cv.namedWindow('mask',0)
cv.namedWindow('result_bg',0)
cv.namedWindow('result_fg',0)
cv.namedWindow('result',0)

cv.imshow('mask',mask_inv)
cv.imshow('result_bg',result_bg)
cv.imshow('result_fg',result_fg)
cv.imshow('result',result)

cv.imwrite('mask.jpg',mask_inv)
cv.imwrite('result_bg.jpg',result_bg)
cv.imwrite('result_fg.jpg',result_fg)
cv.imwrite('result.jpg',result)

cv.waitKey(0)


reference
https://docs.opencv.org/3.0-beta/modules/ximgproc/doc/superpixels.html
https://github.com/opencv/opencv_contrib/blob/master/samples/python2/seeds.py




TypeError: Incorrect type of self (must be 'Feature2D' or its derivative), FastFeatureDetector

This is because of opencv version difference.
Some function is changed as XX_create().
Refer to below code. This is case of FastFeatureDetector.
Thank you.

fast = cv2.FastFeatureDetector_create() # <- FastFeatureDetector()
kp = fast.detect(blurGrayMat)