image
https://www.java.com/zh_TW/download/-------------------------Eclipse安裝我的電腦是64位元,但是下載Windows 64-bit卻無法開啟IDE,參考[2]依然無法解決,後來索性下載Windows 32-bit竟然順利解決! 懷疑因為我的jre安裝32-bit的關係@@C:\Users\me1237guy\workspace新增Java Package新增Java Class
 1: package ex1;
 2:  
 3: public class ex1_helloworld {
 4:  
 5: public static void main(String[] args) {
 6: // TODO Auto-generated method stub
 7: System.out.println("Hello World!");
 8: }
 9:  
 10: }

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

image
contour line: blue colorconvex hull line: red colorstep 1: point 1(light blue) represents a start point, point 2(green) is end point, and point 3 (red) is defect size which is defined as the distance between light blue color line and red cicular point. step 2:step 3:step 4:---------------------------------Now I am going to show you three different sizes of star logos, which are proportional to their defect sizes. figure 0 is a large size logo, and its defect size is about 6984.

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

image

繼續上一篇 OpenCV3.1 搜尋輪廓與遮罩應用

現在要計算輪廓周長、面積和重心,並且用一多邊形曲線近似該輪廓。

 1:  
 2: for (int i = 0; i < contours.size(); i++) {
 3: cout << "contour # " << i << endl;
 4: imgMask = Mat::zeros(imgSrc.size(), CV_8UC1);
 5: drawContours(imgMask, contours, i, Scalar(255), -1);
 6: Mat imgROI;
 7: imgSrc.copyTo(imgROI, imgMask);
 8: string name = std::to_string(i);
 9: //imshow(name, imgROI);
 10: cout << "mean color (BGR) = " << mean(imgSrc, imgMask) << endl;
 11: Moments m = moments(contours[i]);
 12: cout << "area = " << m.m00 <<endl;
 13: double contArea = contourArea(contours[i]);
 14: cout << "contour area = " << contArea << endl;
 15: double cx = m.m10 / m.m00;
 16: double cy = m.m01 / m.m00;
 17: line(imgROI, Point(cx, cy), Point(cx, cy), Scalar(255, 0, 0), 5, 8);
 18: char label[50];
 19: sprintf_s(label, "(%.0f,%.0f)", cx, cy);
 20: int offset = 100;
 21: putText(imgROI, label, Point(cx-offset, cy), FONT_HERSHEY_COMPLEX, 1, Scalar(0, 0, 255), 1, 8);
 22: double perimeter = arcLength(contours[i], true);
 23: cout << "perimeter = " << perimeter << endl;
 24: vector<Point> polyCurves;
 25: double epsilon = 0.01;
 26: approxPolyDP(contours[i], polyCurves, epsilon*arcLength(contours[i], true), true);
 27: 
 28: cout << "polygonal curves = " << polyCurves.size() << endl;
 29: for (int j = 0; j < polyCurves.size()-1; j++) 
 30: {
 31: Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
 32: line(imgROI, polyCurves[j], polyCurves[j + 1], color, 3, 8);
 33: }
 34:  
 35: line(imgROI, polyCurves[0], polyCurves[polyCurves.size()-1], Scalar(0, 0,255), 3, 8);
 36: 
 37: imshow(name, imgROI);
 38: cout << "------------------------------" << endl;
 39: }
多邊形曲線近似 epsilon = 0.01多邊形曲線近似 epsilon = 0.02--------------------------------------輪廓極值(minX, maxX, minY, maxY)
 1:  
 2: bool sortByXAscend(Point a, Point b) { return (a.x<b.x); }
 3: bool sortByXDescend(Point a, Point b) { return (a.x>b.x); }
 4: bool sortByYAscend(Point a, Point b) { return (a.y<b.y); }
 5: bool sortByYDescend(Point a, Point b) { return (a.y>b.y); }

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

polygon

 1: cvtColor(imgSrc, imgG, CV_BGR2GRAY);
 2: threshold(imgG, imgBW, 100, 255, THRESH_BINARY);
 3: vector<vector<Point>> contours;
 4: vector<Vec4i> hierarchy;
 5:  
 6: findContours(imgBW, contours, hierarchy, RETR_TREE, CV_CHAIN_APPROX_SIMPLE);

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

image
安裝3.1.0.2504版本C:\Emgu\emgucv-windesktop 3.1.0.2504---------------------------(2) 安裝 emgucv-windesktop-tbb-ipp-icc 3.1.0.2504加速版本C:\Emgu\emgucv-windesktop-tbb-ipp-icc 3.1.0.2504兩個版本差異 x64資料夾 兩個版本在bin資料夾下是一樣的!!很可惜,下面幾張圖是加速的版本跑出來的結果,似乎跟原本跑出來的速度差不多,有些甚至跑不贏原本未加速前,IPP-TBB-ICC版本真是出乎我意料之外@@

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

blob3
利用PowerPoint製造測試圖片,黑色數字為PPT旋轉角度範例1經過簡單二值化黑色: PPT旋轉角度紅色: OpenCV計算出的角度,可以從第三列開始看起,豎立著的矩形為0度;接著順時鐘轉54度, 然後橫躺矩形為90度;最後轉到120度Contour包覆效果取橢圓的長短軸當面積,不過隨物體旋轉角度更動, 最小包覆面積也會改變斜率>0 : 0°~90°斜率<0 : 90°~180°

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

image
看了網路上[1]有關Function Pointer, 感覺Function Pointer使用語法很累贅, 於是聯想到typedef來簡化原本累贅的語法double (*PtrFun)(double a, double b)只要前面多加一個typedef, 呼叫上就會變得比較親民typedef double (*PtrFun)(double a, double b)例如我想要一個四則運算的功能PtrFun p[4]{ OperatorAdd, OperatorSub, OperatorMul, OperatorDev };宣告一個PtrFun資料型態,存放四個函式指標(即為函式名稱)

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

image
先到研華官網下載以下兩個應用程式1. 安裝 COMMON MOTION DRIVER_X86.exe2. 安裝 COMMON MOTION UTILITY EXAMPLES_X86.exe點選桌面連結按下->按鈕後,馬達開始往正方向移動,按下<停止>按鈕停止動作。按下<-按鈕後,馬達開始往負方向移動,按下<停止>按鈕停止動作。

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

Blob Characteristics
The Objects(BLOB) are sorted by Circularity from small to big(1)  (2)  (3) (4)

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

 

method=CV_TM_SQDIFF

image

image image

method=CV_TM_SQDIFF_NORMED

image

image image

method=CV_TM_CCORR

image

image image

method=CV_TM_CCORR_NORMEDimage

Normalize真棒! 相較於上一個參數只差別分母(正規化部分), 竟然有這麼神奇的效果

image image

method=CV_TM_CCOEFF

image

image image

method=CV_TM_CCOEFF_NORMED

image

image image

--------------------------------

計算流程: matchTemplate -> normalize-> minMaxLoc

全域最大值: CV_TM_CCORRCV_TM_CCOEFF

全域最小值: CV_TM_SQDIFF



參考資料:

1. Object Detection

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

image
ActivVisionTool是好幾年前的影像量測工具, 下面這段範例程式看起來像是原廠底層activeX元件沒寫好, 竟然要寫一個GC.Collect()在自身的Live取像程式Event內, 不加入就會發生memory leakage喔!關閉程式, 自動儲存DSC參數檔案儲存: AxAVTView1.ExitApplication(True)確認EnableWriteToDSCFile==True不儲存: AxAVTView1.ExitApplication(False)m_AVTView.SetEnableWriteToDSCFile(FALSE);Keep in mind that the DSC files, which store the settings, reside in the same directory as the executable

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

image
下圖(A)、(B)、(C)是一般影像處理常見的處理手法,如何撰寫ImgProc blockset讓影像資料,可以像是串流般一直往下進行,本篇將撰寫一個應用範例:將各個獨立影像模組(module)如同積木般堆疊、依照所需要的順序串接,且不限制積木的個數;過程中還能隨時觀看處理前後的結果,甚至恢復上一步(Undo)。裝飾模式(Decorator)[1]: 動態地給一個物件加入一些額外的職責,就增加功能來說,裝飾模式比產生子類別更為靈活。
 1: class ImgProc
 2: {
 3: private Mat m_srcImg;
 4: private Mat m_dstImg;
 5: private ImageBox m_srcImageBox;
 6: private ImageBox m_dstImageBox;
 7: public Mat SourceImage
 8: {
 9: get { return m_srcImg; }
 10: set { m_srcImg = value; }
 11: }
 12: public Mat TargetImage
 13: {
 14: get { return m_dstImg; }
 15: set { m_dstImg = value; }
 16: }
 17:  
 18: public void LoadImage(string filename)
 19: {
 20: m_srcImg = CvInvoke.Imread(filename, LoadImageType.Unchanged);
 21: m_dstImg = m_srcImg.Clone();
 22: }
 23: public virtual void SetSrcImageBox(ImageBox imageBox)
 24: {
 25: m_srcImageBox = imageBox;
 26: }
 27: public virtual void SetDstImageBox(ImageBox imageBox)
 28: {
 29: m_dstImageBox = imageBox;
 30: }
 31: 
 32: public virtual void ShowSrcImage()
 33: {
 34: m_srcImageBox.Image = m_srcImg;
 35: }
 36: public virtual void ShowDstImage()
 37: {
 38: m_dstImageBox.Image = m_dstImg;
 39: }
 40: public virtual void ImageProc()
 41: {
 42:  
 43: }
 44: public virtual void Undo()
 45: {
 46: this.m_dstImg = this.m_srcImg.Clone();
 47: }
 48: }

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

Blog Stats
⚠️

成人內容提醒

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

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