首页 / 操作系统 / Linux / 使用OpenCV编写的LDA程序----C++ LDA代码
改写自OpenCV中的lda.cpp程序,通过改写的程序可以返回自己所需的信息(LDA算法过程中产生的我们感兴趣的中间值),实现算法的独立编译,也可以通过阅读程序,加深对LDA算法的理解。Objective-C中@property的所有属性详解 http://www.linuxidc.com/Linux/2014-03/97744.htmObjective-C 和 Core Foundation 对象相互转换的内存管理总结 http://www.linuxidc.com/Linux/2014-03/97626.htm使用 Objective-C 一年后我对它的看法 http://www.linuxidc.com/Linux/2013-12/94309.htm10个Objective-C基础面试题,iOS面试必备 http://www.linuxidc.com/Linux/2013-07/87393.htmObjective-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