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.