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
神经网络是一门重要的机器学习技术.它是目前最为火热的研究方向--深度学习的基础.学习神经网络不仅可以让你掌握一门强大的机器学习方法,同时也可以更好地帮助你理解深度学习技术. 本文以一种简单的,循序的方 ...
随机推荐
- 移动端新建html页面
这是一些头部设置 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- redis数据结构之SDS
简介 redis源码虽然是C语言实现的,但是Redis没有直接采用C语言传统的字符串表示,而是构建了一种名叫简单动态字符串(simple dynamic string,SDS)的抽象类型,并将SDS用 ...
- Excel函数——ANSI字符集与Code、Char、Asc函数
小叙背景 Windows系统下,默认的字符集为ANSI,该字符编码方式在不同语言环境下采用不同的编码方案,在中文系统下ANSI编码是GBK.ANSI由ASCII扩展而来,ANSI下无论何种具体的编码方 ...
- Flyway - Version control for your database
Flyway 是什么? Flyway是个数据库版本管理工具.在开发过程中,数据库难免发生变更,例如数据变更,表结构变更.新建表或者视图等等. 在项目进行时无法保证一旦开发环境中的数据库内容变化候会去测 ...
- Failed selinux 错误
再看他如何解决,步骤大概是: 1.开机之后进入linux启动选择界面,停在平时启动的哪那一行按E键,进入grub编辑页面. 2.按↓键光标往下移,在标签fi下面的内容里加上一个enforcing=0. ...
- 按钮与js事件先后顺序
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- idea 在新建一个class的时候可以选择继承的父类
1.把光标放在父类名称上按alt+enter可以生成子类 2. 选中implement abstract class
- Redis探索之路(一):Redis简介
一:NOSQL NotOnlySQL 反SQL运动,非关系型数据库(区别于Mysql关系型书库). 随着Web2.0兴起,“高性能”,“高并发”成为主流. NoSQL以key-value形式存储数据, ...
- leetcood学习笔记-69-x的平方根
题目描述: 第一次提交:(会超时) class Solution: def mySqrt(self, x: int) -> int: if x==0 or x==1: return x for ...
- leetcood学习笔记-404-左叶子之和
题目描述: 方法一:递归 class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: if not root: retur ...