Skip to content

Instantly share code, notes, and snippets.

View MarcWang's full-sized avatar

MarcWang MarcWang

  • 吾微而智
View GitHub Profile

Install Anaconda on Linux

Download from Anaconda

bash ~/Downloads/AnacondaX-X.X.X-Linux-x86_64.sh

AnacondaX-X.X.X = 依照下載的版本

Install OpenCV 2.4.4 with Visual Studio 2010 on Windows

加入header檔的路徑

Tools->Options->VC++Directories->Show diretories for->Include files

  • ..\opencv\build\include
  • ..\opencv\build\include\opencv
  • ..\opencv\build\include\opencv2

Install OpenCV 2.3.1 with Visual Studio 2008 on Windows

加入header檔的路徑

Tools->Options->VC++Directories->Show diretories for->Include files

  • ..\opencv\build\include
  • ..\opencv\build\include\opencv
  • ..\opencv\build\include\opencv2

如何撰寫商業計劃書 (How to write a Business Plan)

Starting a business? Then you'll need a plan - a road map, taking you on the straightest, fastest route to where you want to go.

開創一個事業?你需要一個計劃-一張地圖,帶領你走最直的最快速的道路到達你想去的地方

Your business plan will include 6 sections and will help you think through your business idea, making sure you've covered all the angles and eventualities, before you set off.

Basic Matrix Operation 基本矩陣運算

在使用OpenCV時常常會操作cv::Mat陣列,以下會列出常使用到的情況。

如何建立矩陣

直接宣告矩陣大小及型態

Mat image(240, 320, CV_8UC3);

Convert Binary Data to OpenCV Image Format

在影像處理時,常常會讀取影像資料(binary data)後轉成影像格式(cv::Mat),在進行影像操作。

那我們如何轉成可用的OpenCV影像格式呢?

首先讀取檔案後得到binary data,在進行解碼轉成cv::Mat

當然如果單純讀檔後轉成OpenCV影像格式,OpenCV是有提供cv::imread這個API可以使用。

Mouse Control on OpenCV GUI

使用OpenCV寫介面時,經常會使用滑鼠的操作,OpenCV有提供一個APIsetMousecallback方便操作。

void setMousecallback(const string& winname, MouseCallback onMouse, void userdata=0)*

  • winname : 建立視窗的名稱
  • onMouse : 滑鼠的callback函式
  • userdate:傳遞的參數
  • void on_Mouse(int event, int x, int y, int flags, void* param);
  • event : CV_EVENT_*變數

OpenCV Get Pixel Value from Mat

在使用OpenCV時,經常會針對Mat裡的每一個pixel操作,可能是取值,也可能需要寫值。

但OpenCV提供了很多種方法可以做影像操作,如果有大量運算時,其實要找到一個比較適合且快速的方式。

從前使用OpenCV到現在也嘗試過很多種方式,今天稍微整理了幾種方式,做一個簡單的評估分享給大家。

我分類出較常用的影像取值6種方式:

Capture Image from Camera using OpenCV

一般的影像來源分為兩種,一個是圖片(image),一個就是串流,雖然串流(stream)也是會切成一張一張的影像在做影像操作。

而串流(stream)又可分為視訊串流跟影片串流,這裡介紹如何從視訊裝置得到串流,再切成影像進行操作。

範例環境

  • Visual Studio 2010
  • Windows 7

Resize and Rotate Image using OpenCV

有時候需要對影像做旋轉、縮放時,可以透過簡單的數學運算可得到結果。

OpenCV有提供cvGetQuadrangleSubPix讓開發者自行調整影像的變化程度。

範例環境:

  • Visual Studio 2010
  • Windows 7
  • OpenCV 2.4.5