歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 使用OpenCV編寫的LDA程序----C++ LDA代碼

使用OpenCV編寫的LDA程序----C++ LDA代碼

日期:2017/3/1 9:43:47   编辑:Linux編程

改寫自OpenCV中的lda.cpp程序,通過改寫的程序可以返回自己所需的信息(LDA算法過程中產生的我們感興趣的中間值),實現算法的獨立編譯,也可以通過閱讀程序,加深對LDA算法的理解。

Objective-C中@property的所有屬性詳解 http://www.linuxidc.com/Linux/2014-03/97744.htm

Objective-C 和 Core Foundation 對象相互轉換的內存管理總結 http://www.linuxidc.com/Linux/2014-03/97626.htm

使用 Objective-C 一年後我對它的看法 http://www.linuxidc.com/Linux/2013-12/94309.htm

10個Objective-C基礎面試題,iOS面試必備 http://www.linuxidc.com/Linux/2013-07/87393.htm

Objective-C適用C數學函數 <math.h> http://www.linuxidc.com/Linux/2013-06/86215.htm

// main.cpp : 定義控制台應用程序的入口點。
//

#include "stdafx.h"
#include <cxcore.hpp>
#include <vector>
#include <iostream>
#include "lda.h"
using namespace std;
using namespace cv;

int main(void)
{
double data[6][2]={{0,1},{0,2},{1,4},{8,0},{8,2},{9,4}};
Mat dmat=Mat(6,2,CV_64FC1,data);
int labels[6]={0, 0, 0, 1, 1, 1};
Mat lmat=Mat(1,6,CV_32SC1,labels);

cout<<"--------------------------------"<<endl;

MyLDA(dmat, lmat);

system("pause");
return 0;
}

//lda.h

#ifndef _MY_LDA_H
#define _MY_LDA_H

#include <cxcore.hpp>
#include <vector>
using namespace std;
using namespace cv;

/*********************
_src:
輸入的采樣數據,Mat類型,每行是一個樣本數據
_lbls:
輸入的類別標簽,可以是矩陣或者向量

還沒有返回值,需要的朋友可以自己做進一步改寫
/********************/
extern void MyLDA(InputArrayOfArrays _src, InputArray _lbls);

#endif

更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2014-05/102410p2.htm

Copyright © Linux教程網 All Rights Reserved