image
之前有寫過一篇關於如何將執行緒運算結果顯示於人機介面上?, 今天剛好找到一個不錯的範例How to: Make Thread-Safe Calls to Windows Forms Controls, Let’s cut to the chase and get started!======================================================================Access to Windows Forms controls is not inherently thread safe. If you have two or more threads manipulating the state of a control, it is possible to force the control into an inconsistent state. Other thread-related bugs are possible as well, including race conditions and deadlocks. It is important to ensure that access to your controls is done in a thread-safe way.更新控制元件與threrad safe觀念: 如果有兩個執行緒, 一個UI(主執行緒), 另一個或更多個使用者開的執行緒要更新控制元件上(windows Form, TextBox, Label,…), 有可能造成不相容狀況

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
載入一張照片, 利用 InRange參數lower和higher顏色BGR上下限篩選感興趣區域, 得到一張遮罩m_img_inRange,再利用CvBlobDetector 進行Blob運算
 1: using Emgu.CV;
 2: using Emgu.CV.Cvb;
 3: using Emgu.CV.CvEnum;
 4: using Emgu.CV.Structure;
 5: using Emgu.CV.VideoSurveillance;
 6: using System.Diagnostics;
 7: using System.Threading;
 8:  
 9: private void CalInRange()
 10: {
 11: if (m_img_color == null) return;
 12: m_img_inRange = m_img_color.InRange(lower, higher);
 13: m_img_inRange_not = m_img_inRange.Not();
 14: using (CvBlobs blobs = new CvBlobs())
 15: {
 16: m_blobDetector.Detect(m_img_inRange, blobs);
 17: m_img_color_copy = m_img_color.Copy();
 18: foreach (var pair in blobs)
 19: {
 20: CvBlob b = pair.Value;
 21: CvInvoke.Rectangle(m_img_color_copy, b.BoundingBox, new MCvScalar(255.255, 255, 0), 5);
 22: //CvInvoke.PutText(frame, blob.ID.ToString(), Point.Round(blob.Center), FontFace.HersheyPlain, 1.0, new MCvScalar(255.0, 255.0, 255.0));
 23: }
 24:  
 25: imageBox1.Image = m_img_color_copy;
 26: imageBox2.Image = m_img_inRange;
 27: imageBox3.Image = m_img_inRange_not;
 28: }
 29: }

me1237guy 發表在 痞客邦 留言(2) 人氣()

image
1. 利用Canny Method 直線偵測2. 利用Hough Transform(霍夫轉換)來找線段候選人3. 利用 GetExteriorAngleDegree 計算目前線段(line)與自訂義水平線(otherline)的夾角
 1: private void CalExteriorAngles()
 2: {
 3: LineSegment2D[] lines = CvInvoke.HoughLinesP(
 4: m_img_thresh_gauss.Canny(100, 64),
 5: 1, //Distance resolution in pixel-related units
 6: Math.PI / 360.0, //Angle resolution measured in radians.
 7: 90, //threshold
 8: 140, //min Line width
 9: 120); //gap between lines
 10:  
 11: 
 12: Color[] colorArray = new Color[13] { Color.Red, Color.Green, Color.Blue, Color.Honeydew, Color.AliceBlue, 
 13: Color.AliceBlue, Color.Pink, Color.Indigo, Color.IndianRed, Color.GreenYellow,
 14: Color.Lavender, Color.LemonChiffon, Color.LightBlue};
 15: Random r = new Random();
 16: int ind;
 17: //double ramp;
 18: double theta = -1;
 19: int cnt = 0;
 20: m_img_copy = m_img_color.Copy();
 21: imageBox11.Image = m_img_copy;
 22: listBox1.Items.Clear();
 23: LineSegment2D otherline = new LineSegment2D();
 24: otherline.P1 = new Point(0, 0);
 25: otherline.P2 = new Point(m_img_gray.Width, 0);
 26: foreach (LineSegment2D line in lines)
 27: {
 28: ind = r.Next() % 11 +1;
 29: theta = line.GetExteriorAngleDegree(otherline);
 30:  
 31:  
 32: //this.Text = theta.ToString();
 33: //if (theta > 0)
 34: {
 35: m_img_copy.Draw(line, new Bgr(colorArray[ind]), 12);
 36: imageBox11.Image = m_img_copy;
 37: cnt++;
 38: listBox1.Items.Add(string.Format("#{0} Angle = {1:###.##}",cnt, theta));
 39: //imageBox11.Image = m_img_copy;
 40: Application.DoEvents();
 41: Thread.Sleep(2000);
 42: //if (cnt > 0) break;
 43: }
 44:  
 45: 
 46:  
 47:  
 48: }
 49: imageBox11.Image = m_img_copy;
 50: 
 51: //MessageBox.Show("Done");
 52: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
新增專案名稱 “CameraCapture”加入 references Emgu.CV Emgu.CV.UI Emgu.Util from directory C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin
 1: using System;
 2: using System.Collections.Generic;
 3: using System.ComponentModel;
 4: using System.Data;
 5: using System.Drawing;
 6: using System.Linq;
 7: using System.Text;
 8: using System.Windows.Forms;
 9:  
 10: using Emgu.CV;
 11: using Emgu.CV.CvEnum;
 12: using Emgu.CV.Structure;
 13: using Emgu.Util;

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
以下為EMGU Multiple Face Recognition using PCA and Parallel Optimisation筆記在此, 我會試著用 libemgucv-windows-universal-cuda-2.4.10.1940版本測試, 因為在上去3.0版本並不支援FaceRecognizer==========================================================
如果你是第一次使用Emgu CV, 請參考Creating Your First EMGU Image Processing Project article人臉辨識是以Multiple face detection and recognition in real time為基礎

me1237guy 發表在 痞客邦 留言(2) 人氣()

image
以下是我研究這篇技術文件的筆記 Emgu CV -Select ROI (Region Of Interest) With Mouse C#
修改部分1. 多了一個影像備份(Clone), 加快裁剪的速度; 原作者是從檔案直接再讀一次, 當載入的圖片比較大(如8192x8192)時就會發現速度超慢!2. 下圖中最右邊, 裁剪的影像外框會有紅色ROI, 已經拿掉 展示人機介面如下:1. 先拉一個splitContainer(水平), 在拉兩個splitContainer(垂直)

me1237guy 發表在 痞客邦 留言(10) 人氣()

image
加入索引標籤, 輸入 EmguCV選擇項目.NET Framework元件頁面, 點選<瀏覽>C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin選擇Emgu.Util.dll開啟後, 可以在EmguCV看到新增的四個.NET framework元件

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
Emgu CV版本: libemgucv-windows-universal-cuda-3.0.0.2158

可參考: 安裝libemgucv-windows-universal-cuda-3.0.0.2131


me1237guy 發表在 痞客邦 留言(1) 人氣()

image
3xN陣列, 每一列的長度隨機
 1: int[][] x = new int[3][];
 2: Random r = new Random();
 3: for (int i = 0; i < x.Length; i++)
 4: {
 5: int len = r.Next() % 5 + 1;
 6: x[i] = new int[len];
 7: Console.WriteLine("i = {0}, len = {1}", i, len);
 8: for (int j = 0; j < x[i].Length; j++)
 9: {
 10: x[i][j] = r.Next() % 10;
 11: Console.WriteLine("x[{0}][{1}] = {2}", i, j, x[i][j]);
 12: }
 13: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
1 public class iArray : IComparable
2 {
3 private int x, y;
4 public iArray()
5 {
6 x = 0; y = 0;
7 }
8 public iArray(int ix, int iy)
9 {
10 x = ix;
11 y = iy;
12 }
13 public void Show()
14 {
15 Console.WriteLine("({0}.{1})", x, y);
16 }
17 int IComparable.CompareTo(object obj)
18 {
19 iArray v = (iArray)obj;
20 return (x * x + y * y) - (v.x * v.x + v.y * v.y);
21 }
22 }

測試
1 class Program
2 {
3 static void Main(string[] args)
4 {
5 iArray[] vec = { new iArray(20, 10),
6 new iArray(50, 20),
7 new iArray(90, 40),
8 new iArray(10, 10),
9 new iArray(40, 30)};
10 Console.WriteLine("排序前...");
11 foreach (iArray v in vec)
12 {
13 v.Show();
14 }
15
16 Console.WriteLine("排序後(ascending)...");
17 Array.Sort(vec);
18 foreach (iArray v in vec)
19 {
20 v.Show();
21 }
22 Console.WriteLine("排序後(descending)...");
23 Array.Reverse(vec);
24 foreach (iArray v in vec)
25 {
26 v.Show();
27 }
28
29 Console.Read();
30 }
31 }

1 public class iArray : IComparable
2 {
3 private int x, y;
4 public iArray()
5 {
6 x = 0; y = 0;
7 }
8 public iArray(int ix, int iy)
9 {
10 x = ix;
11 y = iy;
12 }
13 public void Show()
14 {
15 Console.WriteLine("({0}.{1})", x, y);
16 }
17 int IComparable.CompareTo(object obj)
18 {
19 iArray v = (iArray)obj;
20 return (x * x + y * y) - (v.x * v.x + v.y * v.y);
21 }
22 }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
virtual 虛擬方法,若希望或預料到基礎類別的這個方法在將來的衍生類別中會被覆寫(override),則此方法必須被聲明為 virtual。
1 class Employee
2 {
3 protected int m_salary;
4 public virtual int Salary
5 {
6 get
7 {
8 return m_salary;
9 }
10 set
11 {
12 if (value >= 22000 & value <= 42000)
13 {
14 m_salary = value;
15 }
16 else
17 {
18 if (value < 22000)
19 m_salary = 22000;
20 else
21 m_salary = 42000;
22 }
23 }
24 }
25 public void showTotal()
26 {
27 Console.WriteLine("實領薪水{0}", m_salary);
28 }
29 }
Operator薪水繼承Employee, 基本上薪水上下限的規則不變(與父類別相同)
1 class Operator : Employee
2 {
3 public override int Salary
4 {
5 get
6 {
7 return base.Salary;
8 }
9 set
10 {
11 if (value >= 22000 & value <= 42000)
12 {
13 m_salary = value;
14 }
15 else
16 {
17 if (value < 22000)
18 m_salary = 22000;
19 else
20 m_salary = 42000;
21 }
22 }
23 }
24 }
1 class Operator : Employee
2 {
3 public override int Salary
4 {
5 get
6 {
7 return base.Salary;
8 }
9 set
10 {
11 base.Salary = value;
12 }
13 }
14 }

me1237guy 發表在 痞客邦 留言(0) 人氣()

試用版 Evaluation Applications Open_eVision_Eval_1_2_5_8535.exe 須先註冊一個帳號, 登錄後才能下載檔案  
       

Open eVision 1.2.5.8549

 

Description

File format

File size

Files

Getting Started

PDF

0.6 MB

Download here

Release Notes

PDF

0.6 MB

Download here

Installation Files

Development Tools

EXE

164 MB

Download here

Libraries 32-bit

EXE

88 MB

Download here

Libraries 64-bit

EXE

74 MB

Download here

Documentation

C++

PDF

39 MB

Download here

.NET

PDF

39 MB

Download here

ActiveX

PDF

39 MB

Download here

Migration Guide

PDF

0.5 MB

Download here

Project sample

ZIP

61 KB

Download here

Application Samples

Clinical Analysis

ZIP

1.6 MB

Download here

Fuse Inspection

ZIP

2.3 MB

Download here

OCR

ZIP

4.2 MB

Download here

支援作業系統

image

 

me1237guy 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。