Tuesday, December 19, 2017

[C#] VGG Face - Multiple face detection / recognition

VggFaceCrop_1
Last time we tried VGG Face at previous post to display face recognition in one picture, this time we improve it, detect multiple face in one image and recognize them.

Here I will use Haar Cascades to do face detection, you can also download other feature-based cascade classifiers at here.

Monday, December 18, 2017

[C#] VGG Face CNN descriptor first try

VGG_Face0
It's time to try face detection since done lot of object detection. At this post, I will try VGG Face Descriptor, test the pre-trained model result, then see what we can do in next phase.

As usual, OpenCv Dnn is our model test good friend.

Friday, December 15, 2017

[C#] OpenCvSharp DNN test with SSD

OpenCvDnn_2
Last time, we compared different language running in OpenCv DNN at this article OpenCV DNN Speed Test in Python / C# / C++, this time we can test the newest OpenCvSharp with DNN moudule supported.

Tuesday, December 12, 2017

Electron first try with Active Directory and MSSQL access

electron_0
Electron is a framework base on Chromium and Node.js, it can create cross platform native applications with web technologies run on Mac, Windows, and Linux.

Recently I got a request to make a application to do some automatic stuff on Mac and Windows, after search on google, I think Electron was worth to try. But sadly the project got cut-out few day ago, so I only can share some experience what I got.

Thursday, December 7, 2017

[Tensorflow] Object Detection API test in Python and TensorflowSharp

py_tensorflow_2
Object detection in machine learning is a popular topic, this time I will test Tensorflow Object Detection API in Python(official) and TensorflowSharp(wrapper) and check the result.

Let's start with Python, my code was modify from Object Detection Demo with some simplify, avoid path/protobuf issue, hope this simple example can help more people successful test it.

Thursday, November 30, 2017

Textile defect detection using OpenCV | 使用OpenCv檢測紡織品瑕疵


textile defect detection
This is a sample display the result of textile defect detection via OpenCV, you can slide left/right to check image before and after.
這是一個範例,展示用OpenCV檢測紡織品瑕疵的結果,你可以在圖上左右拉動來比較前後的差別。

Get the result like that was not so hard, just tune parameters and keep patient, I had put my code on Github - Defect Detection Demo, you can test it by yourself.
要得到這樣的結果不難,只需要調參數跟耐心,我已經把程式放到。Github上的Defect Detection Demo,你可以自己試試。

Thursday, November 23, 2017

OpenCV DNN speed compare in Python, C#, C++

OpenCVDnnCompare_4
Last time I tried SSD on Python + OpenCV DNN, this time I will implement same test using C# and C++ to test performance and the difficult of implement.

To be fair, I will use same model and same test image on those 3 tests, model will be "VGG_VOC0712Plus_SSD_512x512_ft_iter_160000.caffemodel" from here (07++12+COCO: SSD512), image will be one picture I shot at Bail few year ago.
bali-crop

Friday, November 17, 2017

[Python] SSD (Single Shot MultiBox Detector) first try with OpenCv DNN | 在 OpenCv DNN初試 SSD

OpenCvSSD_0

SSD - Single Shot MultiBox Detector is an object detection model that has comparable accuracy with region proposals model(e.g. Faster RCNN) and is much faster. This time I will test SSD with Pyhton OpenCV DNN and check the result.
SSD - 單發多框偵測器(亂翻)是個在準確率上與候選區域模型(如Faster RCNN)不相上下,但速度更快的物體偵測模型。這次我將在Python OpenCV DNN環境下測試SSD看看其結果。

First, download SSD model from here, if you want to do train/evaluate just follow the instruction at same page, we only use model for detecting objects now.
首先,從這邊下載SSD模型,如果你想做訓練/驗證只要照著同一頁的說明去做就好,我們現在只用模型去做物件偵測。

Friday, November 10, 2017

[C#] Solve find difference game by OpenCv | 用OpenCv來玩找出差異的遊戲

FindDifferent3
This is a tiny side project using OpenCv(actually, OpenCvSharp) Background Subtraction methods to solve find difference game's image.
這是一個用OpenCV(實際上是OpenCvSharp)的Background Subtraction功能來解找出差異遊戲圖片的小專案。

0x8007042B - 0x2000D error while upgrading Windows 10 | 升級Win10時發生0x8007042B - 0x2000D錯誤

fail_update

Recently I am updating Windows 10 Fall Creators Update, but when it auto reboot and install to 27%, the update will stop and restore to previous version. After login in windows, the error message was that :
最近我在更新Windows 10秋季創作者更新,但當他自動重開然後安裝到27%時,更新會停止然後還原到上個版本。當登入windows後,錯誤訊息如下:
0x8007042B - 0x2000D
The installation failed in the SAFE_OS phase with an error during MIGRATE_DATA operation

Friday, November 3, 2017

[C#] Breakpoint will not currently be hit. No symbols loaded for this document.

breakingpoint

Recently I was modify an old WPF application, but when I am debugging, it shows a message on my breakpoint told it can't work.
最近我在改一個之前的WPF程式,但當我在除錯時,發現中斷點上顯示了一個訊息說它無法運作。
Breakpoint will not currently be hit. No symbols loaded for this document.

Googled it, a lot of solutions about this question, like this "Breakpoint will not currently be hit. No symbols loaded for this document." on codeproject , but no one work on me.
Google了一下,很多關於這問題的解法,像是codeproject上的"Breakpoint will not currently be hit. No symbols loaded for this document."這篇,不過沒有一個解法對我適用。

Tuesday, October 31, 2017

A trick in evaluate image using CNTK | 一個使用CNTK評估圖片的技巧

Most of time when you search for CNTK's example, they are training and evaluating model using bulk data, but in some production field, we need evaluate one or few image from real time generated data, how does CNTK framework work on it? Let's find out.
通常你搜尋CNTK的範例,它們都在用大量資料訓練跟驗證模型,但是在一些實際使用情況下,我們需要評估即時產生的一張或幾張圖片時,CNTK框架可以表現得如何呢? 讓我們來看看。


I writed some example for compare evaluate performance between from C#/CNTK, Python/CNTK and Python/OpenCv+DNN, full solution put on github CNTK Evaluate Performance Test with detail description, so I will skip the code detail focus on others.
我寫了一些範例來比較C#/CNTK, Python/CNTK 跟 Python/OpenCv+DNN 之間的驗證效率,完整專案放在github上 CNTK Evaluate Performance Test 還有各種細節描述,所以我這邊就會跳過程式細節的部份來說其他的。

Tuesday, October 24, 2017

[C#] Test MNIST Classifier with image using CNTK | 運用CNTK以圖片測試MNIST分類器

mnist1
CNTK - The Microsoft Cognitive Toolkit - is a unified deep-learning toolkit by Microsoft. This time we will using CNTK to run up a MNIST Classifier and test it by our selected image.
CNTK - 微軟認知工具(?) - 是一套微軟的整合性深度學習工具。這次我們將使用CNTK來執行一個MNIST分類器,並使用我們所選擇的圖片進行測試。

Due to Microsoft didn't provide much CNTK support for C#, so the best way is start from the CNTK C#/.NET API training examples, in here you can get some code example for training/validate model and the dataset that you need for training/validate. Copy example code to get a new post not my sytle, so I will skip it, assume you already get all things complete and let the MNISTClassifier model trained done.
由於微軟沒有提供很多C#的CNTK支援,所以最佳的方式是從CNTK C#/.NET API training examples這範例開始,在這裡你可以取得一些訓練/驗證模型的程式範例,還有訓練/驗證所需的資料。拷貝範例程式就生出一篇新的文章不是我的風格,所以我會跳過這段,假設你已經取得所有東西而且訓練好MNISTClassifier的模型了。

Friday, October 13, 2017

在Visual Studio內嵌美人時鐘 - 美人時計IDE

puni_ide_4

今天在找Visual Studio上的theme時,發現到一個有趣的東西美人時計 IDE,因為介紹上沒看到圖,不是很能了解具體呈現會是怎樣,所以我抱著踩雷的心情試看看,沒想到裝了之後這玩意真心不錯XD

[Python] Using deep learning model in OpenCV | 在OpenCV中使用深度學習模型

space_shuttle

OpenCV 3.3 included dnn module in the main repository, now we can use popular framework like Caffe, TensorFlow in OpenCV via dnn module.
OpenCV 3.3將dnn模組包入了主庫,現在我們可以在OpenCV中藉由dnn模組使用像是Caffe,TensorFlow這些熱門框架。

This post we will follow this dnn sample to test it (with some modify), because OpenCvSharp didn't support OpenCV 3.3 yet, so we will using python to do it.
這篇文章我們將照著這篇dnn範例來測試(有做一點修改),因為OpenCvSharp還沒支援OpenCV 3.3,所以我們將使用python來做這測試。

Tuesday, October 3, 2017

[C#] OpenCvSharp Detect Object in Video | OpenCvSharp 在影片中偵測物體

Last time we can detect object in image , now we can using same way to detect object in video , all we need just change the data source then do a little change.
上次我們做到了從圖片中偵測物體,現在我們可以用同個方式來從影片中偵測物體,只要改變資料來源跟做一點小修改。

Monday, October 2, 2017

2017 台灣網路銀行速度評比

cobank.tcb-bank.com.tw
日前因為工作需要開了合作金庫的帳戶,開戶過程蠻有問題的就算了,沒想到回家後使用網銀也讓我怨聲載道,從來沒看過有一家銀行的網銀可以慢到timeout的,於是我就想來看看到底合庫的網銀是不是最爛的,這篇文章因此而生。

首先參考wiki上的台灣銀行列表,將其中所列的37間商業銀行,一間間的找到其個人網銀的首頁或登入頁,然後丟到Pingdom Website Speed Test去測試速度,測試來源一律選San Jose, California, USA,在一番苦功之後,終於把每間銀行都搞定,底下就是我整理後的結果。

Thursday, September 28, 2017

[C#] OpenCvSharp Detect Object in Image by Contour | OpenCvSharp 使用輪廓偵測圖片中的物體

snip_20170928110929

This time I will try to detect objects from image by OpenCvSharp, let me introduce the flow first.
這次我要用OpenCvSharp嘗試偵測圖片中的物體,讓我先介紹流程。

  1. Load image (I load image as gray scale here). | 讀取圖片(我直接讀成灰階)
  2. Blur the image (I choose Gaussian Blur). | 模糊化圖片(我用高斯模糊)
  3. Get edge (use canny) | 取得邊緣(使用Canny)
  4. Find the Contour. | 找出輪廓
  5. Get right contour and draw on image. | 取得正確的輪廓並畫到圖片上上

Tuesday, September 19, 2017

[C#] OpenCvSharp Draw Histogram | OpenCvSharp 畫直方圖

最近我使用OpenCv做研究,發現C#在這領域蠻缺乏資源的,在找怎麼畫出直方圖時花了一些時間,所以現在來分享一下結果。
Recently I was using OpenCV to do research, found C# in this field was quite lack of resources, looking for how to draw the histogram took me some time, so now to share the results.

首先,使用nuget安裝OpenCvSharp,目前C#比較好用的OpenCv Wrapper。
First, use nuget to install OpenCvSharp, the current better OpenCv Wrapper for C#.

HistExample1


然後參考下列程式碼
Then refer to the following code

Thursday, September 7, 2017

Merge DLL into EXE on WPF via LibZ | 使用LibZ在WPF上將DLL合併至EXE內

In winform, you can use ILMerge merge DLLs into EXE, but it can't work on WPF, so we need find another way to do it. Lot of people recommend this post "Combining multiple assemblies into a single EXE for a WPF application", but it didn't work on me, luckily I found another way to do it.
在winform上,你可以用ILMerge合併DLLs到EXE裡,但是在WPF上沒辦法辦到,所以我們需要找另外的方法來達成。很多人推薦這篇" Combining multiple assemblies into a single EXE for a WPF application "的方式,但是在我的情況不適用,還好我找到另外的方式。


Using LibZ, we can use commend line doing merge like using ILMerge, you can even use LibZ as library to control it in code for advanced use. For me, Libz can merge DLLs into EXE on WPF, it saved my day.
使用LibZ,我們可以跟ILMerge一樣用指令列來做合併,在進階的狀況,甚至可以在程式內呼叫LibZ library來使用他。對我來說,LibZ可以在WPF上將DLLs合併至EXE內,這省了我很多時間。


LibZ github nuget


To use LibZ is easy, the fast way for me is use NuGet Package Manager Console (in Visual Studio -> Tools -> NuGet Package Manager -> Package Manager Console)
使用LibZ很簡單,最快的方式就是使用NuGet Package Manager Console (在Visual Studio中-> Tools -> NuGet Package Manager -> Package Manager Console)


Open NuGet Package Manager Console, type in following commend to install
開啟NuGet Package Manager Console,輸入下列指令安裝
PM>Install-Package LibZ.Tool -Version 1.2.0
libz1


After LibZ.Tool package installed, goto the dictionary that having you want to merge's file, using following commend to merge DLLs into EXE.
LibZ.Tool安裝完後,到有你要合併的檔案之目錄,使用下列指令來將DLLs合併至EXE.

PM>libz inject-dll --assembly .\YOUREXE.exe --include .\YOURDLL.dll
libz2


Then it's done.
然後就完成啦。


You can read LibZ document to get more help.
你可以閱讀LibZ的文件來取得更多幫助。

Thursday, July 27, 2017

冥頑不靈的舊時代思維

最近這幾天,北市府與Youtuber合作宣傳世大運上了好幾個新聞,像是這個 宣傳世大運 柯P聯手網紅拍片,其實這也不是創舉,政府單位在之前就已經有找國內外youtuber合作的記錄了。而跟網路紅人、Youtuber業配是一個很聰明又實惠的作法,只要找對人,其穿透力、到達率絕對比花大錢買電視、報紙廣告來的有效,看了一下這次合作背後的推手是貝殼放大的創辦人,想想也就不意外了,若是舊時代的思維肯定會覺得這些都是邪魔歪道....沒想到在FB上還真的看到這種人。

前柯辦發言人,前悠遊卡公司董事長特助 - 林筱淇在7/26時發了一篇文評論了與Youtuber合作這件事,在貼文章內容之前,先來說說舊時代思維有哪些特點:
  1. 接受不了新觀念、新事物。
  2. 看不慣的東西都是沒用的垃圾。
  3. 覺得用老招就可以吃遍天下。
讓我們看看舊時代思維是怎麼呈現的。
Joke4

Tuesday, April 25, 2017

[C#] Roman numerals converter - 羅馬數字轉換

Two little function can translate Roman Numerals(String) to Number(Int) and trans back.
兩個小function可以將羅馬數字(字串)轉成數字(整數)再轉回

//1990=>MCMXC
public static string IntToRoman(int num)
{
 String[] m = { "", "M", "MM", "MMM" };
 String[] c = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
 String[] x = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
 String[] i = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
 return m[num / 1000] + c[(num % 1000) / 100] + x[(num % 100) / 10] + i[num % 10];
}

//MCMXC=>1990
public static int RomanToInt(string s)
{
 Dictionary d1 = new Dictionary { { 'I', 1 }, { 'V', 5 }, { 'X', 10 }, { 'L', 50 }, { 'C', 100 }, { 'D', 500 }, { 'M', 1000 } };
 Dictionary d2 = new Dictionary { { "IV", 4 }, { "IX", 9 }, { "XL", 40 }, { "XC", 90 }, { "CD", 400 }, { "CM", 900 } };
 int num = 0;
 foreach (var d in d2)
 {
  if (s.Contains(d.Key))
  {
   num += d.Value;
   s = s.Replace(d.Key, "");
  }
 }
 foreach (var d in d1)
 {
  var c = s.Count(x => x == d.Key);
  if (c > 0)
  {
   num += d.Value * c;
  }
 }
 return num;
}

Monday, April 24, 2017

空襲來時要躲哪 ?

今天北韓開戰的機會不小,前幾天北韓太陽節搞得大家人心惶惶,雖然最終以北韓飛彈試射失敗告終,但還是讓東亞國家都緊張了一個周末,戰爭的陰霾也還未散去。雖然北韓開戰影響台灣的機會很小,但天底下不怕一萬只怕萬一,就算北韓影響不到台灣,還有幾千顆飛彈對著台灣啊。

說到空襲,在和平了許久的台灣,最多人聯想到的應該是伍佰的【空襲警報】,至於防空演習,這年代除了參與演習的單位,其他人只會覺得一小時不能上街有點麻煩吧。但是你有想過,若今天空襲警報響了,幾分鐘後你查了一下,發現這不是演習,這時候你要躲到哪裡去嗎 ?

電影中打仗有戰壕躲,伍佰【空襲警報】裡說種田的都躲樹下,學生時代遇到空襲演練,老師說要躲在課桌底下,而現在呢 ? 老實說我還真的不曉得台灣有甚麼規定要怎麼躲,按照我的知識,遇到空襲若在市區,應該要就近找堅固的建築物做掩蔽,祈禱炸彈別炸到頭上把你埋了,但這只是我的想法,理論上台灣辦過那麼多場萬安演習,應該會有清楚的指示才對.....

Thursday, April 13, 2017

[實測] 捷運PM2.5真的比較高嗎 ?

事情是這麼來的,在FB PM2.5 開放資料社群上看到了這篇地鐵PM2.5飆高不只國外 北捷實測也相符,文中引用英國研究,並在台北捷運測得車站密閉空間的PM2.5數值較室外空間高出不少,由於文章內沒有當天的空汙資料可以參考,所以也不太曉得背景值大約是怎樣,只能用室外空間測出來的數據來推測應該是個空氣很好的天氣。

看了這樣的文章,我剛好有帶之前買的空汙偵測小工具,所以就在搭捷運時測試了一下,看看結果會如何。


Screenshot_20170412-192640
這是我開始測試前截的圖,看的出來台北市空氣蠻糟的,這個糟糕的空氣持續到半夜,截圖的時候是七點半,我九點多有再看一次,感覺上有更糟一點,大致上是沒有大風吹過空氣變好的情況在測試時發生。

Monday, April 10, 2017

自製求生盒 - DIY SOS Box

IMG_3481

求生盒(SOS box)這東西算是一個比較奇妙的東西,不像避難背包那麼出名,但又因為體積關係,不少廠商都有出套裝產品可供選擇,網路上搜尋SOS Box可以找到很多產品能參考,而不少對於此方面有經驗的人,都傾向於自己組求生盒,來對應自身會(或是預期)遭遇的狀況。

自組求生盒的第一步,就是找到適合的容器,一般而言都是找個大小適中,方便攜帶的堅固容器,如果能防水最好,比較常見的尺寸從海底雞罐頭這種大小,到便當盒大小都有人用。個人建議是別太小,至少要能裝進求生毯,也別大到放不進口袋,如果工作褲口袋或是外套口袋裝進去會妨礙行動,就太大了。

至於內容物,一般來說在都市準備的核心都是以刀、火、燈為基礎,古典一點求生盒會有針線、釣具、鏈鋸等等,比較常見的還有哨子、反射鏡、指南針,基本上是針對自己所需,還有能放進多少東西進盒子來思考。

Friday, March 3, 2017

Dcard 新聞誰最多

台灣網友皆知,台灣的新聞媒體很大一部分的內容來源就是從網路上抄,而抄的來源又決定了新聞的內容品質,在PTT上常常有很多網友評論那些Dcard網站內容為「低__卡幻想文」,抄過去變成新聞自然也是大批一頓,看到很多人在批,我就想來看看哪家新聞的Dcard新聞最多。

由於懶得寫程式爬,所以直接用google搜尋代勞,也許不完全精準但是要看出Dcard程度應該還是沒問題的,方式是在www.google.com.tw搜尋「site:網站 dcard」,舉例而言,以蘋果日報來說,就是搜尋
site:appledaily.com.tw dcard


簡單的搜尋結果如下,我只有找google搜尋「新聞」前五頁的台灣有自產新聞的媒體,沒想到那麼少



排序一下名次,

Dcard 新聞誰最多 - 2017/3/3

#NameCount
1 NOWnews 182,000
2 聯合新聞網 26,100
3 東森新聞雲 16,100
4 TVBS新聞網 4,930
5 蘋果日報 3,840
6 自由時報 1,040
7 中時電子報 745


只看數字不是很直觀,所以轉成圓餅圖,可以看到第一名的NOWnews低卡文大勝其他新聞啊



周末前的小分析,感謝大家。

Thursday, February 2, 2017

春節期間該買樂透嗎 ?

lottery

過年前分析了一下前三年樂透彩的數據,想看看過年的時候要不要買樂透拚退休,沒想到分析出來的結果蠻有意思的,而過完年後,看起來只有這三年的分析也沒讓我失望,目前為止還算是準的。

其實看上圖就知道分析的結果了,但我還是歸納一下,從過去三年的資料中得知:

  • 威力彩在春節前後一個月不會開頭獎
  • 大樂透在春節期間會開頭獎

所以若想中頭獎的話,春節期間買大樂透是比較有機會的,威力彩大概過完元宵後再考慮拚頭獎XD

下面有過去三年的資料,紅色是大年初一,橘色是頭獎累積,藍色是頭獎金額(藍色比橘色短表示頭獎不只一個)

Wednesday, January 11, 2017

FEMA Markings | FEMA 標記說明

fema mark

如果有在看國外的新聞,或是一些電影,你可能對牆上的噴漆有點眼熟,這不是胡亂的塗鴉,而是一種都市搜尋與搜救標記(Urban Search and Rescue Markings),上下的標記都是,不過我不太確定上面紅色標記是按照甚麼規範噴的,而下面橘色標記則是FEMA Markings。

FEMA是Federal Emergency Management Agency的簡寫,就是美國的聯邦緊急事務管理署,主要是負責自然災害的應對與處理。而這套標記在美國Katrina風災時廣泛使用而被大眾所知(可以參考這篇"Katrina + 5: An X-Code Exhibition"),也有人稱為Katrina crosses、Katrina X ,有些人在使用上會簡稱為search codes,而在FEMA的RESCUE FIELD OPERATIONS GUIDE文件中則被命名為 FEMA Search Assessment Marking (FEMA搜索評估標記),順帶一提,這份文件寫了很多有用的資訊,有興趣的人可以研究一下。