Linux
Alg SDK接入说明
流程图
SDK 文件说明
下载alg-linux-v1.0.zip,并解压
libalg_algorithm.so
算法动态链接库alg_algorithm.h
算法头文件inputData/zeng.csv
测试用eeg数据mian.c
sdk使用实例代码readcsv.c
,readcsv.h 读文件工具
SDK 方法说明
初始化方法
void initAll(void); 初始化数据
添加设备
int add_device(char *serial) 参数为设备名称
连接设备成功后,需要添加设备,返回值为设备index,后面获取指标需要用到
删除设备
int delete_device(char * serial) 参数为设备名称
删除之前添加的设备
解析原始数据函数
get_eeg_info_t Split_data_frame(char *str)
参数为蓝牙每帧的 16 进制字符串
返回结果
typedef struct
{
unsigned int frame_dect_ok; //检测帧的完整性,完整则为1,否则为0
int frame_index;
unsigned long group_count; //得到eeg的采样点组数
double AF7_eeg_data[50]; //AF7通道原始数据
int AF7_leadoff_flag[50]; //AF7通道信号质量
double AF8_eeg_data[50]; //AF8通道原始数据
int AF8_leadoff_flag[50]; //AF8通道信号质量
int have_4sec_time_flag; //得到4秒标志
int time_flag_postion; //时间标志在数据帧中的位置,如第一组时位置为0
long time_counter; //时间计数器
} get_eeg_info_t;
获取算法指标
algorithmTarget get_algorithm_result(double data_raw[58],int index) 参数为蓝牙解析后的原始数据,数组前 29 位 AF7,后 29 位 AF8;index 为添加设备方法获取的下标。
返回结果
typedef struct {
double alphaRelative; // alpha 相对能量
double betaRelative;
double thetaRelative;
double deltaRelative;
double gammaRelative;
double alphaAbsolute; // alpha 绝对能量
double betaAbsolute;
double thetaAbsolute;
double deltaAbsolute;
double gammaAbsolute;
}energyName;
typedef struct {
double mindfullness; // 正念
double focus;// 专注
double emotion;// 情绪
double stress; // 压力
double fatigue;// 疲劳
double relax; // 放松
energyName energy;
int isValid;
int sqd[2];
int sqdValid;
} algorithmTarget;
typedef struct{
int stability; // 稳定度
double potential; // 潜力值
double percent; // 百分比
int score;// 分数
} mindfulnessScore;
注意stress,focus,fatigue,relax需要量化
int mapStress(double stress);
int mapFocus(double focus);
int mapFatig(double fatig);
fatigue,relax使用同一个量化方法
具体的数据和指标说明请参考:数据说明
获取正念指数指标
energyCoherence get_alg_coherence(double * indata,int len) 获取正念指数指标(传输原始值,512个AF7原始值+512个AF8原始值,128的步长窗口后移,传入的len指定为512)
获取正念雷达图四个指标
mindfulnessScore getMindfulnessScore(double * array,int length)
array脑电算法计算的正念值数组(经过getMindfulness得到energyCoherence.theta),length数组长度,返回指标结构体
typedef struct{
int stability; // 稳定度
double potential; // 潜力值
double percent; // 百分比
int score;// 分数
} mindfulnessScore;
具体的数据和指标说明请参考:数据说明