91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

本例采用opencv的隨機(jī)森林對(duì)圖像做分類(lèi),提取的是圖像的顏色直方圖,然后計(jì)算統(tǒng)計(jì)特征,采用csv文件存儲(chǔ)圖像特征。

資源截圖

代碼片段和文件信息

//?openCvRandomForest.cpp?:?定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//

#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
?
using?namespace?cv;
using?namespace?std;
?

/******************************************************************************/??
//?global?definitions?(for?speed?and?ease?of?use)??
//隨機(jī)森林實(shí)現(xiàn)
??
#define?NUMBER_OF_TRAINING_SAMPLES?862????????//樣本數(shù)目
#define?ATTRIBUTES_PER_SAMPLE?9???????????????//每個(gè)樣本的特征值,數(shù)據(jù)為csv格式
#define?NUMBER_OF_TESTING_SAMPLES?14753???????//測(cè)試數(shù)目?
??
#define?NUMBER_OF_CLASSES?2???????????????????//類(lèi)別數(shù)目,用int類(lèi)型的數(shù)字標(biāo)記,從0開(kāi)始
??
//?N.B.?classes?are?integer?handwritten?digits?in?range?0-9??
??
/******************************************************************************/??
??
//?loads?the?sample?database?from?file?(which?is?a?CSV?text?file)??
??
int?read_data_from_csv(const?char*?filename?Mat?data?Mat?classes?int?n_samples?)??
{??
????float?tmp;??
??
????//?if?we?can‘t?read?the?input?file?then?return?0??
????FILE*?f?=?fopen(?filename?“r“?);??
????if(?!f?)??
????{??
????????printf(“ERROR:?cannot?read?file?%s\n“??filename);??
????????return?0;?//?all?not?OK??
????}??
??
????//?for?each?sample?in?the?file??
??
????for(int?line?=?0;?line?????{??
????????//?for?each?attribute?on?the?line?in?the?file??
????????for(int?attribute?=?0;?attribute?????????{??
????????????if?(attribute?????????????{??
????????????????//?first?64?elements?(0-63)?in?each?line?are?the?attributes??
????????????????fscanf(f?“%f“?&tmp);??
????????????????data.at(line?attribute)?=?tmp;??
????????????????//?printf(“%f“?data.at(line?attribute));??
????????????}??
????????????else?if?(attribute?==?9)??
????????????{??
????????????????//?attribute?65?is?the?class?label?{0?...?9}??
????????????????fscanf(f?“%f“?&tmp);??
????????????????classes.at(line?0)?=?tmp;??
????????????????//?printf(“%f\n“?classes.at(line?0));??
????????????}??
????????}??
????}??
??
????fclose(f);??
????return?1;????//?all?OK??
}??

/******************************************************************************/??

int?main(?int?argc?char**?argv)??
{??
??????
????//?lets?just?check?the?version?first??
????printf?(“OpenCV?version?%s?(%d.%d.%d)\n“??CV_VERSION?CV_MAJOR_VERSION?CV_MINOR_VERSION?CV_SUBMINOR_VERSION);??
????const?char*?trainDataFile=“data7.csv“;
const?char*?testDataFile=“Sample11.csv“;
????//定義訓(xùn)練數(shù)據(jù)與標(biāo)簽矩陣??
????Mat?training_data?=?Mat(NUMBER_OF_TRAINING_SAMPLES?ATTRIBUTES_PER_SAMPLE?CV_32FC1);??
????Mat?training_classifications?=?Mat(NUMBER_OF_TRAINING_SAMPLES?1?CV_32FC1);??
??
????//定義測(cè)試數(shù)據(jù)矩陣與標(biāo)簽??
????Mat?testing_data?=?Mat(NUMBER_OF_TESTING_SAMPLES?ATTRIBUTES_PER_SAMPLE?CV_32FC1);??
????Mat?testing_classifications?=?Mat(NUMBER_OF_TESTING_SAMPLES?1?CV_32F

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-17?15:48??openCvRandomForest\
?????目錄???????????0??2016-08-17?15:37??openCvRandomForest\Debug\
?????文件???????87552??2016-08-17?15:46??openCvRandomForest\Debug\openCvRandomForest.exe
?????文件??????580324??2016-08-17?15:46??openCvRandomForest\Debug\openCvRandomForest.ilk
?????文件?????1412096??2016-08-17?15:46??openCvRandomForest\Debug\openCvRandomForest.pdb
?????目錄???????????0??2016-08-17?15:22??openCvRandomForest\ipch\
?????目錄???????????0??2016-08-17?15:37??openCvRandomForest\ipch\opencvrandomforest-a952a877\
?????文件?????2818048??2016-08-17?15:37??openCvRandomForest\ipch\opencvrandomforest-a952a877\opencvrandomforest-a1348e8b.ipch
?????目錄???????????0??2016-08-17?15:26??openCvRandomForest\openCvRandomForest\
?????目錄???????????0??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\
?????文件???????16476??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\CL.read.1.tlog
?????文件????????1114??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\CL.write.1.tlog
?????文件????????1706??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\cl.command.1.tlog
?????文件???????????2??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link-cvtres.read.1.tlog
?????文件???????????2??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link-cvtres.write.1.tlog
?????文件???????????2??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link-rc.read.1.tlog
?????文件???????????2??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link-rc.write.1.tlog
?????文件????????2372??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link.command.1.tlog
?????文件????????5454??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link.read.1.tlog
?????文件?????????744??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\link.write.1.tlog
?????文件??????????72??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\openCvRandomForest.lastbuildstate
?????文件????????2079??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\openCvRandomForest.log
?????文件??????266379??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\openCvRandomForest.obj
?????文件?????1245184??2016-08-17?15:34??openCvRandomForest\openCvRandomForest\Debug\openCvRandomForest.pch
?????文件???????11844??2016-08-17?15:34??openCvRandomForest\openCvRandomForest\Debug\stdafx.obj
?????文件??????429056??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\vc110.idb
?????文件??????839680??2016-08-17?15:46??openCvRandomForest\openCvRandomForest\Debug\vc110.pdb
?????文件????????1587??2016-08-17?15:17??openCvRandomForest\openCvRandomForest\ReadMe.txt
?????文件?????1258985??2016-07-29?12:57??openCvRandomForest\openCvRandomForest\Sample11.csv
?????文件???????45139??2016-07-28?21:51??openCvRandomForest\openCvRandomForest\data7.csv
?????文件????????8084??2016-08-17?15:44??openCvRandomForest\openCvRandomForest\openCvRandomForest.cpp
............此處省略9個(gè)文件信息

評(píng)論

共有 條評(píng)論