2017年9月24日 星期日

vim顯示顏色設定


  • 「.vimrc」檔案:

執行vim時會先去執行使用者家目錄下的「.vimrc」檔案(~/.vimrc)。


  • 顏色方案(colorscheme):

vim內建顏色方案功能,可以使用「colorscheme」指令來設定vim的配色主題。
vim內建顏色方案,存在「/usr/share/vim/vim??/colors」(「??」是vim的版本號碼)目錄中,副檔名為「.vim」。

$ ll /usr/share/vim/vim74/colors/
總計 72
-rw-r--r--. 1 root root 2476 12月 22  2016 blue.vim
-rw-r--r--. 1 root root 2990 12月 22  2016 darkblue.vim
-rw-r--r--. 1 root root  548 12月 22  2016 default.vim
-rw-r--r--. 1 root root 2399 12月 22  2016 delek.vim
-rw-r--r--. 1 root root 2812 12月 22  2016 desert.vim
-rw-r--r--. 1 root root 1666 12月 22  2016 elflord.vim
-rw-r--r--. 1 root root 2476 12月 22  2016 evening.vim
-rw-r--r--. 1 root root 3476 12月 22  2016 koehler.vim
-rw-r--r--. 1 root root 2460 12月 22  2016 morning.vim
-rw-r--r--. 1 root root 2006 12月 22  2016 murphy.vim
-rw-r--r--. 1 root root 1037 12月 22  2016 pablo.vim
-rw-r--r--. 1 root root 2673 12月 22  2016 peachpuff.vim
-rw-r--r--. 1 root root 2311 12月 22  2016 README.txt
-rw-r--r--. 1 root root 1393 12月 22  2016 ron.vim
-rw-r--r--. 1 root root 2720 12月 22  2016 shine.vim
-rw-r--r--. 1 root root 2445 12月 22  2016 slate.vim
-rw-r--r--. 1 root root 1629 12月 22  2016 torte.vim
-rw-r--r--. 1 root root 1840 12月 22  2016 zellner.vim


  • 挑一個內建的顏色方案來看看:

$ cat .vimrc
colorscheme torte

結果:


2017年9月15日 星期五

myOpenCV_Win10_Visual studio 2015

作業系統:Windows 10
開發工具:Visual Studio 2015
OpenCV版本:3.3.0   (opencv-3.3.0-vc14.exe 安裝位置為C:\opencv)

1. 修改環境變數

本機 → 內容 → 進階系統設定 → 環境變數 → path → 編輯

新增以下資料:
C:\OpenCV3.3\opencv\build\x64\vc14\bin


2. 開啟 Visual Studio 2015 並且新增專案

新增專案 → 左側「Visual C++」 → Win32 主控台應用程式→ 輸入專案名稱 → 確定 → 下一步 → 完成



3. 點選上方的「專案」→「屬性」→ 調整「平台」為“x64”



4. 對「VC++目錄」與「連結器」進行調整

設定VC++目錄 →在「Include目錄」增加“C:\OpenCV3.3\opencv\build\include”

設定VC++目錄 →在「程式庫目錄」增加“C:\OpenCV3.3\opencv\build\x64\vc14\lib”





設定連結器 →「輸入」 →在「其他相依性」增加

“opencv_world330d.lib”





5. 調整專案平台為「x64」



6. 新增 Visual C++檔於專案

「專案」 →「加入新項目」 →「C++檔(.cpp)」 →「新增」

7. 測試是否連結成功

撰寫一開啟圖檔的程式碼來測試是否連結成功

2017年9月6日 星期三

MariaDB基本安全性設定


MariaDB基本安全性設定:

安裝好 MariaDB 後,可執行 mysql_secure_installation 安全性設定工具:
mysql_secure_installation

設定 root 密碼、移除匿名登入帳號、禁止 root 從遠端登入、移除測試用的資料庫。




使用 root 帳號登入 MariaDB 伺服器:
mysql -u root -p


2017年9月5日 星期二

yum repolist - 基本 指令 用法與範例說明

列出所有的套件庫(repository)
yum repolist
yum -v repolist | less 

列出所有 EPEL 中的套件
yum --disablerepo="*" --enablerepo="epel" list available 

搜尋 EPEL 中的套件
yum --disablerepo="*" --enablerepo="epel" search mongodb 

安裝 EPEL 中的套件
 yum --disablerepo="*" --enablerepo="epel" install mongodb

 --disablerepo="*" 與 --enablerepo="epel" 參數
停用所有其他的套件庫,只使用 EPEL

Installing MariaDB with YUM 安裝 指令

Installing MariaDB with YUM:
1. Adding the MariaDB YUM repository
2. Installing MariaDB with YUM
3. start MariaDB
[root@localhost hen]# systemctl start mariadb
[root@localhost hen]# mysql


================
1. Adding the MariaDB YUM repository
[root@localhost hen]# vi /etc/yum.repos.d/MariaDB.repo    
[root@localhost hen]# cat /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-09-06 03:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

================
2. Installing MariaDB with YUM

[root@localhost hen]# yum install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00
epel/x86_64/metalink                                     | 6.4 kB     00:00
epel                                                     | 4.3 kB     00:00
extras                                                   | 3.4 kB     00:00
mariadb                                                  | 2.9 kB     00:00
mongodb-org-3.4                                          | 2.5 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/5): epel/x86_64/group_gz                                | 170 kB   00:00
(2/5): epel/x86_64/updateinfo                              | 817 kB   00:00
(3/5): extras/primary_db                                   | 191 kB   00:00
(4/5): mariadb/primary_db                                  |  21 kB   00:00
(5/5): epel/x86_64/primary_db                              | 4.8 MB   00:00
Loading mirror speeds from cached hostfile
 * epel: mirror2.totbb.net
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.2.8-1.el7.centos will be installed
--> Processing Dependency: MariaDB-common for package: MariaDB-client-10.2.8-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.2.8-1.el7.centos will be installed
--> Processing Dependency: galera for package: MariaDB-server-10.2.8-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-common.x86_64 0:10.2.8-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.2.8-1.el7.centos.x86_64
---> Package galera.x86_64 0:25.3.20-1.rhel7.el7.centos will be installed
--> Processing Dependency: libboost_program_options.so.1.53.0()(64bit) for package: galera-25.3.20-1.rhel7.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.2.8-1.el7.centos will be obsoleting
---> Package boost-program-options.x86_64 0:1.53.0-26.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch     Version                       Repository
                                                                           Size
================================================================================
Installing:
 MariaDB-client          x86_64   10.2.8-1.el7.centos           mariadb    48 M
 MariaDB-compat          x86_64   10.2.8-1.el7.centos           mariadb   2.8 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 MariaDB-server          x86_64   10.2.8-1.el7.centos           mariadb   108 M
Installing for dependencies:
 MariaDB-common          x86_64   10.2.8-1.el7.centos           mariadb   155 k
 boost-program-options   x86_64   1.53.0-26.el7                 base      156 k
 galera                  x86_64   25.3.20-1.rhel7.el7.centos    mariadb   8.0 M

Transaction Summary
================================================================================
Install  3 Packages (+3 Dependent packages)

Total download size: 168 M
Is this ok [y/d/N]:

Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/mariadb/packages/MariaDB-10.2.8-centos7-x86_64-com    mon.rpm: 表頭 V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
Public key for MariaDB-10.2.8-centos7-x86_64-common.rpm is not installed
(1/6): MariaDB-10.2.8-centos7-x86_64-common.rpm            | 155 kB   00:01
(2/6): MariaDB-10.2.8-centos7-x86_64-compat.rpm            | 2.8 MB   00:11
(3/6): boost-program-options-1.53.0-26.el7.x86_64.rpm      | 156 kB   00:00
(4/6): MariaDB-10.2.8-centos7-x86_64-client.rpm              |  48 MB  00:03:16
(5/6): galera-25.3.20-1.rhel7.el7.centos.x86_64.rpm          | 8.0 MB  00:00:34
(6/6): MariaDB-10.2.8-centos7-x86_64-server.rpm              | 108 MB  00:07:29
------------------------------------------------------------------------------------
Total                                                  371 kB/s | 168 MB  07:42
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid     : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
 From       : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]:
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : MariaDB-common-10.2.8-1.el7.centos.x86_64                        1/7
  Installing : MariaDB-compat-10.2.8-1.el7.centos.x86_64                        2/7
  Installing : MariaDB-client-10.2.8-1.el7.centos.x86_64                        3/7
  Installing : boost-program-options-1.53.0-26.el7.x86_64                       4/7
  Installing : galera-25.3.20-1.rhel7.el7.centos.x86_64                         5/7
  Installing : MariaDB-server-10.2.8-1.el7.centos.x86_64                        6/7
chown: 無效的使用者: ‘mysql’

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  Erasing    : 1:mariadb-libs-5.5.52-1.el7.x86_64                               7/7
  Verifying  : MariaDB-compat-10.2.8-1.el7.centos.x86_64                        1/7
  Verifying  : MariaDB-client-10.2.8-1.el7.centos.x86_64                        2/7
  Verifying  : boost-program-options-1.53.0-26.el7.x86_64                       3/7
  Verifying  : galera-25.3.20-1.rhel7.el7.centos.x86_64                         4/7
  Verifying  : MariaDB-server-10.2.8-1.el7.centos.x86_64                        5/7
  Verifying  : MariaDB-common-10.2.8-1.el7.centos.x86_64                        6/7
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                               7/7

Installed:
  MariaDB-client.x86_64 0:10.2.8-1.el7.centos
  MariaDB-compat.x86_64 0:10.2.8-1.el7.centos
  MariaDB-server.x86_64 0:10.2.8-1.el7.centos

Dependency Installed:
  MariaDB-common.x86_64 0:10.2.8-1.el7.centos
  boost-program-options.x86_64 0:1.53.0-26.el7
  galera.x86_64 0:25.3.20-1.rhel7.el7.centos

Replaced:
  mariadb-libs.x86_64 1:5.5.52-1.el7

Complete!

================
3. start MariaDB

systemctl start mariadb

[root@localhost hen]# systemctl start mariadb
[root@localhost hen]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.8-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

MariaDB [(none)]> use test
Database changed
MariaDB [test]> SHOW TABLES;
Empty set (0.00 sec)

MariaDB [test]>

Install vCenter Server 6.5 for Windows - 安裝 指令

安裝VMware vCenter Sever 6.5 步驟紀錄筆記:











Log in to vCenter Server by Using the vSphere Web Client:
https://10.1.1.1/vsphere-client
https://10.1.1.1/ui


2017年9月3日 星期日

Install MongoDB Community Edition - 安裝 指令

Install MongoDB Community Edition
mySOP:
  1. Configure repository:
     Create an /etc/yum.repos.d/mongodb-org-3.4.repo

[root@localhost ~]# cat /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

  2. yum install -y mongodb-org

  3. Start MongoDB:
     systemctl start mongod

Ref:
[root@localhost ~]# date
四  8月 10 22:32:50 CST 2017
[root@localhost ~]# yum install -y mongodb-org
Loaded plugins: fastestmirror, langpacks
base                                                                             | 3.6 kB  00:00:00  
epel/x86_64/metalink                                                             | 5.5 kB  00:00:00  
epel                                                                             | 4.3 kB  00:00:00  
extras                                                                           | 3.4 kB  00:00:00  
mongodb-org-3.4                                                                  | 2.5 kB  00:00:00  
updates                                                                          | 3.4 kB  00:00:00  
(1/3): epel/x86_64/updateinfo                                                    | 809 kB  00:00:00  
(2/3): mongodb-org-3.4/7/primary_db                                              |  36 kB  00:00:00  
(3/3): epel/x86_64/primary_db                                                    | 4.8 MB  00:00:36  
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org.x86_64 0:3.4.7-1.el7 will be installed
--> Processing Dependency: mongodb-org-tools = 3.4.7 for package: mongodb-org-3.4.7-1.el7.x86_64
--> Processing Dependency: mongodb-org-shell = 3.4.7 for package: mongodb-org-3.4.7-1.el7.x86_64
--> Processing Dependency: mongodb-org-server = 3.4.7 for package: mongodb-org-3.4.7-1.el7.x86_64
--> Processing Dependency: mongodb-org-mongos = 3.4.7 for package: mongodb-org-3.4.7-1.el7.x86_64
--> Running transaction check
---> Package mongodb-org-mongos.x86_64 0:3.4.7-1.el7 will be installed
---> Package mongodb-org-server.x86_64 0:3.4.7-1.el7 will be installed
---> Package mongodb-org-shell.x86_64 0:3.4.7-1.el7 will be installed
---> Package mongodb-org-tools.x86_64 0:3.4.7-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved
========================================================================================================
 Package                      Arch             Version                  Repository                 Size
========================================================================================================
Installing:
 mongodb-org                  x86_64           3.4.7-1.el7              mongodb-org-3.4           5.8 k
Installing for dependencies:
 mongodb-org-mongos           x86_64           3.4.7-1.el7              mongodb-org-3.4            12 M
 mongodb-org-server           x86_64           3.4.7-1.el7              mongodb-org-3.4            20 M
 mongodb-org-shell            x86_64           3.4.7-1.el7              mongodb-org-3.4            11 M
 mongodb-org-tools            x86_64           3.4.7-1.el7              mongodb-org-3.4            49 M

Transaction Summary
========================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 91 M
Installed size: 258 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mongodb-org-3.4/packages/mongodb-org-3.4.7-1.el7.x86_64.rpm: 表頭 V3 RSA/SHA1 Signature, key ID a15703c6: NOKEY
Public key for mongodb-org-3.4.7-1.el7.x86_64.rpm is not installed
(1/5): mongodb-org-3.4.7-1.el7.x86_64.rpm                                        | 5.8 kB  00:00:00  
(2/5): mongodb-org-mongos-3.4.7-1.el7.x86_64.rpm                                 |  12 MB  00:00:14  
(3/5): mongodb-org-server-3.4.7-1.el7.x86_64.rpm                                 |  20 MB  00:00:21  
(4/5): mongodb-org-shell-3.4.7-1.el7.x86_64.rpm                                  |  11 MB  00:00:12  
(5/5): mongodb-org-tools-3.4.7-1.el7.x86_64.rpm                                  |  49 MB  00:00:30  
--------------------------------------------------------------------------------------------------------
Total                                                                   1.7 MB/s |  91 MB  00:00:52  
Retrieving key from https://www.mongodb.org/static/pgp/server-3.4.asc
Importing GPG key 0xA15703C6:
 Userid     : "MongoDB 3.4 Release Signing Key <packaging@mongodb.com>"
 Fingerprint: 0c49 f373 0359 a145 1858 5931 bc71 1f9b a157 03c6
 From       : https://www.mongodb.org/static/pgp/server-3.4.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mongodb-org-server-3.4.7-1.el7.x86_64                                                1/5
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
  Installing : mongodb-org-shell-3.4.7-1.el7.x86_64                                                 2/5
  Installing : mongodb-org-mongos-3.4.7-1.el7.x86_64                                                3/5
  Installing : mongodb-org-tools-3.4.7-1.el7.x86_64                                                 4/5
  Installing : mongodb-org-3.4.7-1.el7.x86_64                                                       5/5
  Verifying  : mongodb-org-tools-3.4.7-1.el7.x86_64                                                 1/5
  Verifying  : mongodb-org-mongos-3.4.7-1.el7.x86_64                                                2/5
  Verifying  : mongodb-org-shell-3.4.7-1.el7.x86_64                                                 3/5
  Verifying  : mongodb-org-3.4.7-1.el7.x86_64                                                       4/5
  Verifying  : mongodb-org-server-3.4.7-1.el7.x86_64                                                5/5

Installed:
  mongodb-org.x86_64 0:3.4.7-1.el7                                                                    

Dependency Installed:
  mongodb-org-mongos.x86_64 0:3.4.7-1.el7            mongodb-org-server.x86_64 0:3.4.7-1.el7        
  mongodb-org-shell.x86_64 0:3.4.7-1.el7             mongodb-org-tools.x86_64 0:3.4.7-1.el7          

Complete!

2017年9月1日 星期五

install mongo-c-driver - 安裝 指令

mySOP:
[root@localhost ~]# yum list mongo-c-driver
[hen@localhost mongodb]$ wget https://github.com/mongodb/mongo-c-driver/releases/download/1.7.0/mongo-c-driver-1.7.0.tar.gz
[root@localhost mongodb]# tar xzf mongo-c-driver-1.7.0.tar.gz
[root@localhost Lab]# cd mongo-c-driver-1.7.0/
[root@localhost mongo-c-driver-1.7.0]# ./configure --disable-automatic-init-and-cleanup
[root@localhost mongo-c-driver-1.7.0]# make
[root@localhost mongo-c-driver-1.7.0]# make install

Ref:
      http://mongoc.org/libmongoc/current/installing.html



20170826: wget mongo-c-driver-1.7.0.tar.gz
[root@localhost Lab]# wget https://github.com/mongodb/mongo-c-driver/releases/download/1.7.0/mongo-c-driver-1.7.0.tar.gz
--2017-08-26 19:36:30--  https://github.com/mongodb/mongo-c-driver/releases/download/1.7.0/mongo-c-driver-1.7.0.tar.gz
正在查找主機 github.com (github.com)... 192.30.253.113, 192.30.253.112
正在連接 github.com (github.com)|192.30.253.113|:443... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置: https://github-production-release-asset-2e65be.s3.amazonaws.com/9735077/806d9438-7cfd-11e7-9e17-024ff1f6acb7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20170826%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170826T113631Z&X-Amz-Expires=300&X-Amz-Signature=3675af5de365bcc72bf46304278f7dfde83b78dd7265b27f651d8824393d366c&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dmongo-c-driver-1.7.0.tar.gz&response-content-type=application%2Foctet-stream [跟隨至新的 URL]
--2017-08-26 19:36:31--  https://github-production-release-asset-2e65be.s3.amazonaws.com/9735077/806d9438-7cfd-11e7-9e17-024ff1f6acb7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20170826%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170826T113631Z&X-Amz-Expires=300&X-Amz-Signature=3675af5de365bcc72bf46304278f7dfde83b78dd7265b27f651d8824393d366c&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dmongo-c-driver-1.7.0.tar.gz&response-content-type=application%2Foctet-stream
正在查找主機 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.225.192
正在連接 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.225.192|:443... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 7151766 (6.8M) [application/octet-stream]
Saving to: ‘mongo-c-driver-1.7.0.tar.gz’

100%[==================================================>] 7,151,766   1.16MB/s   in 7.0s

2017-08-26 19:36:39 (997 KB/s) - ‘mongo-c-driver-1.7.0.tar.gz’ saved [7151766/7151766]

[root@localhost Lab]# date
六  8月 26 19:36:55 CST 2017

2017年8月31日 星期四

VMware vSphere Client使用英文環境

VMware vSphere Client使用英文環境

在捷徑的目標加上: -locale en_US

"C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe" -locale en_US



2017年8月4日 星期五

opencv 影像讀取儲存 - 指令


從硬碟讀取檔案,並將影像秀在螢幕上,當使用者按下任一鍵,
從硬碟讀取檔案將影像設定成灰階圖,把影像儲存在硬碟,並將影像秀在螢幕上,
當使用者按下任一鍵,或是關閉視窗後程式終止:






#include <cstdio>
#include <opencv2/opencv.hpp>
using namespace cv;

int main(){
    //Show原影像
    Mat img1 = imread("lena.jpg",CV_LOAD_IMAGE_UNCHANGED);
    namedWindow("Display CV_LOAD_IMAGE_UNCHANGED", WINDOW_AUTOSIZE);
    imshow("Display CV_LOAD_IMAGE_UNCHANGED", img1);
    waitKey(0);

    //Show灰階影像
    Mat img2 = imread("lena.jpg",CV_LOAD_IMAGE_GRAYSCALE);
    imwrite("output.jpg",img2);
    namedWindow("Display CV_LOAD_IMAGE_GRAYSCALE", WINDOW_AUTOSIZE);
    imshow("Display CV_LOAD_IMAGE_GRAYSCALE", img2);
    waitKey(0);

    return 0;
}

Ref:
http://monkeycoding.com/?p=540

2017年8月3日 星期四

Install opencv3.2 on centos7 - 安裝 指令

Install opencv3.2 on centos7

1.Download
http://opencv.org/opencv-3-2.html

The latest version can be downloaded from SourceForge and GitHub:
https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/3.2.0/

20170802
[hen@localhost 下載]$ ll
總計 80112
-rw-rw-r--. 1 hen hen 82033498  8月  2 12:15 opencv-3.2.0.zip
[hen@localhost 下載]$ md5sum opencv-3.2.0.zip
bfc6a261eb069b709bcfe7e363ef5899  opencv-3.2.0.zip

2. Require
yum install cmake gcc gtk2-devel numpy pkconfig
yum install gcc-c++
yum install epel-release
yum install libdc1394-devel
yum install libv4l-devel
yum install gstreamer-plugins-base-devel

3. Make
unzip opencv-3.2.0.zip
cd opencv-3.2.0/
# pwd
/root/opencv/opencv-3.2.0
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install

4.Config
  root:
  echo '/usr/local/lib/' >> /etc/ld.so.conf.d/opencv.conf
  執行 ldconfig 將 /etc/ld.so.conf 的資料讀入快取當中
  將動態函式庫載入快取記憶體當中

  user:
  export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/

  env:
  PKG_CONFIG_PATH=:/usr/local/lib/pkgconfig/


5.Test
wget https://raw.githubusercontent.com/kyshel/template/master/src/hello_cv.cpp
wget https://raw.githubusercontent.com/kyshel/template/master/file/lena.jpg
g++ -o hello_cv hellocv.cpp `pkg-config opencv --cflags --libs`
./hello_cv lena.jpg lena_gray.jpg

[root@localhost ~]# rpm -qa|grep cmake
cmake-2.8.12.2-2.el7.x86_64


Ref:http://www.linuxfromscratch.org/blfs/view/cvs/general/opencv.html


2017年8月2日 星期三

yum install epel-release - 安裝 指令

[root@localhost ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-9 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================
 Package           Arch       Version         Repository         Size
=======================================================================
Installing:
 epel-release     noarch        7-9           extras             14 k

Transaction Summary
=======================================================================
Install  1 Package

Total download size: 14 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-9.noarch.rpm                                                                   |  14 kB  00:00:00  
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-9.noarch                                                                           1/1
  Verifying  : epel-release-7-9.noarch                                                                           1/1

Installed:
  epel-release.noarch 0:7-9                                                                                        

Complete!

CentOS-Base.repo

CentOS-Base.repo

http://ftp.ksu.edu.tw

[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://ftp.isu.edu.tw/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

2017年3月9日 星期四

linux、windows 相容檔案格式- exFAT

linux、windows 相容檔案格式- exFAT
使用 exFAT 格式讓 USB 隨身碟在 Windows 與 Linux 間交換檔案
exFAT(Extended File Allocation Table),又稱FAT64,是一種較適合於快閃記憶體的檔案系統

CentOS7 安裝 chrome - 安裝 指令

CentOS 7
# uname -r
3.10.0-514.el7.x86_64

# cat /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub


# yum -y install google-chrome-stable

2017年3月7日 星期二

良好的密碼儲存系統

良好的密碼儲存系統
Salting
  Salt是指在雜湊函數中或是密碼上加入一串隨機的位元bytes
Stretching (延展)
  利用雜湊函式產生密碼的digest,然後又利用該digest產生另一digest...。像這樣進行四次雜湊函式。


密碼的儲存
https://patrickmn.com/security/storing-passwords-securely/
http://gwokae.mewggle.com/wordpress/2012/07/%E7%BF%BB%E8%AD%AF-%E5%AE%89%E5%85%A8%E7%9A%84%E5%84%B2%E5%AD%98%E5%AF%86%E7%A2%BC-storing-passwords-securely/

系統設計者使用兩種方式來儲存使用者的密碼:

1. 儲存明文(plain text)
2. 利用單向雜湊函式(one-way hash function)來產生digest摘要

第一種方法是個很糟糕的想法,使用者儲存在資料庫的密碼可能也使用在其他網站。
但讓你更為驚訝的是,作為大多數網路系統中所使用的方式的後者,能提供更強的安全性嗎?

金鑰推衍函數(Key Derivation Function, KDF)

Ref:
https://en.wikipedia.org/wiki/Key_derivation_function
https://en.wikipedia.org/wiki/PBKDF2

The most common use of KDFs is the password hashing approach to password verification, as used by the passwd file or shadow password file.
The non-secret parameters are called "salt" in this context.
Examples of such key derivation functions include KDF1, defined in IEEE Std 1363-2000, and similar functions in ANSI X9.42.

key derivation functions是由一個強健的金鑰被使用在連續的加密所衍伸來而的。
例如:PBKDF2、bcrypt、scrypt

要符合FIPS 140-2安全認證的規範就用PBKDF2-SHA-256或SHA-512,並用多次的迭代來產生密碼的Digest。



在Android Studio中安裝OpenCV SDK

1. 安裝 Cmake (編譯工具), NDK (環境), LLDB (調試器)