PokerNet-poker recognition: 基于人工神经网络的扑克识别 (5)
结果1

void computeBCValue(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names,
int current_det_fps = -1, int current_cap_fps = -1)
{
int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } };
Cardsets cardsets;
int tempx = 0;
vector<bbox_t> mypoints; //
for (auto &i : result_vec) {
if (i.prob < confidencetheta) { // if I am not confident than 50%, skip this poker
continue;
}
// here we compute the distance w.r.t (0,0)
if (i.h < i.w) {// 3rd
if (i.prob > cardsets.confidence[2]) {
cardsets.confidence[2] = i.prob;
cardsets.cardvalues[2] = Point3f(i.x, i.y, i.obj_id);
}
}
else {
mypoints.push_back(i);
}
}
if (cardsets.cardvalues[2].x > 0) {
//cout << "3rd-" << obj_names[cardsets.cardvalues[2].z] << endl;
}
if (mypoints.size() < 2) { return; }
sort(mypoints.begin(), mypoints.end(), SetSortRule);
int first = 0;
int second = 0;
if (mypoints.size() == 4) {//
if (mypoints[0].prob > mypoints[1].prob) {
//cout << "1st-" << obj_names[mypoints[0].obj_id] << endl;
first = 0;
}
else {
//cout << "1st-" << obj_names[mypoints[1].obj_id] << endl;
first = 1;
}
if (mypoints[2].prob > mypoints[3].prob) {
// cout << "2ed-" << obj_names[mypoints[2].obj_id] << endl;
second = 2;
}
else {
//cout << "2ed-" << obj_names[mypoints[3].obj_id] << endl;
second = 3;
}
}
else if (mypoints.size() == 3) {// if we only detect 3 points, take first one to match with other two decide which is pair
/* details of the theroy are on the notebook page */
int delta_y = mypoints[1].y - mypoints[0].y;
if (getCosineDistance(mypoints[0], mypoints[1]) < getCosineDistance(mypoints[0], mypoints[2]) && delta_y > 100) { // we assume they belong to one card
first = mypoints[0].prob > mypoints[1].prob ? 0 : 1;
second = 2;
}
else {// 0 and 1 not one card
// cout << "1st-" << obj_names[mypoints[0].obj_id] << endl;
second = mypoints[1].prob > mypoints[2].prob ? 1 : 2;
}
}
else if (mypoints.size() == 2) {
if (getCosineDistance(mypoints[0], mypoints[1]) < cosinetheta) { // we assume they belong to one card
first = mypoints[0].prob > mypoints[1].prob ? 0 : 1;
}
else {
second = 1;
}
}
cardsets.confidence[0] = mypoints[first].prob;
cardsets.cardvalues[0] = Point3f(mypoints[first].x, mypoints[first].y, mypoints[first].obj_id);
cardsets.confidence[1] = mypoints[second].prob;
cardsets.cardvalues[1] = Point3f(mypoints[second].x, mypoints[second].y, mypoints[second].obj_id);
ostringstream info;
info << "1st-" << obj_names[mypoints[first].obj_id] << ",confidence-" << setprecision(2) << fixed << mypoints[first].prob << ",";
info << "2ed-" << obj_names[mypoints[second].obj_id] << ",confidence-" << setprecision(2) << fixed << mypoints[second].prob << ",";
if (cardsets.cardvalues[2].x > 0) { info << "3rd-" << obj_names[cardsets.cardvalues[2].z] << ",confidence-" << setprecision(2) << fixed << cardsets.confidence[2] << ","; }
cout << info.str() << endl;
putText(mat_img, info.str(), cv::Point(5, 40), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255));
}
结果2

void computeDTValue(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names,
int current_det_fps = -1, int current_cap_fps = -1)
{
int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } };
int tempx = 0;
vector<bbox_t> mypoints; //
for (auto &i : result_vec) {
if (i.prob > confidencetheta) { // if I am not confident than 50%, skip this poker
mypoints.push_back(i);
}
}
sort(mypoints.begin(), mypoints.end(), SetSortRulebyConfidence);
int cardids = 0;
float confidence = 0;
if (mypoints.size() > 0) {
cardids = mypoints[0].obj_id;
confidence = mypoints[0].prob;
}
else { //error
cout << "nothing detected" << endl;
}
ostringstream info;
info << "1st-" << obj_names[cardids] << ",confidence-" << setprecision(2) << fixed << confidence << ",";
cout << info.str() << endl;
cv::putText(mat_img, info.str(), cv::Point(5, 40), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255));
}
PokerNet-poker recognition: 基于人工神经网络的扑克识别 (5)的更多相关文章
- 基于卷积神经网络的人脸识别项目_使用Tensorflow-gpu+dilib+sklearn
https://www.cnblogs.com/31415926535x/p/11001669.html 基于卷积神经网络的人脸识别项目_使用Tensorflow-gpu+dilib+sklearn ...
- Pytorch实现基于卷积神经网络的面部表情识别(详细步骤)
文章目录 一.项目背景 二.数据处理 1.标签与特征分离 2.数据可视化 3.训练集和测试集 三.模型搭建 四.模型训练 五.完整代码 一.项目背景数据集cnn_train.csv包含人类面部表情的图 ...
- 基于卷积神经网络的面部表情识别(Pytorch实现)----台大李宏毅机器学习作业3(HW3)
一.项目说明 给定数据集train.csv,要求使用卷积神经网络CNN,根据每个样本的面部图片判断出其表情.在本项目中,表情共分7类,分别为:(0)生气,(1)厌恶,(2)恐惧,(3)高兴,(4)难过 ...
- 深度学习项目——基于卷积神经网络(CNN)的人脸在线识别系统
基于卷积神经网络(CNN)的人脸在线识别系统 本设计研究人脸识别技术,基于卷积神经网络构建了一套人脸在线检测识别系统,系统将由以下几个部分构成: 制作人脸数据集.CNN神经网络模型训练.人脸检测.人脸 ...
- 硕毕论文_基于 3D 卷积神经网络的行为识别算法研究
论文标题:基于 3D 卷积神经网络的行为识别算法研究 来源/作者机构情况: 中 国 地 质 大 学(北京),计算机学院,图像处理方向 解决问题/主要思想贡献: 1. 使用张量CP分解的原理, ...
- C#中调用Matlab人工神经网络算法实现手写数字识别
手写数字识别实现 设计技术参数:通过由数字构成的图像,自动实现几个不同数字的识别,设计识别方法,有较高的识别率 关键字:二值化 投影 矩阵 目标定位 Matlab 手写数字图像识别简介: 手写 ...
- 人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五)
原文:人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五) 前面4篇文章说的是模糊系统,它不同于传统的值逻辑,理论基础是模糊数学,所以有些朋友看着有点迷糊,如果有兴趣建议参 ...
- 基于BP神经网络的字符识别研究
基于BP神经网络的字符识别研究 原文作者:Andrew Kirillov. http://www.codeproject.com/KB/cs/neural_network_ocr.aspx 摘要:本文 ...
- 人工神经网络--ANN
神经网络是一门重要的机器学习技术.它是目前最为火热的研究方向--深度学习的基础.学习神经网络不仅可以让你掌握一门强大的机器学习方法,同时也可以更好地帮助你理解深度学习技术. 本文以一种简单的,循序的方 ...
随机推荐
- ios网络学习------2 用非代理方法实现同步post请求
#pragma mark - 这是私有方法,尽量不要再方法中直接使用属性,由于一般来说属性都是和界面关联的,我们能够通过參数的方式来使用属性 #pragma mark post登录方法 -(void) ...
- nginx打包成rpm
[root@localhost ~ ]#yum -y install lrzsz pcre pcre-devel zlib zlib-devel vim nrt-tools psmisc gcc gc ...
- union 或者 union all 与 order by 的联合使用
首先清楚:多个select 语句 union 时不是简单的将查询结果拼接起来 而是将sql拼接起来编译(做为一个sql语句),然后去执行. 注: union 连接的语句中只会出现一个order by ...
- jdk8中map新增的merge方法介绍
1.Map.merge方法介绍 jdk8对于许多常用的类都扩展了一些面向函数,lambda表达式,方法引用的功能,使得java面向函数编程更为方便.其中Map.merge方法就是其中一个,merge方 ...
- 基本TCP Sockets编程
一.socket 函数 #include <sys/socket.h> int socket (int family, int type, int protocol); Returns: ...
- HashMap和Hashtable有什么区别
HashMap和Hashtable都实现了Map接口,因此很多特性非常相似.但是,他们有以下不同点: HashMap允许键和值是null,而Hashtable不允许键或者值是null. Hashtab ...
- nodejs 模板引擎ejs的简单使用(3)
1.ejs <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- CentOS 7 編譯qBittorrent Web UI安裝指南
前言 以下是安装qBittorrent教学. 适用于CentOS7或更新版本 适用于qBittorrent4.1.5或更新版本 安裝須知 qBittorrent基于libtorrent,所以必须先安装 ...
- LoadRunner模拟REST接口的json请求
LoadRunner模拟REST接口的json请求 现在很多手机应用的性能测试,REST接口调用通过json格式,在用loadrunner模拟这些json请求时,需要开发提供 1.供接口地址 2.提交 ...
- c++ GetAsyncState() 函数
函数原型 SHORT GetAsyncKeyState(int vKey); 例:若判断 回车键 if(GetAsyncKeyState(VK_RETURN)&0x8000) ( return ...