Tuesday, December 19, 2017

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

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

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

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 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

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.

Get the result like that was not so hard, just tune parameters and keep patient, for confidentiality reason I can't share sample code this time.

Thursday, November 23, 2017

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

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.

Friday, November 17, 2017

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


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.

Friday, November 10, 2017

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

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錯誤


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.


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.
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分類器

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


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

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


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 台灣網路銀行速度評比


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

Thursday, September 28, 2017

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


This time I will try to detect objects from image by OpenCvSharp, let me introduce the flow first.

  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 畫直方圖

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#.


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

After LibZ.Tool package installed, goto the dictionary that having you want to merge's file, using following commend to merge DLLs into EXE.

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

Then it's done.

You can read LibZ document to get more help.

Thursday, July 27, 2017


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

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

Tuesday, April 25, 2017

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

Two little function can translate Roman Numerals(String) to Number(Int) and trans back.

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];

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數值較室外空間高出不少,由於文章內沒有當天的空汙資料可以參考,所以也不太曉得背景值大約是怎樣,只能用室外空間測出來的數據來推測應該是個空氣很好的天氣。



Monday, April 10, 2017

自製求生盒 - DIY SOS Box


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



Friday, March 3, 2017

Dcard 新聞誰最多


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



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

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



Thursday, February 2, 2017

春節期間該買樂透嗎 ?




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



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搜索評估標記),順帶一提,這份文件寫了很多有用的資訊,有興趣的人可以研究一下。