diff --git a/Makefile b/Makefile
index 02dc534..149d9f9 100644
--- a/Makefile
+++ b/Makefile
@@ -6,13 +6,13 @@ CC = g++ -Wall -O3 -Wno-unused-result $(CINC)
all: ${BIN}/build ${BIN}/recog
# Generates a compiler for an d_lang language,
-${BIN}/build: $(SRC)/build.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp $(SRC)/bmp.cpp
+${BIN}/build: $(SRC)/build.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp
mkdir -p ${BIN}
- $(CC) -o $(BIN)/build $(SRC)/build.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/bmp.cpp $(SRC)/wav.cpp -ll -lm -lfftw3
+ $(CC) -o $(BIN)/build $(SRC)/build.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp -lfftw3
-${BIN}/recog: $(SRC)/recog.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp $(SRC)/bmp.cpp
+${BIN}/recog: $(SRC)/recog.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp
mkdir -p ${BIN}
- $(CC) -o $(BIN)/recog $(SRC)/recog.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/bmp.cpp $(SRC)/wav.cpp -ll -lm -lfftw3
+ $(CC) -o $(BIN)/recog $(SRC)/recog.cpp $(SRC)/hash.cpp $(SRC)/fingerprint.cpp $(SRC)/wav.cpp -lfftw3
clean:
rm -f *.BAK *.o core *~* *.a
diff --git a/data/dataset.txt b/data/dataset.txt
new file mode 100644
index 0000000..95975be
--- /dev/null
+++ b/data/dataset.txt
@@ -0,0 +1,39 @@
+/root/ws/AudioRecognition/data/
+007.wav
+Fly-Me-To-The-Moon.wav
+Halo.wav
+Heart-And-Soul.wav
+Historia-De-Un-Amor.wav
+Just-Dance.wav
+Just-One-Last-Dance.wav
+Loving-You.wav
+Moves-Like-Jagger.wav
+Never-Say-Goodbye.wav
+Never-Say-Never.wav
+Only-Time.wav
+Only-You.wav
+Part-Of-Me.wav
+Poker-Face.wav
+Pretty-Boy.wav
+Price-Tag.wav
+Rolling-In-The-Deep.wav
+Safe---Sound-.wav
+Satin-Doll.wav
+Seven-Years.wav
+She-Is-My-Sin.wav
+Solitude.wav
+Stronger--What-Doesn-t-Kill-You-.wav
+Summer.wav
+That-Place-In-Your-Heart.wav
+The-Promise.wav
+Trespassing.wav
+Trouble-Is-A-Friend.wav
+Unforgivable-Sinner.wav
+Vertigo.wav
+Wake-Up-Call.wav
+Walking-In-The-Sun.wav
+We-Will-Rock-You.wav
+What-A-Wonderful-World.wav
+Whataya-Want-From-Me.wav
+Work-Out.wav
+Yellow.wav
diff --git a/data/getdata.sh b/data/getdata.sh
new file mode 100755
index 0000000..9178a8d
--- /dev/null
+++ b/data/getdata.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+axel http://home.ustc.edu.cn/~kaiki/dataset/007.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Fly-Me-To-The-Moon.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Halo.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Heart-And-Soul.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Historia-De-Un-Amor.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Just-Dance.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Just-One-Last-Dance.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Loving-You.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Moves-Like-Jagger.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Never-Say-Goodbye.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Never-Say-Never.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Only-Time.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Only-You.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Part-Of-Me.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Poker-Face.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Pretty-Boy.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Price-Tag.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Rolling-In-The-Deep.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Safe---Sound-.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Satin-Doll.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Seven-Years.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/She-Is-My-Sin.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Solitude.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Stronger--What-Doesn-t-Kill-You-.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Summer.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/That-Place-In-Your-Heart.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/The-Promise.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Trespassing.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Trouble-Is-A-Friend.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Unforgivable-Sinner.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Vertigo.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Wake-Up-Call.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Walking-In-The-Sun.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/We-Will-Rock-You.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/What-A-Wonderful-World.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Whataya-Want-From-Me.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Work-Out.wav &
+axel http://home.ustc.edu.cn/~kaiki/dataset/Yellow.wav
diff --git a/include/bmp.h b/include/bmp.h
deleted file mode 100644
index f93067e..0000000
--- a/include/bmp.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**-------------------------/// bmp include \\\---------------------------
- *
- * bmp include
- * @version :
- * @since : 2015 2月 07
- *
- * @description :
- *
- * @usage :
- *
- * @author : 'Jiahui Yu' | yjh199511 gmail.com
- * @copyright
- * @TODO :
- *
- *--------------------------\\\ bmp include ///---------------------------*/
-
-#ifndef BMP_H
-#define BMP_H
-
-#define BMP_TEST
-
-#include
-#include
-#include
-#include
-#define checkborder(x,y) (x>=0 && x=0 && y
#include
#include
-#include
#include
#define FRAME_SIZE 512
diff --git a/src/bmp.cpp b/src/bmp.cpp
deleted file mode 100644
index e1224cd..0000000
--- a/src/bmp.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/**-------------------------/// bmp \\\---------------------------
- *
- * bmp pics head
- * @version : 1.0
- * @since : 2015 2 07
- *
- * @description :
- * To produce bmp pictures.
- * @usage :
- *
- * @author : 'Jiahui Yu' | yjh199511 ^_^ gmail.com
- * @copyright
- * @TODO :
- *
- *--------------------------\\\ bmp ///---------------------------*/
-
-#include "bmp.h"
-
-TBMP::TBMP(const char *filename, int w, int h, int mode){
-#ifdef BMP_TEST
- char bufferc[4];
- /* char ch = 255; */
- unsigned long buffer4;
- unsigned short buffer2;
-
- fp = fopen(filename, "wb");
- if (fp == NULL) printf("!!");
- W = w;
- H = h;
- MODE = mode%2;
- if (W%4!=0) W=(W/4+1)*4;
-
- int i, j;
- bitmap = (char **)malloc(H * sizeof(char *));
- if (bitmap == NULL) printf("00");
- for(i=0; i=0; j--)
- fwrite(bitmap[j], 1, W, fp);
- fclose(fp);
- //realease resources
-#endif
-}
-
-int TBMP::setcolor(int grey){
-#ifdef BMP_TEST
- if (grey<0 || grey>255)
- return 1;
-
- Grey = grey;
- return 0;
-#endif
-}
-
-int TBMP::drawpoint(int x, int y){
-#ifdef BMP_TEST
- if (!checkborder(x,y))
- return 1;
-
- if (MODE)
- bitmap[H-1-y][x] = Grey;
- else
- bitmap[y][x] = Grey;
- return 0;
-#endif
-}
-
-int TBMP::drawline(int x0, int y0, int x1, int y1){
-#ifdef BMP_TEST
- if (!checkborder(x0, y0) || !checkborder(x1, y1))
- return 1;
- if (x0==x1 && y0==y1)
- return drawpoint(x0, y0);
-
- int xs, ys, xe, ye;
- int i, j;
- double t;
- if (abs(x0-x1) >= abs(y0-y1)){
- if (x0 < x1){
- xs = x0;
- ys = y0;
- xe = x1;
- ye = y1;
- }
- else{
- xs = x1;
- ys = y1;
- xe = x0;
- ye = y0;
- }
- t = (double)(ye - ys) / (double)(xe - xs);
- for (i=xs; i<=xe; i++){
- j = (int)((i - xs) * t + ys);
- drawpoint(i,j);
- //bitmap[j][i] = Grey;
- }
- }
- else{
- if (y0 < y1){
- xs = x0;
- ys = y0;
- xe = x1;
- ye = y1;
- }
- else{
- xs = x1;
- ys = y1;
- xe = x0;
- ye = y0;
- }
- t = (double)(xe - xs) / (double)(ye - ys);
- for (j=ys; j<=ye; j++){
- i = (int)((j-ys) * t + xs);
- drawpoint(i,j);
- //bitmap[j][i] =Grey;
- }
- }
- return 0;
-#endif
-}
-
-int TBMP::drawrect(int x0, int y0, int x1, int y1){
-#ifdef BMP_TEST
- return drawline(x0, y0, x0, y1) || drawline(x0, y0, x1, y0) \
- || drawline(x1, y0, x1, y1) || drawline(x0, y1, x1, y1);
-#endif
-}
diff --git a/src/build.cpp b/src/build.cpp
index e90e0d3..8850b2b 100644
--- a/src/build.cpp
+++ b/src/build.cpp
@@ -20,7 +20,7 @@
#include // 提供目录流操作函数
#include // 提供属性操作函数
#include // 提供mode_t 类型
-#include
+#include
using namespace std;
@@ -33,41 +33,28 @@ int Initialize(){
}
int ProcessBuildRes(const char *szResDir, const char *szResPath){
- int index = 0;
- char FileName[80];
- DIR *dp; // 定义子目录流指针
- struct dirent *entry; // 定义dirent结构指针保存后续目录
- struct stat statbuf; // 定义statbuf结构保存文件属性
- if((dp = opendir(szResDir)) == NULL) // 打开目录,获取子目录流指针,判断操作是否成功
- {
- printf("Can't open dir.\n");
- return 1;
- }
- chdir(szResDir); // 切换到当前目录
- while ( (entry = readdir(dp)) != NULL ) //获取下一级目录信息,如果未否则循环
- {
- lstat(entry->d_name, &statbuf); // 获取下一级成员属性
- if (!(S_IFDIR &statbuf.st_mode)) // 判断下一级成员不是目录
- {
- strcpy(FileName, entry->d_name);
- myhash.AddSongList(FileName);
- char FilePath[80] = "";
- strcat(FilePath, szResDir);
- strcat(FilePath, FileName);
- /* printf("%s\n",FilePath); // 输出属性不是目录的成员 */
- fingerprint.ExtractPair(FilePath, myhash, 0, (float)0.98, index, 0);
- printf("%d: %s 建库成功.\n",index , FileName); // 输出属性不是目录的成员
- fingerprint.UnInit();
- index ++;
- }
- }
- printf("%d.\n", index);
- chdir("..");
- closedir(dp); // 关闭子目录流
- //write to the database
- myhash.Hash2File(szResPath);
-
- return 0;
+ int index = 0;
+ char audioname[80];
+ char basepath[80];
+ fstream fs_in;
+ fs_in.open(szResDir, std::fstream::in);
+ fs_in.getline(basepath, 80);
+ while (fs_in.getline(audioname, 80)) {
+ // add to hash
+ myhash.AddSongList(audioname);
+ // get audio path
+ char audiopath[80] = "";
+ strcat(audiopath, basepath);
+ strcat(audiopath, audioname);
+ fingerprint.ExtractPair(audiopath, myhash, 0, (float)0.98, index, 0);
+ printf("%d: %s Add song's fingerprint sucessfully.\n",index , audiopath); // 输出属性不是目录的成员
+ fingerprint.UnInit();
+ index ++;
+ printf("%d.\n", index);
+ }
+ //write to the database
+ myhash.Hash2File(szResPath);
+ return 0;
}
int unInitialize(){
diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp
index 3e8d774..0c1d9b7 100644
--- a/src/fingerprint.cpp
+++ b/src/fingerprint.cpp
@@ -211,8 +211,6 @@ int TExtractFeature::Feature2PairInsert(THash &hash, int id){
}
int TExtractFeature::Feature2PairSearch(THash &hash){
- TBMP tb("pair.bmp", frame_num, FRAME_HEIGHT, 1);
- tb.setcolor(0);
int pi, pj;
int count;
int flag;
@@ -229,7 +227,6 @@ int TExtractFeature::Feature2PairSearch(THash &hash){
continue;
count++;
hash.Vote(j, pj-j+f2_f1_max, pi-i, i);
- tb.drawline(i, j, pi, pj);
/* if (count >= MAX_PAIR_PER_FEATURE) flag = 0; */
}
}